xy2shp: Generate a shapefile from coordinates. 'xy2shp'

View source: R/Func_GIS.R

xy2shpR Documentation

Generate a shapefile from coordinates. xy2shp

Description

Generate a shapefile from coordinates. xy2shp

Usage

xy2shp(xy, df = NULL, crs = NULL, shape = "points")

Arguments

xy

matrix

df

attribute table

crs

projection parameters

shape

Shape of the result in points, lines or polygons

Value

SpatialPointsDataFrame, SpatialLinesDataFrame, or SpatialPolygonsDataFrame

Examples

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)


SHUD-System/SHUDtoolbox documentation built on Nov. 27, 2024, 5:54 a.m.