[R-sig-Geo] problem with spTransform and SpatialPixelsDataFrame

Roger Bivand Roger.Bivand at nhh.no
Wed Oct 20 08:56:45 CEST 2010


On Wed, 20 Oct 2010, Julian Burgos 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'

The error was caused by a missing +:

library(rgdal)
data(meuse.grid)
gridded(meuse.grid) <- TRUE
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
ll <- spTransform(meuse.grid, CRS("proj=longlat +datum=WGS84"))
ll <- spTransform(meuse.grid, CRS("+proj=longlat +datum=WGS84"))

which coerces to points first, as Mike said it should.

Roger

>
> 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: julian at hafro.is, jmburgos at uw.edu
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list