[R-sig-Geo] how to find projections supported by sf::st_crs()?

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Tue Jan 21 16:54:35 CET 2020


Please note that anything I am going to write concerns current sf (on
CRAN), and that things will change pretty strongly in a month or so,
driven by GDAL 3.x and PROJ 6.2.x releases.

st_crs() takes a proj4string or an EPSG number, and tries to resolve
this using GDAL. Although it uses PROJ, GDAL is more strict than PROJ in
accepting proj4strings, and as you noted +wintri is not accepted.

sf_project() was written exactly for the reason that it communicates to
PROJ without going through GDAL, and hence is more flexible; all
proj4strings PROJ accepts are fine as input, but those that are not
accepted by GDAL can only be passed as character strings for the reason
mentioned above.

Hth,

On 1/21/20 3:45 PM, Daniel Kelley wrote:
> I am pondering the use of `sf::sf_project()` for map-projection calculations within the `oce` package. My impression is that `sf::st_crs()` ought to be used to process projection strings, instead of handing strings directly to `sf::sf_project()`.  (I think the idea is that this will lead to the addition of extra information about the ellipse model, etc., and perhaps do some checks for errors in the string.)
> 
> However, my tests show that `sf::st_crs()` balks at some projections, such as `wintri`, as shown in the code snippets given near the end of this email.  (Those snippets also show that `sf::sf_project()` handles the wintri projection, as does `rgdal::project()`, so the warning does not mean that `sf` will refuse to do the projection.)
> 
> This leads me to three questions, that I'm hoping others can shed light on.
> 
> 1. Am I right in thinking that I ought to use `sf::sf_crs()` to "clean up" my projection specifications?
> 
> 2. Is there a way to find the list of projections that `sf::sf_crs()` accepts without producing `NA` results and warnings?
> 
> 3. Should I avoid using projections that `sf::sf_crs()` warns about?
> 
> I apologize if I ought to have gathered the results from my reading.  I could be looking in the wrong places.
> 
> Thanks in advance for any advice!  -- Dan.
> 
> ```R
>> library(sf)
> Linking to GEOS 3.8.0, GDAL 2.4.2, PROJ 6.2.1
> 
>> sf::sf_project("+proj=lonlat", "+proj=wintri", cbind(0,0))
>      [,1] [,2]
> [1,]    0    0
> 
>> sf::st_crs("+proj=wintri")
> Coordinate Reference System: NA
> Warning message:
> In CPL_crs_from_proj4string(x) :
>   GDAL cannot import PROJ.4 string `+proj=wintri': returning missing CRS
> ```
> 
> Dan E. Kelley [he/him/his 314ppm]
> Dalhousie University
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 3110 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20200121/319b0e69/attachment.bin>


More information about the R-sig-Geo mailing list