Closed tcwilkinson closed 2 years ago
Please confirm that you rebuilt GDAL with new PROJ, as the two are connected. What does sf_extSoftVersion()
say? You will need to re-install sf avoiding pre-installation of proj.db
on your platform - if you have access to Linux, use rather that than macOS. On Windows and macOS, sf and other packages using PROJ, GDAL, GEOS package basic shared metadata, so very possibly your PROJ HEAD proj.db
is simply not seen by sf. My PROJ 8.2.1 shows errors with both sf and rgdal - the latter does not go via GDAL.
> CRS("+proj=peirce_q +lon_0=25 +shape=square")
proj_create: Error 1027 (Invalid value for an argument): peirce_q: peirce_q: invalid value for 'type' parameter
proj_create: Error 1027 (Invalid value for an argument): peirce_q: peirce_q: invalid value for 'type' parameter
Error in CRS("+proj=peirce_q +lon_0=25 +shape=square") : NA
> CRS("+proj=peirce_q +lon_0=25 +type=square")
proj_normalize_for_visualization: Cannot retrieve source or target CRS
proj_normalize_for_visualization: Cannot retrieve source or target CRS
Error in CRS("+proj=peirce_q +lon_0=25 +type=square") : NA
Thanks for checking this out.
sf_extSoftVersion()
as above under Details.proj.db
but since sf_extSoftVersion show 8.2.0 (which I take to mean it is linked to HEAD version, as before build it was linked to current stable, i.e. 8.2.1), am confused as to where sf is looking.For me, CRS()
gives different WKT results from st_crs()
, with the HEAD branch (see below). How do each of these generate their WKT strings?
> CRS("+proj=peirce_q +lon_0=25 +shape=square")
Coordinate Reference System:
Deprecated Proj.4 representation:
+proj=peirce_q +shape=square +lat_0=90 +lon_0=25 +k_0=1 +x_0=0 +y_0=0
+datum=WGS84 +units=m +no_defs
WKT2 2019 representation:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["Peirce Quincuncial (Square)"],
PARAMETER["Latitude of natural origin",90,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",25,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]]
> st_crs("+proj=peirce_q +lon_0=25 +shape=square")
Coordinate Reference System:
User input: +proj=peirce_q +lon_0=25 +shape=square
wkt:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["PROJ peirce_q"],
PARAMETER["lon_0",25,
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]]
CRS()
above seems to acknowledge the square param as METHOD["Peirce Quincuncial (Square)"]
, but then it gives the same response for another shape (+shape=horizontal
), which is wrong (see below). Again this may well be upstream somewhere, but I don't know where to look to chase it up. Any help gratefully received!
> CRS("+proj=peirce_q +lon_0=25 +shape=horizontal")
Coordinate Reference System:
Deprecated Proj.4 representation:
+proj=peirce_q +shape=square +lat_0=90 +lon_0=25 +k_0=1 +x_0=0 +y_0=0
+datum=WGS84 +units=m +no_defs
WKT2 2019 representation:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["Peirce Quincuncial (Square)"],
PARAMETER["Latitude of natural origin",90,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",25,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]]
ps. Have not tried on linux yet... (Some time needed to set up an equivalent working vm...)
Briefly, sf_proj_search_paths() shows where the runtime in sf is looking. sf goes through GDAL, so is perhaps losing contact with the updated definition there.
OK, makes sense, thanks.
sf_proj_search_paths()
was searching remnant homebrew/cellar installation of version 7.2.1 I had... but updating these paths made no difference to outputted WKT from sf::st_crs()
so problem may well be trip via gdal as you say.
Do you have any idea why i) CRS("+proj=peirce_q +lon_0=25 +shape=square")
and ii) CRS("+proj=peirce_q +lon_0=25 +shape=horizontal")
both produce the same WKT+proj output (with (ii) being wrong). Is this WKT string created in rgdal, or returned from a call to the PROJ api ? ...I can chase up over on PROJ if the second...
Is this WKT string created in rgdal, or returned from a call to the PROJ api ? ...I can chase up over on PROJ if the second...
It's created by GDAL, which calls PROJ in turn. See https://github.com/r-spatial/sf/blob/main/src/gdal.cpp#L117-L122
Building against GDAL current HEAD and PROJ current HEAD:
> st_crs("+proj=peirce_q +lon_0=25 +shape=square")
Coordinate Reference System:
User input: +proj=peirce_q +lon_0=25 +shape=square
wkt:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["Peirce Quincuncial (Square)"],
PARAMETER["Latitude of natural origin",90,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",25,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]]
And yes, +shape=square
and +shape=horizonal
give the same WKT2, +shape=diamond
does seem to feed through. With GDAL current HEAD:
library(sf)
sq <- st_crs("+proj=peirce_q +lon_0=25 +shape=square")
library(rnaturalearth)
sf_world <- ne_download( scale = 110, type = 'countries' , returnclass="sf")
plot(st_geometry(st_transform(sf_world, sq)))
dm <- st_crs("+proj=peirce_q +lon_0=25 +shape=diamond")
plot(st_geometry(st_transform(sf_world, dm)))
Looks like an upstream (PROJ) problem that has been solved in PROJ 9.0.0RC1:
> library(sf)
Linking to GEOS 3.10.0, GDAL 3.4.1, PROJ 9.0.0; sf_use_s2() is TRUE
> x1 = st_crs("+proj=peirce_q +lon_0=25 +shape=square")
> x2 = st_crs("+proj=peirce_q +lon_0=25 +shape=horizontal")
> all.equal(x1, x2)
[1] "Component \"input\": 1 string mismatch"
[2] "Component \"wkt\": 1 string mismatch"
> x1
Coordinate Reference System:
User input: +proj=peirce_q +lon_0=25 +shape=square
wkt:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["Peirce Quincuncial (Square)"],
PARAMETER["Latitude of natural origin",90,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",25,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]]]
> x2
Coordinate Reference System:
User input: +proj=peirce_q +lon_0=25 +shape=horizontal
wkt:
PROJCRS["unknown",
BASEGEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]]],
CONVERSION["unknown",
METHOD["PROJ peirce_q shape=horizontal"],
PARAMETER["lon_0",25,
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1,
ID["EPSG",9001]]],
REMARK["PROJ CRS string: +proj=peirce_q +lon_0=25 +shape=horizontal"]]
Describe the bug Essential parameter of the (recently updated)
peirce_q
projection do not seem to appear in the WKT form after st_crs(). This has obvious consequences for translation etc.This may well be an upstream issue, but can't get the same WKT using proj cmd line tools so not sure how st_crs() generates the WKT string (presumably via C api?).
Any help tracking this down, much appreciated.
To Reproduce
Will need the current master branch version of PROJ (>8.2.1) in order to test with "+shape"
OK that's fine, but add in the parameter
+shape=square
[in HEAD branch of proj, in 8.2.1 the value was (wrongly)+type=square
], and you end up with exactly the same, except the user input:-For comparison, PROJ via command line
projinfo
provides:Additional context The context is trying to get the new peirce_q projection to work for a mapping project, hence am currently using the master branch (HEAD) build of PROJ. (Have been contributing to PROJ library to get this to work, and trying to find + iron out any issues before next PROJ release.)