PyCRS
PyCRS copied to clipboard
CRS equality operator
Can PyCRS pass this test?
import rasterio
import pycrs
def test_pycrs_parses_ogc_wkt():
# data from https://spatialreference.org/ref/epsg/4326/
epsg_4326_to_ogc_wkt = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
rasterio_ogc_wkt = rasterio.crs.CRS.from_string('EPSG:4326').to_wkt(morph_to_esri_dialect=False)
epsg_4326_ogc_crs = pycrs.parse.from_ogc_wkt(epsg_4326_to_ogc_wkt)
rasterio_ogc_crs = pycrs.parse.from_ogc_wkt(rasterio_ogc_wkt)
assert rasterio_ogc_crs == epsg_4326_ogc_crs
The aim of this test is to check for the equality of some CRS regardless of what tools have serialized the CRS, assuming that it should be an OGC WKT serialization.
Good point, I've thought about adding this as well. What I've done so far is just outputting to a common string representation and comparing those.
A better way would perhaps be to only compare those parameters that actually impact the projection, ie ignoring several of the naming parameters that are solely for human readability. I'll look into adding this functionality at some point, though not sure when, as I would have to think through which parameters to compare/ignore. If you have time for a PR that would probably be faster.
I see you've written multiple unittests that compares to rasterio. Currently PyCRS lacks unittests, but would happily add your unittests if you write it as a PR.