CRS¶
pyproj.CRS¶
-
class
pyproj.crs.
CRS
(projparams=None, **kwargs)[source]¶ Bases:
pyproj._crs._CRS
A pythonic Coordinate Reference System manager.
The functionality is based on other fantastic projects:
-
__init__
(projparams=None, **kwargs)[source]¶ Initialize a CRS class instance with a WKT string, a proj,4 string, a proj.4 dictionary, or with proj.4 keyword arguments.
CRS projection control parameters must either be given in a dictionary ‘projparams’ or as keyword arguments. See the proj.4 documentation (https://github.com/OSGeo/proj.4/wiki) for more information about specifying projection parameters.
Example usage:
>>> from pyproj import CRS >>> crs_utm = CRS.from_user_input(26915) >>> crs_utm <CRS: epsg:26915> Name: NAD83 / UTM zone 15N Ellipsoid: - semi_major_metre: 6378137.00 - semi_minor_metre: 6356752.31 - inverse_flattening: 298.26 Area of Use: - name: North America - 96°W to 90°W and NAD83 by country - bounds: (-96.0, 25.61, -90.0, 84.0) Prime Meridian: - longitude: 0.0000 - unit_name: degree - unit_conversion_factor: 0.01745329 Axis Info: - Easting[E] (east) EPSG:9001 (metre) - Northing[N] (north) EPSG:9001 (metre) <BLANKLINE> >>> crs_utm.area_of_use.bounds (-96.0, 25.61, -90.0, 84.0) >>> crs_utm.ellipsoid.inverse_flattening 298.257222101 >>> crs_utm.ellipsoid.semi_major_metre 6378137.0 >>> crs_utm.ellipsoid.semi_minor_metre 6356752.314140356 >>> crs_utm.prime_meridian.unit_name 'degree' >>> crs_utm.prime_meridian.unit_conversion_factor 0.017453292519943295 >>> crs_utm.prime_meridian.longitude 0.0 >>> crs = CRS(proj='utm', zone=10, ellps='WGS84') >>> crs.to_proj4() '+proj=utm +zone=10 +ellps=WGS84 +units=m +no_defs +type=crs' >>> crs.to_wkt() 'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["Unknown based on WGS84 ellipsoid",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1],ID["EPSG",7030]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["UTM zone 10N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",-123,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]],ID["EPSG",16010]],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]]]]' >>> geod = crs.get_geod() >>> "+a={:.0f} +f={:.8f}".format(geod.a, geod.f) '+a=6378137 +f=0.00335281' >>> crs.is_projected True >>> crs.is_geographic False >>> crs.is_valid True
-
area_of_use
¶ returns: AreaOfUse :rtype: The area of use object with associated attributes.
-
axis_info
¶ returns: list[AxisInfo] :rtype: The list of axis information.
-
datum
¶ returns: pyproj.CRS :rtype: The datum as a CRS.
-
ellipsoid
¶ returns: Ellipsoid :rtype: The ellipsoid object with associated attributes.
-
classmethod
from_epsg
(code)[source]¶ Make a CRS from an EPSG code
- Parameters
code (int or str) – An EPSG code. Strings will be converted to integers.
Notes
The input code is not validated against an EPSG database.
- Returns
- Return type
-
classmethod
from_string
(proj_string)[source]¶ Make a CRS from an EPSG, PROJ, or WKT string
- Parameters
proj_string (str) – An EPSG, PROJ, or WKT string.
- Returns
- Return type
-
classmethod
from_user_input
(value)[source]¶ Make a CRS from various input
Dispatches to from_epsg, from_proj, or from_string
- Parameters
value (obj) – A Python int, dict, or str.
- Returns
- Return type
-
is_exact_same
()¶ Compares projections to see if they are exactly the same.
-
is_geocentric
¶ returns: bool :rtype: True if projection in geocentric (x/y) coordinates
-
is_geographic
¶ returns: bool :rtype: True if projection in geographic (lon/lat) coordinates.
-
is_projected
¶ returns: bool :rtype: True if projection is a projected type.
-
is_valid
¶ returns: bool :rtype: True if projection is a valid type.
-
prime_meridian
¶ returns: PrimeMeridian :rtype: The CRS prime meridian object with associated attributes.
-
to_epsg
()¶ Return the EPSG code best matching the projection.
- Parameters
min_confidence (int, optional) – A value between 0-100 where 100 is the most confident. Default is 70.
- Returns
int or None
- Return type
The best matching EPSG code matching the confidence level.
-
to_geodetic
()¶ - Returns
pyproj.CRS
- Return type
The geographic (lat/lon) CRS from the current CRS.
-
to_proj4
()¶ Convert the projection to a proj.4 string.
- Parameters
version (int) – The version of the proj.4 output. Default is 4.
- Returns
str
- Return type
The proj.4 string.
-
to_wkt
()¶ Convert the projection to a WKT string.
- Version options:
WKT2_2015
WKT2_2015_SIMPLIFIED
WKT2_2018
WKT2_2018_SIMPLIFIED
WKT1_GDAL
WKT1_ESRI
- Parameters
version (str) – The version of the WKT output. Default is WKT2_2018.
- Returns
str
- Return type
The WKT string.
-