[R-sig-Geo] spTransform / SpatialPixelsDataFrame
twah at gmx.ch
twah at gmx.ch
Thu Apr 21 13:10:35 CEST 2016
Hello
I would like to reproject a SpatialPixelsDataFrame, changing the CRS. I
am trying to use the command "spTransform" from the package "sp".
Unfortunately, the command results in a SpatialPointsDataFrame, which is
not desired. My SpatialPixelsDataFrame has proj4string
+init=epsg:21781 +proj=somerc +lat_0=46.95240555555556
+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel
+towgs84=674.4,15.1,405.3,0,0,0,0
+units=m +no_defs
The command which results in a SpatialPointsDataFrame is:
SPDF2<-spTransform(SPDF1,CRS("+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0"))
An object transformation through
SPDF3<-as(SPDF2,"SpatialPixelsDataFrame")
results in an error, possibly since in the underlying problem the SPDF2
is a subset for a particular layer, so it is not a full grid.
Can someone help?
Thanks.
More information about the R-sig-Geo
mailing list