-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling local CRS, st_can_transform() #2049
Comments
With sf
In rgdal, the So while current sf HEAD on I'm not planning to make any changes to rgdal, but if Basically, this provides additional support for my strong view that ggplot should never have imposed graticules, as nobody I know implicitly knows the geographical coordinates for places on interest on any map; they just are never used for orientation as a grid might be on an xy plot. |
Curiously:
|
I was planning to revert (undo) d016301, which is responsible for that.
That would be another issue. I think they are easier to understand than grids in projected coordinates, and their shape may help understanding what kind of projection took place. |
Yes, I understand. Might an RFC make sense? This reaches packages like tmap too, and mapview to transform to Web Mercator. I'll actually need to modify rgdal too, the geometry is associated with
Further:
My argument with graticules in ggplot is that they may be added for the purpose you describe (world/continental scales) but should not be required as the default setting for maps. Adding them as a non-default decoration is fine - the issue is that thematic cartography in general avoids that kind of unnecessary ink, with the exception of conveying the message that projection distortion is or may be in play. That is a small minority of use cases, I feel. |
|
With
The
So to keep missing SRS as planar,
If a generic planar is imposed:
|
Note also https://gdal.org/drivers/vector/gpkg.html#coordinate-reference-systems, where |
And:
For s2:
|
Next step: what we need is not:
but we certainly need to avoid asserting the units as metres, for example by:
However:
And:
So we are obliged to accept the probably wrong metre unit. |
Interesting and constructive response from @rouault : https://lists.osgeo.org/pipermail/proj/2022-December/010842.html with
Because the unit now gets a type, name and conversion factor, perhaps this is a way forward to let us migrate to GPKG where SRS are planar and units are unknown? |
if you really intend to use conversion_factor=0, I'd suggest you add a test case in PROJ test suite to check that we can parse such CRS (in test/unit/test_io.cpp). Otherwise, it might be possible that someone in a few years forgets that use case, and facing an issue related to the ones I mentioned in https://lists.osgeo.org/pipermail/proj/2022-December/010842.html, just decides to reject such CRS on import. |
The tests seem to run OK with: https://github.com/rsbivand/proj.4/commit/4ace26fbe4f8357dcedb336bf56c232d894c72fb . Should I specifically test the unit name and conversion factor (added in https://github.com/rsbivand/proj.4/commit/ab825221823929253b4c17b111734473009bfc5d)? @rouault, may I wait until I've checked a little more (@edzer ?) with R packages before going to a PR? Should we use |
the conversion factor.
sure, I meant if you intend that to be supported long term.
Reviewing the WKT CRS spec, I believe the empty string is not technically legal. There should be at least one character in a quote string acording to the BNF grammar. I'm going to fix PROJ to expand |
Conversion factor included as per https://github.com/rsbivand/proj.4/commit/ab825221823929253b4c17b111734473009bfc5d. I've rebuilt and run So "Engineering datum" in |
"Unknown datum" name test added in https://github.com/rsbivand/proj.4/commit/8e7aa36bb22c603427d74f964fcd8e79ba62006d. |
…e for the datum Otherwise, the WKT2 output as a engineering CRS will be technically invalid, as the BNF of WKT2 requires a non-empty double-quoted string. Fixes r-spatial/sf#2049 (comment)
submitted in OSGeo/PROJ#3491 |
no, in "Test #54: proj_test_cpp_api" |
So:
indicates passing with my addition, now with "Unknown datum" in too. |
The east & north directions might be even presumptuous for a unknown CRS. Perhaps using the "unspecified" direction would be better
... But ... I'm not totally sure that unspecified is legal for a Cartesian CS in a engineering CRS. "unspecified" would be clearly illegal for a projected CRS: """c) For projected CRSs, except for coordinate systems centred on a pole, the horizontal axis direction shall be 'north' or 'south' and 'east' or 'west'.""" |
Yes, I'd thought of |
the "X" or "Y" strings are axis names, governed by http://docs.opengeospatial.org/is/18-010r7/18-010r7.html#47, which are governed by a few conventions described in that paragraph. On the contrary "unspecified" is one of the members of the enumerated list. in the context of WKT CRS / ISO 19111, "vertical" implies indeed some sort of height. |
Can I test for the unspecified token in each axis? |
Linking to https://mastodon.social/@edzer/109438013774699729 and subsequent; no reverse dependency failures that can be attributed to using:
for "most" sf reverse dependencies for the
|
No extra failures resulting from using |
@rouault would you like me to create a PR including the new test? |
yes, please do. |
Maybe it would be better to lift https://github.com/rsbivand/proj.4/blob/07a70d3f2397a627b4ae6855afb35cf6e47f9b49/test/unit/test_io.cpp#L5268-L5299 directly, as on starting a PR I see that my fork has redundant copies of two other files which should not be proposed for merging. I do not know how to tell github to only choose changes to a single file, dropping the two others. |
something along
|
Sorry, that didn't work. I'm not sure which order the pushes should be cherry-picked. I'd like to avoid having to re-fork if possible to get a clean repo from which to re-start. |
you shouldn't need to re-fork with the correct git invocations (sometimes a |
Yes, I deleted the fork (was proj.4 anyway, so pretty old). Re-establishing with a new fork, hopefully cleanly. |
OSGeo/PROJ#3494 created. |
Fantastic. Shall we substitute this WKT definition for the current |
PR created in |
So we now have a valid WKT crs that (currently) is not identical to
but that behaves identically: Cartesian, unknown units. This breaks measures (length, area) because not NA but also no units - so far CRS with a WKT were assumed to have units (wrongly substituting [m] when unkonwn). Shall we substitute this WKT definition for the current |
I think that I'd tend to view geographical as implying that we know more than planar. I sense that raster went the other way, but I don't find any very strong argument for then saying that coordinates that would be valid within +/- 90 and +/- 180 or 0-360 should be geographical and others planar. I think planar is the position that assumes least. |
This came up here: r-spatial/stars#622 (comment) when I tried to assign the "Undefined Cartesian SRS with unknown unit" to the GeoTIFF and warp it using the GPKG with the same SRS:
which can be reproduced command line with
Reprex in R:
|
…and relax isEquivalentTo() comparisons to deal with case of r-spatial/sf#2049 (comment)
should be fixed per OSGeo/PROJ#3685 |
…and relax isEquivalentTo() comparisons to deal with case of r-spatial/sf#2049 (comment)
Addison Crump (1): Fuzzer: indicate discarded inputs Alan Snow (1): BUG: Handle prefix whitespace when guessing WKT dialiect Alexander Nehrbass (1): Add Polish geoid model PL-geoid2021 Andrew Annex (1): Adds Pseudo Mercator to build_db_from_iau.py Even Rouault (91): NEWS: move bug fix mention from 9.1.1 to 9.2.0 JSON/WKT: avoid precision issues on non-Intel architectures on coordinate epochs (fixes #3632) test/unit/test_io.cpp: change tests to avoid fp issues on some architectures (fixes #3632) test: proj_create_crs_to_crs_from_pj_force_over(): avoid use of uninitialized memory Database: add explicit casts to make sure all arms of columns selected by views have the same type affinity WKT_ESRI export: do not export NAD83 3D as NAD83(HARN) testvarious: do not output program name / versoin number Database: update to EPSG 10.083 Fix build errors with Cygwin (fixes #3639) Database: update to EPSG 10.084 pj_open_lib_internal(): rework to avoid false positive warnings of Coverity Scan / CSA about nullptr dereference proj_create_operations(): fix documentation related to 3D transformations (fixes #3651) PROJ string CRS parser: make sure that PROJ arguments of the rotated string are kept in the WKT representation (fixes #3654) [Performance regression fix] Fix slowness on proj_trans() on WGS 84 <--> NAD83 conversions .github/workflows/backport.yml: update with a BACKPORT_TOKEN from my (Even Rouault) account that has write permissions [Lint] projinfo: use const reference for for argument (CID 396530) Use ghcr.io/osgeo/proj-docs as Docker hub is sunsetting free organizations (refs OSGeo/gdal#7447) vgridshift/gridshift: accept hydroid_height as valid band description WKT/PROJJSON: import/export accuracy of ConcatenatedOperation Coord. operation factory: count identified concatenated operations as a single step Doc: fix search functionnality Database: add alias for old ESRI datum/CRS names of EPSG:8353 S_JTSK_JTSK03_Krovak_East_North EngineeringCRS: make proj_create_engineering_crs() set a datum name, and relax isEquivalentTo() comparisons to deal with case of r-spatial/sf#2049 (comment) Database: register Hessen HeTA2010 grid (cf OSGeo/PROJ-data#98) Database: update to EPSG 10.085 Database: register grids for New Caledonia (added per OSGeo/PROJ-data#99) createOperations(): tune to get better results in some cases, typically RGNC91-93 to RGNC15 PROJJSON: fix import/export of integer parameter value, and deal with interpolation CRS parameters in conversions (fixes #3689) CMake: avoid imbalanced cmake_policy push/pop if TIFF or CURL dependency cannot be found (fixes #3696) Database: refresh IAU CRS with addition of Pseudo Mercator ones Fix code format C++ API: add a CoordinateTransformer class, and CoordinateOperation::coordinateTransformer() (refs #3593) Doc: remove empty page pj_obs_api_mini_demo.c: remove header comments non-essential IMHO for the beginner and reflecting more historical evolution CMakeLists.txt: distribute examples Add build support for the examples/ programs (disabled by default, unless -D BUILD_EXAMPLES=ON is set) Doc: add a C++ quickstart (fixes #3593) createOperationsVertToVert(): assign an extent DatabaseContext::lookForGridInfo(): deal with special 'null' grid proj_create_crs_to_crs(): restore behaviour of PROJ 9.1 Database: update to EPSG 10.086 Add code comment about likely domain of validity for wintri in +over mode Import from ESRI WKT: remove special case of renaming UPS_North / UPS_South which appears to be undesirable WKT ESRI: recognize Polar_Stereographic_Variant_A method name which is used in the official ESRI formulation of EPSG:5041 and EPSG:5042 Database: update to EPSG 10.087 Fix unreleased regression related to 78d563c97f4920c58a4f04d4a5058df41720fd8c, that caused GDAL's test_gdalwarp_lib_135 test to fail CRS instanciation from PROJ.4 string: set 'Unknown based on XXXX ellipsoid' datum name... cs2cs / proj_create_crs_to_crs(): fix regression with geocentric CRS Doc: proj_create_crs_to_crs_from_pj(): formatting fix proj_trans(): set PROJ_ERR_COORD_TRANSFM_NO_OPERATION error when failing in ONLY_BEST=YES mode Database: update to EPSG 10.088 Add support for EPSG:1102 'Lambert Conic Conformal (1SP variant B)' method, and import related EPSG records tinshift: raise maximum size of JSON file to 100 MB (fixes #3732) Add +R_C as an ellipsoid spherification parameter to use the radius of the conformal sphere Map EPSG:1026 Mercator (Spherical) method to +proj=merc +R_C CMake: remove useless cross-compiling related checks (fixes #3746) omerc: catch invalid value of gamma (when specified without alpha) Merge pull request #3757 from jidanni/patch-8 proj.ini: set default values of parameter to be consistent, and some missing documentation CMake: build fuzzers in standalone mode as part of BUILD_TESTING GeographicBoundingBox::intersection(): avoid infinite recursion and stack overflow on invalid bounding boxes metadata.sql: update PROJ_DATA.VERSION to 1.15 Fix proj-config.cmake to not try including proj4-targets.cmake in INSTALL_LEGACY_CMAKE_FILES=OFF mode omerc.rst: fix example (fixes #3794) Database: update to EPSG v10.091 Equidistant Conic: add mapping to new EPSG:1119 method proj_db_table_defs.sql: add EPSG_1026_Mercator (Spherical) Fix -Wunused-but-set-variable with recent clang in bison generated parsers ConcatenatedOperation::fixStepsDirection(): fix detection of geocentric CRS which wrongly detected geographic 3D CRS too fixStepsDirection(): pass database context Add a way to skip inconsistently defined operations in createFromCoordinateReferenceSystemCodes() and createFromCRSCodesWithIntermediates() factory.cpp: include authority name in exception fixStepsDirection(): enable to define a concatenated operationg ending with a NADCOND (3D) transformation (use case of refs #3819) exportToPROJString(): when a NADCON operation is included in a vertical transformation, do not include axis swap proj_factors(): make it work with projected CRS with non-metre unit and/or northing/easting axis order (fixes #3824) Database: update to EPSG 10.093 Projected CRS identification: fix crash when the base CRS is a non-geographic geodetic CRS (fixes #3828) Doc: fix links to geoapi Avoid C++ exceptions to be thrown (and caught) when parsing strings like '+proj=longlat +datum=WGS84 +type=crs' pj_hgrid_apply_internal(): use pj_log() infrastructure PROJ_DEBUG: make ON an alias of 2, and OFF of 1 (fixes #3832) ConcatenatedOperation::fixStepsDirection(): fix logic error (Coverity CID 416067) CoordinateOperation::targetCoordinateEpoch(): use std::move() to avoid copy (CID 406913) proj_alter_id(): make it replace an existing ID instead of appending a new one Database: update to EPSG 10.094 bonne: fix inverse map projection computations when lat_1 < 0 (fixes #3848) WKT1 ESRI import/export: fix GCS name for EPSG:8353 S-JTSK_[JTSK03]_Krovak_East_North Database: grid_alternatives: reference new HT2 Canadian grids added per OSGeo/PROJ-data#106 Fix false-positive compiler warning JSON export: avoid non-significant decimal digits in version field (fixes #3863) JSON import: reduce number of significant decimal digits when parsing id.version field (fixes #3863, reworks previous commit) Hannes (1): Fix typo "geograpic" -> "geographic" in logging/error output Javier Jimenez Shaw (7): add GEOIDE-Ar16.gri in grid_alternatives.sql as ar_ign_GEOIDE-Ar16.tif Add option in proj CLI to use a CRS (#3825) Use NS_PROJ namespace (fixes #3842, master only) (#3843) Docker: update base image to ubuntu:22.04 [ci skip] Mention derived projected in operations_computation Doc docker: limit sphinxcontrib-spelling version. Breaking changes in v8 Doc docker: remove conflictive dependency awscli Jean-Christophe Malapert (2): Update build_db_from_iau.py Add new projection : Mercator (Spherical) Kristian Evers (11): Update website for 9.2.0 release Bump version numbers in anticipation of 9.3.0 release Add Danish grid files to grid_alternatives Update NEWS for 9.2.1 release Update website for 9.2.1 release Add stale GitHub action, as replacement for old stale GitHub integration Merge pull request #3803 from jidanni/patch-33 Update .github/workflows/stale.yml Update man-pages from Sphinx-docs Update man-pages from Sphinx-docs Update NEWS for 9.3.0 Mike Taves (13): Update clang static analyzer CI and docs for ubuntu-22.04 CI: update ubuntu images, actions/checkout, actions/cache, unique job IDs (#3649) CI: update other actions, use apt-get for scripts CMake: add PROJ_DB_CACHE_DIR CI: upgrade vcpkg tag used for AppVeyor; use --triplet option resolve MSVC warnings C4800 CI: use PROJ_DB_CACHE_DIR (#3717) CI: Clean-up Travis CI scripts and files related to publishing docs Doc/CI: Transition to ReadTheDocs, clean-up previous methods CMake: add /disabled_workflows/ to CPACK_SOURCE_IGNORE_FILES [ci skip] Docs: refactor Python code for sphinx configuration and extensions (#3761) plot.py: rewrite using shapely>=2 (#3811) ReadTheDocs: add htmlzip to offline formats; remove ePub (#3810) Thomas Knudsen (1): Deformation: Make code and comments compatible 積丹尼 Dan Jacobson (5): Simplify eqc.rst example (#3755) Update ellipsoids.rst to mention default Update proj.rst example to modern usage (#3754) omerc.rst: add comparison with spherical tmerc (#3752) Update y_0.rst (#3797) 9.3.0 Release Notes ------------------- Updates ------- o Add C++ API to transform coordinate (#3705) o CMake: add PROJ_DB_CACHE_DIR (#3711) o Implement EPSG:1026 Mercator (Spherical) method (#3741) o CMake: remove useless cross-compiling related checks (#3747) o Add mapping of Equidistant Conic to new EPSG:1119 method (#3812) (NEWS truncated at 15 lines)
This came up here: dieghernan/tidyterra#64 ; Cc @rhijmans
Since GPKG (for good reasons!), and I believe also geoparquet, need to know on writing whether coordinates are ellipsoidal or Cartesian, we do write for objects with
NA
crs the wktLOCAL_CS["Undefined Cartesian SRS"]
. This is returned as such on reading:(if you write nothing, GDAL will assume and write the default
Undefined geographic SRS
).In #1776 the suggestion came up to use
Undefined Cartesian SRS
instead of NA (as this is howsf
andsp
always handled it: NA of course doesn't reveal whether coordinates are geographic or Cartesian, but following a long GIS legacy we handled such data as Cartesian for plotting and area and distance computation, units being implicitly those of the coordinates). Using that definition has the problem thatwhich is obvious: the first has units and axis directions, but this way a that potentially a large number of CRS definitions may come up as valid WKT, be essentially identical but test as different.
So far we've essentially handled two cases: CRS missing, or CRS given and compatible with any other Earth related CRS. Now new cases come up.
The
Undefined Cartesian SRS
breaks plotting with ggplot2, as that checks foris.na(crs)
, which is notTRUE
, and then assumes the crs can be transformed (a graticule is drawn in EPSG:4326 and transformed to the data CRS, but this fails onst_transform()
). Following @rhijmans suggestion, I added a functionst_can_transform()
that checks whether two CRS can be transformed into each other; this is now in sf branchcan_transform
The question is how to go forward: we need to do one of the following:
is.na.crs
such that it returns TRUE onUndefined Cartesian SRS
and similar, replaceNA_crs_
(st_crs(NA)
) withst_crs("Undefined Cartesian SRS")
(more descriptive of what we do, but what counts as similar?)is.na.crs
but release sf withst_can_transform()
, then patch ggplot2 (and potentially other packages) to use it rather than rely onis.na(crs)
.I'm also thinking about transformations on datums of other celestial bodies; PROJ seems to be able to do this; we're r-spatial, not r-geo; st_graticule may have to be generalized in this respect. I think we're heading for the second option.
The text was updated successfully, but these errors were encountered: