[R-sig-Geo] spTransform error

Ross Ahmed rossahmed at googlemail.com
Wed May 15 08:34:19 CEST 2013


I¹ve recently reinstalled QGIS - might this have anything to do with it?


# spTransform() works fine in the other example I posted to the group
yesterday:

library(sp); library(rgeos); library(rgdal)
polygonCoords <- matrix(c(-1.9450, -1.9075, -1.9075, -1.9450, -1.9450,
55.72476, 55.72476, 55.70267, 55.70267, 55.72476), ncol=2)
p = Polygon(polygonCoords)
myPolygon = Polygons(list(p),1)
myPolygonSpatial = SpatialPolygons(list(myPolygon))
proj4string(myPolygonSpatial) <- CRS("+proj=longlat +datum=WGS84
+ellps=WGS84 +towgs84=0,0,0")
gArea(spTransform(myPolygonSpatial, CRS("+proj=laea +lon_0=-1.92
+lat_0=55.7 +datum=WGS84")))/1e6
#[1] 5.796854




# But spTransform() fails in all other instances, for example:

Library(maptools)
data(wrld_simpl)
spTransform(wrld_simpl[1,], CRS("+init=epsg:4326"))
# Error in spTransform(wrld_simpl[1, ], CRS("+init=epsg:4326")) :
# error in evaluating the argument 'CRSobj' in selecting a method for
function 'spTransform': Error in CRS("+init=epsg:4326") : no system list,
errno: 2








# rgdal() start up message

library(rgdal)
Loading required package: sp
rgdal: version: 0.8-9, (SVN revision 470)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.9.2, released 2012/10/08
Path to GDAL shared files:
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: (autodetected)






# sessionInfo() output

sessionInfo()

R version 3.0.0 (2013-04-03)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] tcltk stats4 splines grid stats graphics grDevices utils datasets
methods
[11] base

other attached packages:
[1] Hmisc_3.10-1.1 adehabitat_1.8.12 shapefiles_0.7 tkrplot_0.0-23
[5] ggmap_2.3 formatR_0.7 lme4_0.999999-2 Matrix_1.0-12
[9] adehabitatHR_0.4.7 adehabitatLT_0.3.11 CircStats_0.2-4 MASS_7.3-26
[13] adehabitatMA_0.3.6 ade4_1.5-2 spatialsegregation_2.38 dismo_0.8-11
[17] raster_2.1-25 geosphere_1.2-28 knitr_1.2 lubridate_1.3.0
[21] stringr_0.6.2 boot_1.3-9 coin_1.0-22 modeltools_0.2-19
[25] mvtnorm_0.9-9994 survival_2.37-4 gmodels_2.15.4 ggplot2_0.9.3.1
[29] spatstat_1.31-2 deldir_0.0-22 mgcv_1.7-22 bibtex_0.3-5
[33] plyr_1.8 reshape2_1.2.2 ProjectTemplate_0.4-2 testthat_0.7.1
[37] maptools_0.8-23 lattice_0.20-15 foreign_0.8-53 rgdal_0.8-9
[41] rgeos_0.2-17 sp_1.0-9

loaded via a namespace (and not attached):
[1] cluster_1.14.4 colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3
evaluate_0.4.3
[6] gdata_2.12.0.2 gtable_0.1.2 gtools_2.7.1 labeling_0.1 mapproj_1.2-1
[11] maps_2.3-2 munsell_0.4 nlme_3.1-109 png_0.1-4 proto_0.3-10
[16] RColorBrewer_1.0-5 RgoogleMaps_1.2.0.3 rjson_0.2.12 scales_0.2.3
tools_3.0.0






On 14/05/2013 22:33, "Roger Bivand" <Roger.Bivand at nhh.no> wrote:

>On Tue, 14 May 2013, Ross Ahmed wrote:
>
>> I get the following error when running SpTransform, and error is
>>occurring
>> not matter what object I try to transform:
>>
>> Error in spTransform(columbus, CRS("+init=epsg:27700 +datum=WGS84")) :
>>  error in evaluating the argument 'CRSobj' in selecting a method for
>> function 'spTransform': Error in CRS("+init=epsg:27700 +datum=WGS84") :
>>no
>> system list, errno: 2
>>
>
>You must include all of the important information: all of sessionInfo()
>output, all of the startup messages given by rgdal on loading, and a
>reasonable example (this one isn't, the actual projection is unknown). I
>think you have installed rgdal from source on a system without the
>necessary extra files, but without knowledge of how you installed rgdal,
>it is not possible to tell.
>
>Roger
>
>>
>>
>> I?ve tried to replicate my code using the columbus
>>SpatialPolygonsDataFrame
>> from maptools package:
>>
>> setwd(system.file("shapes", package="maptools"))
>> columbus <- readShapeSpatial(?columbus.shp?)
>> proj4string(columbus) <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84
>> +towgs84=0,0,0")
>> spTransform(columbus, CRS("+init=epsg:4326?))
>>
>> Error in spTransform(columbus, CRS("+init=epsg:27700 +datum=WGS84")) :
>>  error in evaluating the argument 'CRSobj' in selecting a method for
>> function 'spTransform': Error in CRS("+init=epsg:27700 +datum=WGS84") :
>>no
>> system list, errno: 2
>>
>>
>>
>> I?m using R 3.0.0
>>
>> Ross
>>
>>
>>
>> 	[[alternative HTML version deleted]]
>>
>>
>
>-- 
>Roger Bivand
>Department of Economics, NHH Norwegian School of Economics,
>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