Closed xycarto closed 1 year ago
The EPSG code is for a Projected CRS
:
>>> from pyproj import CRS
>>> crs = CRS("EPSG:2193")
>>> crs
<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
>>> crs.to_proj4()
'+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +units=m +no_defs +type=crs'
When you add the towsg84
the type of CRS is a Bound CRS
:
>>> from pyproj import CRS
>>> proj4 = "+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
>>> crs = CRS(proj4)
>>> crs
<Bound CRS: +proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=160 ...>
Name: unknown
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- undefined
Coordinate Operation:
- name: Transformation from unknown to WGS84
- method: Position Vector transformation (geog2D domain)
Datum: Unknown based on GRS80 ellipsoid using towgs84=0,0,0,0,0,0,0
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich
Source CRS: unknown
To get the EPSG code of the projected CRS, you use the source_crs
attribute (see to_epsg docstring):
>>> crs = CRS(proj4)
>>> crs.source_crs.list_authority(min_confidence=0)
[AuthorityMatchInfo(auth_name='EPSG', code='2193', confidence=50)]
>>> crs.source_crs.to_epsg(min_confidence=50)
2193
Thank you for the very clear explanation. Very helpful! Implemented into my process
Pyproj returns
None
whentowgs
existsCode Sample, a copy-pastable example if possible
Returns
None
Problem description
Ideally this should return
2193
.This appears to be common proj4 string for 'epsg:2193`.
I suspect this is an issue with the addition of the
+towgs84=0,0,0,0,0,0,0
in the proj4 and not an issue specific toepsg:2193
Normally, I would not rely on the proj4 string for operations, however, in my use case, I am forced to use it
Expected Output
Environment Information
Installation method
Also tried: