SpatialPixelsDataFrame cannot be reprojected without converting to points,
and a lot of manual handling / resampling. The raster package can do it
though, see ?projectRaster

e.g.
library(sp)
data(meuse.grid)
m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data =
meuse.grid)
proj4string(m) <- CRS("+init=epsg:28992")
library(raster)
library(rgdal)
r <- raster(m)
newproj <- "+proj=longlat +ellps=WGS84"

pr <- projectExtent(r, newproj)
# project the values of RasterLayer 'r' to the new RasterLayer

pr <- projectRaster(r, pr)

sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
other attached packages:
[1] rgdal_0.6-28  raster_1.5-16 sp_0.9-72
loaded via a namespace (and not attached):
[1] grid_2.12.0     lattice_0.19-13 tools_2.12.0


On Wed, Oct 20, 2010 at 1:37 PM, Julian Burgos <jmbur...@uw.edu> wrote:

> Dear list,
> I have a problem trying to change the projection of a
> SpatialPixelsDataFrame, from UTM to lat/long.  My object has the following
> characteristics:
>
> > summary(mb)
> Object of class SpatialPixelsDataFrame
> Coordinates:
>        min       max
> X -14.17196 -13.76879
> Y  63.75071  63.96791
> Is projected: TRUE
> proj4string : [+proj=utm +zone=28 +datum=WGS84]
> Number of points: 5669540
> Grid attributes:
>  cellcentre.offset     cellsize cells.dim
> X         -14.17189 1.347473e-04      2992
> Y          63.75074 5.944386e-05      3654
> Data attributes:
>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>  108.5   230.3   256.9   283.0   287.9   987.6
>
> when using the  spTransform I get the following error message:
>
> > mb=spTransform(mb,CRS("proj=longlat +datum=WGS84"))
> Error in spTransform(mb, CRS("proj=longlat +datum=WGS84")) :
>  error in evaluating the argument 'CRSobj' in selecting a method for
> function 'spTransform'
>
> Any ideas what is the problem?
> Many thanks,
>
> Julian Burgos
>
> Julian Mariano Burgos
> Hafrannsóknastofnunin/Marine Research Institute
> Skúlagata 4, 121 Reykjavík, Iceland
> Sími/Telephone : +354-5752037
> Bréfsími/Telefax:  +354-5752001
> Netfang/Email: jul...@hafro.is, jmbur...@uw.edu
>
>        [[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
>
>


-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

        [[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