geo_collection: Geometry constructors

Description Usage Arguments Value Examples

View source: R/geo-collection.R

Description

These functions provide a means to construct geometries from data frames, possibly using dplyr::group_by() and dplyr::summarise(). Collections contain zero or more objects of type geo_point(), geo_linestring(), geo_polygon(), geo_multipoint(), geo_multilinestring(), and/or geo_multipolygon(). See wkutils::coords_point_translate_wkb() and related functions for high-performance methods to create these vectors.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
geo_collection(feature = wksxp(), srid = NA)

geo_point(xy = geo_xy(), srid = NA)

geo_linestring(xy = geo_xy(), srid = NA)

geo_polygon(xy = geo_xy(), ring = 1L, srid = NA)

geo_multipoint(feature = wksxp(), srid = NA)

geo_multilinestring(feature = wksxp(), srid = NA)

geo_multipolygon(feature = wksxp(), srid = NA)

Arguments

feature

A vector of one or more features. For multi geometries, this must be a collection that only contains that type (e.g., multipolygons can only be composed of polygons).

srid

A spatial reference identifier, coerced to an integer by as_geo_srid(). These identifiers can and should be managed outside of geovctrs except for 0, which is interpreted as "not set".

xy

A geo_xy() of coordinates

ring

A vector whose unique values separate rings. Row order matters: the first value encountered will identify the outer ring.

Value

A wk::wksxp() of length 1.

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
# geo_point() and family all return a wk::wksxp() of length 1
c(geo_point(geo_xy(0, 1)), geo_point(geo_xy(1, 2)))

# linestring
geo_linestring(geo_xy(1:5, 2:6))

# a polygon
geo_polygon(geo_xy(c(0, 10, 0, 0), c(0, 0, 10, 0)))

# polygon with a hole
poly_hole <- geo_polygon(
  geo_xy(
    c(35, 45, 15, 10, 35, 20, 35, 30, 20),
    c(10, 45, 40, 20, 10, 30, 35, 20, 30)
  ),
  ring = c(1, 1, 1, 1, 1, 2, 2, 2, 2)
)

# multipoint
geo_multipoint(
  c(geo_point(geo_xy(10, 30)), geo_point(geo_xy(12, 11)))
)

# multilinestring
geo_multilinestring(
  c(
    geo_linestring(geo_xy(0:1, 0:1)),
    geo_linestring(geo_xy(c(12, 30), c(11, 10)))
  )
)

# multipolygon
geo_multipolygon(
  geo_polygon(geo_xy(c(0, 10, 0, 0), c(0, 0, 10, 0)))
)

# nested geo_collection()
c(geo_point(geo_xy(0, 1)), geo_collection(geo_point(geo_xy(1, 2))))

paleolimbot/geovctrs documentation built on July 30, 2020, 3:41 p.m.