point: Make WKT point objects

Description Usage Arguments Details See Also Examples

View source: R/point.R

Description

Make WKT point objects

Usage

1
point(..., fmt = 16, third = "z")

Arguments

...

A GeoJSON-like object representing a Point, LineString, Polygon, MultiPolygon, etc.

fmt

Format string which indicates the number of digits to display after the decimal point when formatting coordinates. Max: 20

third

(character) Only applicable when there are three dimensions. If m, assign a M value for a measurement, and if z assign a Z value for three-dimenionsal system. Case is ignored. An M value represents a measurement, while a Z value usually represents altitude (but can be something like depth in a water based location).

Details

The third parameter is used only when there are sets of three points, and you can toggle whether the object gets a Z or M.

When four points are included, the object automatically gets assigned ZM

See Also

Other R-objects: circularstring(), geometrycollection(), linestring(), multilinestring(), multipoint(), multipolygon(), polygon()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## empty point
point("empty")
# point("stuff")

## single point
point(-116.4, 45.2)
point(0, 1)

## single point, from data.frame
df <- data.frame(lon=-116.4, lat=45.2)
point(df)

## many points, from a data.frame
ussmall <- us_cities[1:5, ]
df <- data.frame(long = ussmall$long, lat = ussmall$lat)
point(df)

## many points, from a matrix
mat <- matrix(c(df$long, df$lat), ncol = 2)
point(mat)

## single point, from a list
point(list(c(100.0, 3.101)))

## many points, from a list
point(list(c(100.0, 3.101), c(101.0, 2.1), c(3.14, 2.18)))

## when a 3rd point is included
point(1:3, third = "m")
point(1:3, third = "z")
point(list(1:3, 4:6), third = "m")
point(list(1:3, 4:6), third = "z")
point(matrix(1:9, ncol = 3), third = "m")
point(matrix(1:9, ncol = 3), third = "z")
point(data.frame(1, 2, 3), third = "m")
point(data.frame(1, 2, 3), third = "z")
point(data.frame(1:3, 4:6, 7:9), third = "m")

## when a 4th point is included
point(1:4)
point(list(1:4, 5:8))
point(matrix(1:12, ncol = 4))
point(data.frame(1, 2, 3, 4))
point(data.frame(1:3, 4:6, 7:9, 10:12))

Example output

Attaching package:wellknownThe following object is masked frompackage:graphics:

    polygon

[1] "POINT EMPTY"
[1] "POINT (-116.4000000000000057 45.2000000000000028)"
[1] "POINT (0.0000000000000000 1.0000000000000000)"
[1] "POINT (-116.4000000000000057 45.2000000000000028)"
[1] "POINT (-99.7399999999999949 32.4500000000000028)" 
[2] "POINT (-81.5199999999999960 41.0799999999999983)" 
[3] "POINT (-122.2600000000000051 37.7700000000000031)"
[4] "POINT (-84.1800000000000068 31.5799999999999983)" 
[5] "POINT (-73.7999999999999972 42.6700000000000017)" 
[1] "POINT (-99.7399999999999949 32.4500000000000028)" 
[2] "POINT (-81.5199999999999960 41.0799999999999983)" 
[3] "POINT (-122.2600000000000051 37.7700000000000031)"
[4] "POINT (-84.1800000000000068 31.5799999999999983)" 
[5] "POINT (-73.7999999999999972 42.6700000000000017)" 
[1] "POINT (100.0000000000000000 3.1010000000000000)"
[1] "POINT (100.0000000000000000 3.1010000000000000)"
[2] "POINT (101.0000000000000000 2.1000000000000001)"
[3] "POINT (3.1400000000000001 2.1800000000000002)"  
[1] "POINT M(1 2 3)"
[1] "POINT Z(1 2 3)"
[1] "POINT M(1 2 3)" "POINT M(4 5 6)"
[1] "POINT Z(1 2 3)" "POINT Z(4 5 6)"
[1] "POINT M(1 4 7)" "POINT M(2 5 8)" "POINT M(3 6 9)"
[1] "POINT Z(1 4 7)" "POINT Z(2 5 8)" "POINT Z(3 6 9)"
[1] "POINT M(1.0000000000000000 2.0000000000000000 3.0000000000000000)"
[1] "POINT Z(1.0000000000000000 2.0000000000000000 3.0000000000000000)"
[1] "POINT M(1 4 7)" "POINT M(2 5 8)" "POINT M(3 6 9)"
[1] "POINT ZM(1 2 3 4)"
[1] "POINT ZM(1 2 3 4)" "POINT ZM(5 6 7 8)"
[1] "POINT ZM(1 4 7 10)" "POINT ZM(2 5 8 11)" "POINT ZM(3 6 9 12)"
[1] "POINT ZM(1.0000000000000000 2.0000000000000000 3.0000000000000000 4.0000000000000000)"
[1] "POINT ZM(1 4 7 10)" "POINT ZM(2 5 8 11)" "POINT ZM(3 6 9 12)"

wellknown documentation built on May 26, 2021, 1:06 a.m.