hydrodata.data_catalog.projection module

Convert lat/lng (EPSG:4326) to to Lambert Confirmal Conic (ESRI:102004) for conus 1.

Do this using the projection constants of the coordinate systems obtained from the python pyproj package. This module is a custom implementation of lat/lng to conic transformation that is 35x faster than the pyproj.Transform class. The speed improvement is because the code is not generic and can be compiled instead interpreting all the possible coordinates types supported by pyproj. Since the algorithm and conversion constants are the same as pyproj the answer is the same for conus1. For conus2 the conversion constants are different.

The unit tests compares the answer with pyproj to verify that the two functions produce the same answer within 0.001 meters.

Inspiration (not code) taken from:

https://github.com/vraida/Lambert-projection https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection

hydrodata.data_catalog.projection.CONUS1_PROJ_CONSTANTS = <hydrodata.data_catalog.projection.ProjConstants object>

Global singleton instance of CONUS1 ProjContants

hydrodata.data_catalog.projection.CONUS2_PROJ_CONSTANTS = <hydrodata.data_catalog.projection.ProjConstants object>

Global singleton instance of CONUS2 ProjContants

class hydrodata.data_catalog.projection.ProjConstants(grid: str)

Bases: object

Constants from the pyproj package used for the EPSG:4326 to ESRI:102004 transformation.

calculate_m(x: float) float

Return the M value associated with the x radians values as required by the algorithm.

calculate_t(x)

Return the T value associated with the x radians values as required by the algorithm.

un_calculate_t(t)

Return the x value given t where x=calculate_t(x) using numerical iteration method.

hydrodata.data_catalog.projection.from_conic(x: float, y: float, grid='conus1') List[float]

Convert conic x,y point to lat/lng point. :param lat: x position in meters in conic flat coordinates :param lng: y position in meters in conic flat coordinates

Returns:

4326 coordinates.

Return type:

A tuple (lat, lng) as a float in degrees in EPSG

hydrodata.data_catalog.projection.to_conic(lat: float, lng: float, grid='conus1') List[float]

Convert lat/lng point to conic x,y point. :param lat: Latitude in degrees. :param lng: Longitude in degress.

Returns:

A tuple (x, y) as a float in flat projected conic coordinates in meters.