def __init__(self, name, datum, vertical_cs=VerticalCS(), geoid_model=None): """ Parameters ---------- name: str The name of the Vertical CRS (e.g. NAVD88 height). datum: Any Anything accepted by :meth:`pyproj.crs.Datum.from_user_input` vertical_cs: Any, optional Input to create a Vertical Coordinate System accepted by :meth:`pyproj.crs.CoordinateSystem.from_user_input` or :class:`pyproj.crs.coordinate_system.VerticalCS` geoid_model: str, optional The name of the GEOID Model (e.g. GEOID12B). """ vert_crs_json = { "$schema": "https://proj.org/schemas/v0.2/projjson.schema.json", "type": "VerticalCRS", "name": name, "datum": Datum.from_user_input(datum).to_json_dict(), "coordinate_system": CoordinateSystem.from_user_input(vertical_cs).to_json_dict(), } if geoid_model is not None: vert_crs_json["geoid_model"] = {"name": geoid_model} super().__init__(vert_crs_json)
def __init__( self, name: str = "undefined", datum: Any = "urn:ogc:def:datum:EPSG::6326", ellipsoidal_cs: Any = None, ) -> None: """ Parameters ---------- name: str, optional Name of the CRS. Default is undefined. datum: Any, optional Anything accepted by :meth:`pyproj.crs.Datum.from_user_input` or a :class:`pyproj.crs.datum.CustomDatum`. ellipsoidal_cs: Any, optional Input to create an Ellipsoidal Coordinate System. Anything accepted by :meth:`pyproj.crs.CoordinateSystem.from_user_input` or an Ellipsoidal Coordinate System created from :ref:`coordinate_system`. """ geographic_crs_json = { "$schema": "https://proj.org/schemas/v0.2/projjson.schema.json", "type": "GeographicCRS", "name": name, "datum": Datum.from_user_input(datum).to_json_dict(), "coordinate_system": CoordinateSystem.from_user_input( ellipsoidal_cs or Ellipsoidal2DCS()).to_json_dict(), } super().__init__(geographic_crs_json)
def _horizontal_datum_from_params(cf_params): # step 1: build ellipsoid ellipsoid = None ellipsoid_name = cf_params.get("reference_ellipsoid_name") try: ellipsoid = CustomEllipsoid( name=ellipsoid_name or "undefined", semi_major_axis=cf_params.get("semi_major_axis"), semi_minor_axis=cf_params.get("semi_minor_axis"), inverse_flattening=cf_params.get("inverse_flattening"), radius=cf_params.get("earth_radius"), ) except CRSError: if ellipsoid_name: ellipsoid = Ellipsoid.from_name(ellipsoid_name) # step 2: build prime meridian prime_meridian = None prime_meridian_name = cf_params.get("prime_meridian_name") try: prime_meridian = CustomPrimeMeridian( name=prime_meridian_name or "undefined", longitude=cf_params["longitude_of_prime_meridian"], ) except KeyError: if prime_meridian_name: prime_meridian = PrimeMeridian.from_name(prime_meridian_name) # step 3: build datum datum_name = cf_params.get("horizontal_datum_name") if ellipsoid or prime_meridian: return CustomDatum( name=datum_name or "undefined", ellipsoid=ellipsoid or "WGS 84", prime_meridian=prime_meridian or "Greenwich", ) if datum_name: return Datum.from_name(datum_name) return None