我正在尝试将栅格转换为点shapefile
> library (raster)
> ras <- raster("dem.tif")
> pts = rasterToPoints(ras)
> pts
x y Z
[1,] 70.87500 38.375007 5.035302e+14
[2,] 71.12500 38.375007 4.563356e+14
[3,] 70.62500 38.125007 4.987732e+14
[4,] 70.87500 38.125007 4.108542e+14
[5,] 71.12500 38.125007 4.114788e+14
[6,] 70.37500 37.875006 6.538783e+14
[7,] 70.62500 37.875006 5.798219e+14
[8,] 70.87500 37.875006 5.045395e+14
[9,] 71.12500 37.875006 4.315951e+14
> writeOGR(p,".","output_name,driver="ESRI Shapefile")
Error in writeOGR(p,"filename",driver = "ESRI Shapefile") :
inherits(obj,"Spatial") is not TRUE
> raster::shapefile(pts,"output_name.shp")
Error in (function (classes,fdef,mtable) :
unable to find an inherited method for function ‘shapefile’ for signature ‘"matrix"’
> shapefile(p,outfile,overwrite=TRUE)
Error in (function (classes,mtable) :
unable to find an inherited method for function ‘shapefile’ for signature ‘"matrix"’
>plot(pts)