[R-sig-Geo] Raster to points

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Sep 3 18:08:12 CEST 2009


2009/9/3 Cutberto Uriel Paredes Hernández <cutberto.paredes at gmail.com>:
> Dear list,
>
> Is there a way to convert a raster to points in R
> (SpatialGridDataFrame to SpatialPointsDataFrame)? I know I can do this
> with ArcGIS but I would like not to use propietary software.

 Just build one from the coordinates and the data:

 >  data(meuse.grid)
 >  m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data
= meuse.grid)
 > class(m)
 [1] "SpatialPixelsDataFrame"
 > fullgrid(m)=TRUE
 > class(m)
 [1] "SpatialGridDataFrame"

 # now we have a SGDF, so convert to SPDF:
 > mp=SpatialPointsDataFrame(coordinates(m),data=m at data)

 > class(mp)
 [1] "SpatialPointsDataFrame"

 > names(mp at data)
 [1] "x"      "y"      "part.a" "part.b" "dist"   "soil"   "ffreq"

Barry



More information about the R-sig-Geo mailing list