rgdal functions: spTransform and CRS not working

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

rgdal functions: spTransform and CRS not working

Ossenbruggen, Paul
The following are examples from the rgdal library help file.

Neither functions operate properly.

Help is appreciated.
Paul

Example 1
> EPSG <- make_EPSG()
Error in make_EPSG() : Error opening epsg file
> EPSG[grep("Oslo", EPSG$note), 1:2]
Error: object 'EPSG' not found
> EPSG[1925:1927, 3]
Error: object 'EPSG' not found


Example 2
> data(meuse)
> coordinates(meuse) <- c("x", "y")
> proj4string(meuse) <- CRS(paste("+init=epsg:28992",
+  "+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812"))
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Error in CRS(paste("+init=epsg:28992", "+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812")) :
  no system list, errno: 2
> # see http://trac.osgeo.org/gdal/ticket/1987
> summary(meuse)
Object of class SpatialPointsDataFrame
Coordinates:
     min    max
x 178605 181390
y 329714 333611
Is projected: NA
proj4string : [NA]
Number of points: 155
Data attributes:
    cadmium           copper            lead            zinc      
 Min.   : 0.200   Min.   : 14.00   Min.   : 37.0   Min.   : 113.0  
 1st Qu.: 0.800   1st Qu.: 23.00   1st Qu.: 72.5   1st Qu.: 198.0  
 Median : 2.100   Median : 31.00   Median :123.0   Median : 326.0  
 Mean   : 3.246   Mean   : 40.32   Mean   :153.4   Mean   : 469.7  
 3rd Qu.: 3.850   3rd Qu.: 49.50   3rd Qu.:207.0   3rd Qu.: 674.5  
 Max.   :18.100   Max.   :128.00   Max.   :654.0   Max.   :1839.0  
                                                                   
      elev             dist               om         ffreq  soil   lime  
 Min.   : 5.180   Min.   :0.00000   Min.   : 1.000   1:84   1:97   0:111  
 1st Qu.: 7.546   1st Qu.:0.07569   1st Qu.: 5.300   2:48   2:46   1: 44  
 Median : 8.180   Median :0.21184   Median : 6.900   3:23   3:12          
 Mean   : 8.165   Mean   :0.24002   Mean   : 7.478                        
 3rd Qu.: 8.955   3rd Qu.:0.36407   3rd Qu.: 9.000                        
 Max.   :10.520   Max.   :0.88039   Max.   :17.000                        
                                    NA's   :2                            
    landuse       dist.m      
 W      :50   Min.   :  10.0  
 Ah     :39   1st Qu.:  80.0  
 Am     :22   Median : 270.0  
 Fw     :10   Mean   : 290.3  
 Ab     : 8   3rd Qu.: 450.0  
 (Other):25   Max.   :1000.0  
 NA's   : 1                  
> meuse.utm <- spTransform(meuse, CRS("+proj=utm +zone=32 +datum=WGS84"))
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Error in spTransform(xSP, CRSobj, ...) :
  No transformation possible from NA reference system
> summary(meuse.utm)
Error in summary(meuse.utm) : object 'meuse.utm' not found
>
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

OS X solution... was Re: rgdal functions: spTransform and CRS not working

David Winsemius

> On Jan 13, 2017, at 1:21 PM, Ossenbruggen, Paul <[hidden email]> wrote:
>
> The following are examples from the rgdal library help file.
>
> Neither functions operate properly.
>
> Help is appreciated.
> Paul
>
> Example 1
>> EPSG <- make_EPSG()
> Error in make_EPSG() : Error opening epsg file

I get the same error. Using OSX:

Built: R 3.3.2; x86_64-apple-darwin13.4.0; 2016-12-17 14:34:29 UTC; unix

.... with recently updated rgdal but did not update either GDAL or PROJ4

Loaded GDAL runtime: GDAL 2.1.2, released 2016/10/24
 Path to GDAL shared files:
 Loaded PROJ.4 runtime: Rel. 4.9.1, 04 March 2015,

which I am seeing some documented problems with

... when I search on the warning message:

WARNING: no proj_defs.dat in PROJ.4 shared files

