Cast geometries to another type
Arguments
- x
an object of class
rsgeo
- to
a character scalar of the target geometry type. Must be one of
"point"
,"multipoint"
,"polygon"
,"multipolygon"
,"linestring"
, or"multilinestring"
.
Details
The below conversions are made available. The left hand column indicates the originating vector class and the right hand column indicates the class that it will can be cast to.
Note that correctness of conversions will not be checked or verified. If you
cast an rs_MULTIPOINT
to an rs_POLYGON
, the validity of the polygon
cannot be guaranteed.
Conversions from an rs_POLYGON
into an rs_LINESTRING
will result in only
the exterior ring of the polygon ignoring any interior rings if there are any.
From | To |
rs_POINT | rs_MULTIPOINT |
rs_MULTIPOINT | rs_POLYGON , rs_MULTIPOLYGON , rs_LINESTRING , rs_MULTILINESTRING |
rs_POLYGON | rs_MULTIPOINT , rs_MULTIPOLYGON , rs_LINESTRING , rs_MULTILINESTRING |
rs_MULTIPOLYGON | rs_MULTIPOINT , rs_MULTILINESTRING |
rs_LINESTRING | rs_MULTIPOINT , rs_MULTILINESTRING , rs_POLYGON |
rs_MULTILINESTRING | rs_MULTIPOINT , rs_MULTIPOLYGON |
Examples
ply <- geom_polygon(c(0, 1, 1, 0, 0), c(0, 0, 1, 1, 0))
cast_geoms(ply, "linestring")
#> <rs_LINESTRING[1]>
#> [1] LineString([Coord { x: 0.0, y: 0.0 }, Coord { x: 1.0, y: 0.0 }, Coord { x:...
cast_geoms(ply, "multipoint")
#> <rs_MULTIPOINT[1]>
#> [1] MultiPoint([Point(Coord { x: 0.0, y: 0.0 }), Point(Coord { x: 1.0, y: 0.0 ...