eoio.utils.crs_utils module#

eoio.utils.crs_utils - coordinate reference system utility functions

eoio.utils.crs_utils.convert_xy(im_input: list | tuple | ndarray, input_format: str, output_format: str = 'EPSG:4326')[source]#

Convert input coordinates from their coordinate reference system to the World Geodetic System 1984 (WGS 84) or other specified coordinate reference system.

If im_input is a list/1D- array of x and y coordinates instead of a two dimensional coordinate grid, list/array first used to create a two dimensional coordinate grid

Parameters:
  • im_input – list/1D-array of coordinate values, or 2D-coordinate grid

  • input_format – coordinate reference system of input coordinates

  • output_format – desired coordinate reference system (defaults to ‘EPSG:4326’)

Returns:

Tuple of converted x and y coordinates.

eoio.utils.crs_utils.coord_bounds(x_step: int, y_step: int, x_origin: int, y_origin: int, x_len: int, y_len: int, crs: dict) dict[source]#

Return coordinate bounds of the data

Parameters:
  • x_step

  • y_step

  • x_origin

  • y_origin

  • x_len

  • y_len

  • crs – dictionary of crs info of form {“epsg”: str, “crs”: pyproj.CRS()}

Returns:

Dictionary of bounding coordinates in both the image default CRS and EPSG:4326.

eoio.utils.crs_utils.get_nearest_lon_lat_coords(lon_array, lat_array, coords) list[source]#

Return the new roi clipping coordinates for input longitude and latitude grids using nearest neighbour algorithms

(function currently rounds down to the first closest index, so treats values on either edge of the roi differently if consists of duplicated values)

Parameters:
  • lon_array – input longitude array

  • lat_array – input latitude array

  • coords – coordinates in longitude and latitude for which to find the new x, y coordinates for

Returns:

List of coordinates in x and y that satisfy the input.

eoio.utils.crs_utils.get_xy_arrays(x_step, y_step, x_origin, y_origin, x_len, y_len)[source]#

Return x and y arrays given step size, length of array, and point of origin

Parameters:
  • x_step – x step size

  • y_step – y step size

  • x_origin – position of x origin

  • y_origin – position of y origin

  • x_len – number of x points

  • y_len – number of y points

Returns:

Tuple of x and y arrays.

eoio.utils.crs_utils.y_on_line(p1: Tuple[float | int, float | int], p2: Tuple[float | int, float | int], x: float | int) float | int[source]#

Return y on line between two points for a given x

Parameters:
  • p1 – first point on line (x, y)

  • p2 – second point on line (x, y)

  • x – x value of desired output point

Returns:

Y value on the line defined by p1 and p2.