Learn R Programming

rsgeo (version 0.1.7)

coords: Extract Coordinates

Description

Given an rsgeo class object, extract the object's coordinates as a data frame. Empty or missing geometries are ignored.

Usage

coords(x)

Value

A data.frame with columns x, y. Additional columns are returned based on the geometry type. Additional columns are:

  • id

  • line_id: refers to the LineString ID for rs_LINESTRING, or the component LineString in a MultiLineString, or as the ring ID for a Polygon.

  • multilinestring_id

  • polygon_id

  • multipolygon_id

Arguments

x

an object of class rsgeo

Examples

Run this code
pnt <- geom_point(3, 0.14)
mpnt <- geom_multipoint(1:10, 10:1)
ln <- geom_linestring(1:10, 10:1)
ply <- geom_polygon(c(0, 1, 1, 0, 0), c(0, 0, 1, 1, 0))

coords(pnt)
coords(mpnt)
coords(ln)
coords(union_geoms(rep(ln, 2)))
coords(ply)
coords(union_geoms(rep(ply, 2)))

Run the code above in your browser using DataLab