xy2shp | R Documentation |
xy2shp
Generate a shapefile from coordinates.
xy2shp
xy2shp(xy, df = NULL, crs = NULL, shape = "points")
xy |
matrix |
df |
attribute table |
crs |
projection parameters |
shape |
Shape of the result in points, lines or polygons |
SpatialPointsDataFrame, SpatialLinesDataFrame, or SpatialPolygonsDataFrame
library(raster)
xy=list(cbind(c(0, 2, 1), c(0, 0, 2)), cbind(c(0, 2, 1), c(0, 0, 2))+2)
sp1 = xy2shp(xy=xy, shape = 'polygon')
raster::plot(sp1, axes=TRUE, col='gray')
sp2 = xy2shp(xy=xy, shape = 'lines')
raster::plot(sp2, add=TRUE, lty=2, lwd=3,col='red')
sp3 = xy2shp(xy=xy, shape = 'POINTS')
raster::plot(sp3, add=TRUE, pch=1, cex=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.