developmentseed/morecantile

`https://www.opengis.net/def/crs/EPSG/0/2193` is not a valid URI

vincentsarago opened this issue · 3 comments

"supportedCRS": "https://www.opengis.net/def/crs/EPSG/0/2193",

from pyproj import CRS
CRS.from_user_input("https://www.opengis.net/def/crs/EPSG/0/2193")
>>> CRSError: Invalid projection: https://www.opengis.net/def/crs/EPSG/0/2193: (Internal Proj Error: proj_create: crs not found)

# Works with rasterio + GDAL 3
import rasterio
rasterio.crs.CRS.from_user_input("https://www.opengis.net/def/crs/EPSG/0/2193")
>>> CRS.from_epsg(2193)


# Fails with GDAL 2 (rasterio==1.1.8)
CRS.from_user_input('https://www.opengis.net/def/crs/EPSG/0/2193')
Traceback (most recent call last):
  File "rasterio/_crs.pyx", line 428, in rasterio._crs._CRS.from_user_input
  File "rasterio/_err.pyx", line 202, in rasterio._err.exc_wrap_ogrerr
rasterio._err.CPLE_BaseError: OGR Error code 5

cc @blacha

FYI we fixed this in #61 by replacing the URI by urn:ogc:def:crs:EPSG:2193.

import rasterio
rasterio.crs.CRS.from_string("urn:ogc:def:crs:EPSG:2193") == rasterio.crs.CRS.from_user_input("https://www.opengis.net/def/crs/EPSG/0/2193")
>>> True

Well it should have been "urn:ogc:def:crs:EPSG::2193" not "urn:ogc:def:crs:EPSG:2193" 🤦

FYI it works with rasterio but not with pyproj

import pyproj
import rasterio

rasterio.crs.CRS.from_string("urn:ogc:def:crs:EPSG:2193")
>>> CRS.from_epsg(2193)

pyproj.CRS.from_user_input("urn:ogc:def:crs:EPSG:2193")
>>> CRSError: Invalid projection: urn:ogc:def:crs:EPSG:2193: (Internal Proj Error: proj_create: unrecognized format / unknown name)

rasterio.crs.CRS.from_string("urn:ogc:def:crs:EPSG::2193")
>>> CRS.from_epsg(2193)

pyproj.CRS.from_user_input("urn:ogc:def:crs:EPSG::2193")
>>>
<Projected CRS: EPSG:2193>
Name: NZGD2000 / New Zealand Transverse Mercator 2000
Axis Info [cartesian]:
- N[north]: Northing (metre)
- E[east]: Easting (metre)
Area of Use:
- name: New Zealand - North Island, South Island, Stewart Island - onshore.
- bounds: (166.37, -47.33, 178.63, -34.1)
Coordinate Operation:
- name: New Zealand Transverse Mercator 2000
- method: Transverse Mercator
Datum: New Zealand Geodetic Datum 2000
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

Interesting, so GDAL only added support for https uris in 3.0, we do not use much (any?) gdal v2 any more so havent noticed this issue.

We took these from the OGC doc https://docs.opengeospatial.org/is/17-083r2/17-083r2.html when we imported the WebMercatorQuad TMS, then when making this TMS we just used that standard.