[R-sig-Geo] spTransform / SpatialPixelsDataFrame
Roger Bivand
Roger.Bivand at nhh.no
Thu Apr 21 13:29:19 CEST 2016
On Thu, 21 Apr 2016, twah at gmx.ch wrote:
> 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?
You cannot in general project grids, because the spacings between cell
centre points will no longer be fixed. You can convert to a raster object
and *warp* that grid to a new grid in the new projection with regularly
spaced points, but with output cell centre points that do not match the
projected points. Often, interpolation is needed to decide which value
should be assigned to the output grid cells.
Roger
>
> Thanks.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
More information about the R-sig-Geo
mailing list