[R-sig-Geo] spTransform() error : "load package rgdal for spTransform methods"

Remi Genevest rgenevest at free.fr
Wed Aug 6 12:38:04 CEST 2014


Hi,
I am facing a recurrent problem associated with spTransform() function from
rgdal package.
While I try to change the CRS of a SpatialGrid, I get the following error : 

Error in spTransform(grd, CRS("+init=epsg:3857")) : 
  load package rgdal for spTransform methods

Does anybody know how to solve it?

Here is my code : 

> library(rgdal)
> # create the SpatialGrid
> cc<-c(10,20)
> cs<-c(0.1,0.1)
> cd<-c(200,200)
> grd<-GridTopology(cellcentre.offset=cc,cellsize=cs,cells.dim=cd)
> grd<-SpatialGrid(grd)
> # set the CRS :
> proj4string(grd)<-CRS("+proj=longlat +datum=WGS84")
> # transform the CRS : 
> grd<-spTransform(grd,CRS("+init=epsg:3857"))
Error in spTransform(grd, CRS("+init=epsg:3857")) : 
  load package rgdal for spTransform methods
> 
> ###################################################### R info session 
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
LC_MONETARY=en_GB.UTF-8   
 [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
base     

other attached packages:
[1] rgdal_0.8-16    raster_2.2-31   hexbin_1.26.3   lattice_0.20-29
sp_1.0-15      

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.4     ggplot2_1.0.0    gtable_0.1.2    
MASS_7.3-33      munsell_0.4.2    plyr_1.8.1       proto_0.3-10    
Rcpp_0.11.2     
[10] reshape2_1.4     scales_0.2.4     stringr_0.6.2    tools_3.1.1     



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/spTransform-error-load-package-rgdal-for-spTransform-methods-tp7586877.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list