Hi Stefano,
the coordinates(x) solved the problem. Thank you very much.

Laura


2010/1/22 Stefano Casalegno <stef...@casalegno.net>

> Dear Laura,
> hope this can help you
>
> stefano
>
> To convert a raster to points in R, 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),dat...@data)
> class(mp)
>  [1] "SpatialPointsDataFrame"
> names(m...@data)
>  [1] "x"      "y"      "part.a" "part.b" "dist"   "soil"   "ffreq"
>
>
>
> On Jan 22, 2010, at 9:25 AM, Laura Poggio wrote:
>
> Dear all,
> I am reading a raster file using the readGDAL function. The file has
> 360x364
> cells.
> Looking at the structure of the object (class SpatialGridDataFrame)
> obtained
> I can see:
>
> @ coords     : num [1:2, 1:2] 4081420 4092190 2955325 2966215
>
> I need to transform it as SpatialPixelsDataFrame or data.frame, i.e.
> @ coords     :num [1:130960, 1:2] 4081420 4081450 4081480 4081510 4081540
> ...
>
> I tested a couple of methods:
> 1) dem1 <- as(x, "data.frame")
> 2) fullgrid(x) = FALSE
>
> however both have some problems, i.e. the length of the object obtained is
> only 130960 instead of 131040.
> I think I am doing something wrong, but I can not find what...
>
> Thank you very much in advance.
>
> Laura
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to