...  I got when loading rgdal:

https://github.com/OSGeo/proj.4/issues/351

So I'm wondering what OS you have and what version of GDAL and PROJ4 you are using. I'm quitting my session so I can update my system structure. I've had success in hte past with the KingChaos disk images:

GDAL 2.1 Complete
http://www.kyngchaos.com/files/software/frameworks/GDAL_Complete-2.1.dmg

Used the disk image from Finder.app

That failed to resolve the warning or the error from rgdal::make_EPSG. Tried (re-)installing rgdal from current source tar.gz file using install.packages. Got an error relating to missing gdal-config

So based on a stackOverflow solution from Fran Villamil: http://stackoverflow.com/questions/34333624/trouble-installing-rgdal/37829420#37829420, I tried (from the R console):

install.packages('rgdal', type = "source", configure.args=c(
'--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config',
'--with-proj-include=/Library/Frameworks/PROJ.framework/Headers',
'--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))


reloaded R and ... no warnings or errors

I'm a somewhat clueless, albeit noisy user of R. I don't really have the development skills to figure out how to construct the code to tie together all these compiled bits, but I do find that searching is often sufficient to solve problems. If this is not an exact match to your situation,  then you should first read the posting guide and include sufficient information about _your_ OS, your system tools,  and versions of external-to-R packages to support a more focussed discussion.

Best;
David.


>> EPSG[grep("Oslo", EPSG$note), 1:2]
> Error: object 'EPSG' not found
>> EPSG[1925:1927, 3]
> Error: object 'EPSG' not found
>
>
> Example 2
>> data(meuse)
>> coordinates(meuse) <- c("x", "y")
>> proj4string(meuse) <- CRS(paste("+init=epsg:28992",
> +  "+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812"))
> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
> Error in CRS(paste("+init=epsg:28992", "+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812")) :
>  no system list, errno: 2
>> # see http://trac.osgeo.org/gdal/ticket/1987
>> summary(meuse)
> Object of class SpatialPointsDataFrame
> Coordinates:
>     min    max
> x 178605 181390
> y 329714 333611
> Is projected: NA
> proj4string : [NA]
> Number of points: 155
> Data attributes:
>    cadmium           copper            lead            zinc      
> Min.   : 0.200   Min.   : 14.00   Min.   : 37.0   Min.   : 113.0  
> 1st Qu.: 0.800   1st Qu.: 23.00   1st Qu.: 72.5   1st Qu.: 198.0  
> Median : 2.100   Median : 31.00   Median :123.0   Median : 326.0  
> Mean   : 3.246   Mean   : 40.32   Mean   :153.4   Mean   : 469.7  
> 3rd Qu.: 3.850   3rd Qu.: 49.50   3rd Qu.:207.0   3rd Qu.: 674.5  
> Max.   :18.100   Max.   :128.00   Max.   :654.0   Max.   :1839.0  
>
>      elev             dist               om         ffreq  soil   lime  
> Min.   : 5.180   Min.   :0.00000   Min.   : 1.000   1:84   1:97   0:111  
> 1st Qu.: 7.546   1st Qu.:0.07569   1st Qu.: 5.300   2:48   2:46   1: 44  
> Median : 8.180   Median :0.21184   Median : 6.900   3:23   3:12          
> Mean   : 8.165   Mean   :0.24002   Mean   : 7.478                        
> 3rd Qu.: 8.955   3rd Qu.:0.36407   3rd Qu.: 9.000                        
> Max.   :10.520   Max.   :0.88039   Max.   :17.000                        
>                                    NA's   :2                            
>    landuse       dist.m      
> W      :50   Min.   :  10.0  
> Ah     :39   1st Qu.:  80.0  
> Am     :22   Median : 270.0  
> Fw     :10   Mean   : 290.3  
> Ab     : 8   3rd Qu.: 450.0  
> (Other):25   Max.   :1000.0  
> NA's   : 1                  
>> meuse.utm <- spTransform(meuse, CRS("+proj=utm +zone=32 +datum=WGS84"))
> NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
> Error in spTransform(xSP, CRSobj, ...) :
>  No transformation possible from NA reference system
>> summary(meuse.utm)
> Error in summary(meuse.utm) : object 'meuse.utm' not found
>>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: OS X solution... was Re: rgdal functions: spTransform and CRS not working

Roger Bivand
I apologise for not following up in-thread, as I used to use Gmane to
reply to postings read digested before its (hopefully temporary) demise.

The problem is that the CRAN OSX binaries for rgdal are shipping without
two key folders, proj/ and gdal/. Until we get it fixed, please see if you
can download the equivalent Windows binary package:

https://cran.r-project.org/bin/windows/contrib/3.3/rgdal_1.2-5.zip

unzip it (do not install it), and copy the proj/ and gdal/ folders with
their contents to the folder shown (in R) by:

system.file("", package="rgdal")

For OSX-specific questions like this, you could try R-sig-mac, for spatial
data R-sig-geo. Always show the output of sessionInfo() when reporting
issues.

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Roger Bivand
Department of Economics
NHH Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: OS X solution... was Re: rgdal functions: spTransform and CRS not working

Ossenbruggen, Paul
Thank you for your assistance.

David Winsemius gave me a work around solution that addresses the issue.

I thank both of you.

Paul

Sent from my iPad

> On Jan 16, 2017, at 5:02 AM, Roger Bivand <[hidden email]> wrote:
>
> I apologise for not following up in-thread, as I used to use Gmane to reply to postings read digested before its (hopefully temporary) demise.
>
> The problem is that the CRAN OSX binaries for rgdal are shipping without two key folders, proj/ and gdal/. Until we get it fixed, please see if you can download the equivalent Windows binary package:
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_bin_windows_contrib_3.3_rgdal-5F1.2-2D5.zip&d=DwIBAg&c=c6MrceVCY5m5A_KAUkrdoA&r=WDD4_Yg52kDcV1-aTnZGuPa5XvnE9sRyJLzwnTtaEa4&m=dgU0yI25qorGYcBVyZbsn1WJw773Uh-jx0lQHACi8t0&s=wnPJ31FbUqePLKa2rQgFFPi0-GvGKY8XFGUZQHoEmGY&e= 
> unzip it (do not install it), and copy the proj/ and gdal/ folders with
> their contents to the folder shown (in R) by:
>
> system.file("", package="rgdal")
>
> For OSX-specific questions like this, you could try R-sig-mac, for spatial data R-sig-geo. Always show the output of sessionInfo() when reporting issues.
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; e-mail: [hidden email]
> https://urldefense.proofpoint.com/v2/url?u=http-3A__orcid.org_0000-2D0003-2D2392-2D6140&d=DwIBAg&c=c6MrceVCY5m5A_KAUkrdoA&r=WDD4_Yg52kDcV1-aTnZGuPa5XvnE9sRyJLzwnTtaEa4&m=dgU0yI25qorGYcBVyZbsn1WJw773Uh-jx0lQHACi8t0&s=vkKFU5pFCkqarbvnL7h3LHTf2FOeqRHz5kXzN-LepwE&e= https://urldefense.proofpoint.com/v2/url?u=https-3A__scholar.google.no_citations-3Fuser-3DAWeghB0AAAAJ-26hl-3Den&d=DwIBAg&c=c6MrceVCY5m5A_KAUkrdoA&r=WDD4_Yg52kDcV1-aTnZGuPa5XvnE9sRyJLzwnTtaEa4&m=dgU0yI25qorGYcBVyZbsn1WJw773Uh-jx0lQHACi8t0&s=BzwpcCxeGE8YMisKdas7VFF6YDAXFoMyLygD2PI5XGU&e= https://urldefense.proofpoint.com/v2/url?u=http-3A__depsy.org_person_434412&d=DwIBAg&c=c6MrceVCY5m5A_KAUkrdoA&r=WDD4_Yg52kDcV1-aTnZGuPa5XvnE9sRyJLzwnTtaEa4&m=dgU0yI25qorGYcBVyZbsn1WJw773Uh-jx0lQHACi8t0&s=vDry50VlCgUoz7ZoJu5j2rg-DBKK2fPQ9jjWxOLNoIc&e= 

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.