shareloc.geomodels.rpc

This module contains the RPC class corresponding to the RPC models. RPC models covered are : DIMAP V1, DIMAP V2, DIMAP V3, ossim (geom file), geotiff.

Module Contents

Classes

RPC

RPC class including direct and inverse localization instance methods

Functions

polynomial_equation(xnorm, ynorm, znorm, coeff)

Compute polynomial equation

compute_rational_function_polynomial(lon_col_norm, ...)

Compute rational function polynomial using numba to reduce calculation time on multiple points.

derivative_polynomial_latitude(lon_norm, lat_norm, ...)

Compute latitude derivative polynomial equation

derivative_polynomial_longitude(lon_norm, lat_norm, ...)

Compute longitude derivative polynomial equation

compute_loc_inverse_derivates_numba(lon_norm, ...)

Analytically compute the partials derivatives of inverse localization using numba to reduce calculation time on

class shareloc.geomodels.rpc.RPC(rpc_params)[source]

Bases: shareloc.geomodels.geomodel_template.GeoModelTemplate

RPC class including direct and inverse localization instance methods

classmethod load(geomodel_path)[source]

Load from any RPC (auto identify driver) from filename (dimap, ossim kwl, geotiff)

TODO: topleftconvention always to True, set a standard and remove the option

topleftconvention boolean: [0,0] position

If False : [0,0] is at the center of the Top Left pixel If True : [0,0] is at the top left of the Top Left pixel (OSSIM)

direct_loc_h(row, col, alt, fill_nan=False, using_direct_coef=False)[source]

direct localization at constant altitude

Parameters:
  • row (float or 1D numpy.ndarray dtype=float64) – line sensor position

  • col (float or 1D numpy.ndarray dtype=float64) – column sensor position

  • alt – altitude

  • fill_nan (boolean) – fill numpy.nan values with lon and lat offset if true (same as OTB/OSSIM), nan is returned otherwise

  • using_direct_coef (boolean) – equals True if you want to use direct coefficients

Returns:

ground position (lon,lat,h)

Return type:

numpy.ndarray 2D dimension with (N,3) shape, where N is number of input coordinates

direct_loc_grid_h(row0, col0, steprow, stepcol, nbrow, nbcol, alt)[source]

calculates a direct loc grid (lat, lon) from the direct RPCs at constant altitude TODO: not tested.

Parameters:
  • row0 (int) – grid origin (row)

  • col0 (int) – grid origin (col)

  • steprow (int) – grid step (row)

  • stepcol (int) – grid step (col)

  • nbrow (int) – grid nb row

  • nbcol (int) – grid nb col

  • alt (float) – altitude of the grid

Returns:

direct localization grid longitude and latitude

Return type:

Tuple(numpy.array, numpy.array)

direct_loc_dtm(row, col, dtm)[source]

direct localization on dtm

Parameters:
  • row (float) – line sensor position

  • col (float) – column sensor position

  • dtm (shareloc.geofunctions.dtm_intersection) – dtm intersection model

Returns:

ground position (lon,lat,h) in dtm coordinates system

Return type:

numpy.ndarray 2D dimension with (N,3) shape, where N is number of input coordinates

inverse_loc(lon, lat, alt)[source]

Inverse localization

Parameters:
  • lon (float or 1D numpy.ndarray dtype=float64) – longitude position

  • lat (float or 1D numpy.ndarray dtype=float64) – latitude position

  • alt (float) – altitude

Returns:

sensor position (row, col, alt)

Return type:

tuple(1D np.array row position, 1D np.array col position, 1D np.array alt)

filter_coordinates(first_coord, second_coord, fill_nan=False, direction='direct')[source]

Filter nan input values

Parameters:
  • first_coord (1D numpy.ndarray dtype=float64) – first coordinate

  • second_coord (1D numpy.ndarray dtype=float64) – second coordinate

  • fill_nan (boolean) – fill numpy.nan values with lon and lat offset if true (same as OTB/OSSIM), nan is returned otherwise

  • direction (str in ('direct', 'inverse')) – direct or inverse localisation

Returns:

filtered coordinates

Return type:

list of numpy.array (index of nan, first filtered, second filtered)

compute_loc_inverse_derivates(lon, lat, alt)[source]

Inverse loc partial derivatives analytical compute

Parameters:
  • lon – longitude coordinate

  • lat – latitude coordinate

  • alt – altitude coordinate

Returns:

partials derivatives of inverse localization

Return type:

Tuple(dcol_dlon np.array, dcol_dlat np.array, drow_dlon np.array, drow_dlat np.array)

direct_loc_inverse_iterative(row, col, alt, nb_iter_max=10, fill_nan=False)[source]

Iterative direct localization using inverse RPC

Parameters:
  • row (float or 1D numpy.ndarray dtype=float64) – line sensor position

  • col (float or 1D numpy.ndarray dtype=float64) – column sensor position

  • alt (int) – altitude

  • nb_iter_max – max number of iteration

  • fill_nan (boolean) – fill numpy.nan values with lon and lat offset if true (same as OTB/OSSIM), nan is returned otherwise

Returns:

ground position (lon,lat,h)

Return type:

list of numpy.array

get_alt_min_max()[source]

returns altitudes min and max layers

Returns:

alt_min,lat_max

Return type:

list

get_dtm_alt_offset(corners, dtm)[source]

returns min/max altitude offset between dtm coordinates system and RPC one

Parameters:
  • corners (np.ndarray (4x2)) – corners of the DTM’s footprint

  • dtm (DTMIntersection or bindings_cpp.DTMIntersection) – DTM to get alt offset from

Returns:

min/max altimetric difference between RPC’s epsg minus dtm alti expressed in dtm epsg

Return type:

list of float (1x2)

los_extrema(row, col, alt_min=None, alt_max=None, fill_nan=False, epsg=None)[source]

compute los extrema

Parameters:
  • row (float) – line sensor position

  • col (float) – column sensor position

  • alt_min (float) – los alt min

  • alt_max (float) – los alt max

  • epsg (int) – epsg code of the dtm

Returns:

los extrema

Return type:

numpy.array (2x3)

shareloc.geomodels.rpc.polynomial_equation(xnorm, ynorm, znorm, coeff)[source]

Compute polynomial equation

Parameters:
  • xnorm (float 64) – Normalized longitude (for inverse) or column (for direct) position

  • ynorm (float 64) – Normalized latitude (for inverse) or line (for direct) position

  • znorm (float 64) – Normalized altitude position

  • coeff (1D np.array dtype np.float 64) – coefficients

Returns:

rational

Return type:

float 64

shareloc.geomodels.rpc.compute_rational_function_polynomial(lon_col_norm, lat_row_norm, alt_norm, num_col, den_col, num_lin, den_lin, scale_col, offset_col, scale_lin, offset_lin)[source]

Compute rational function polynomial using numba to reduce calculation time on multiple points. useful to compute direct and inverse localization using direct or inverse RPC.

Parameters:
  • lon_col_norm (1D np.array dtype np.float 64) – Normalized longitude (for inverse) or column (for direct) position

  • lat_row_norm (1D np.array dtype np.float 64) – Normalized latitude (for inverse) or line (for direct) position

  • alt_norm (1D np.array dtype np.float 64) – Normalized altitude position

  • num_col (1D np.array dtype np.float 64) – Column numerator coefficients

  • den_col (1D np.array dtype np.float 64) – Column denominator coefficients

  • num_lin (1D np.array dtype np.float 64) – Line numerator coefficients

  • den_lin (1D np.array dtype np.float 64) – Line denominator coefficients

  • scale_col (float 64) – Column scale

  • offset_col (float 64) – Column offset

  • scale_lin (float 64) – Line scale

  • offset_lin (float 64) – Line offset

Returns:

for inverse localization : sensor position (row, col). for direct localization : ground position (lon, lat)

Return type:

Tuple(np.ndarray, np.ndarray)

shareloc.geomodels.rpc.derivative_polynomial_latitude(lon_norm, lat_norm, alt_norm, coeff)[source]

Compute latitude derivative polynomial equation

Parameters:
  • lon_norm (float 64) – Normalized longitude position

  • lat_norm (float 64) – Normalized latitude position

  • alt_norm (float 64) – Normalized altitude position

  • coeff (1D np.array dtype np.float 64) – coefficients

Returns:

rational derivative

Return type:

float 64

shareloc.geomodels.rpc.derivative_polynomial_longitude(lon_norm, lat_norm, alt_norm, coeff)[source]

Compute longitude derivative polynomial equation

Parameters:
  • lon_norm (float 64) – Normalized longitude position

  • lat_norm (float 64) – Normalized latitude position

  • alt_norm (float 64) – Normalized altitude position

  • coeff (1D np.array dtype np.float 64) – coefficients

Returns:

rational derivative

Return type:

float 64

shareloc.geomodels.rpc.compute_loc_inverse_derivates_numba(lon_norm, lat_norm, alt_norm, num_col, den_col, num_lin, den_lin, scale_col, scale_lon, scale_lin, scale_lat)[source]

Analytically compute the partials derivatives of inverse localization using numba to reduce calculation time on multiple points

Parameters:
  • lon_norm (1D np.array dtype np.float 64) – Normalized longitude position

  • lat_norm (1D np.array dtype np.float 64) – Normalized latitude position

  • alt_norm (1D np.array dtype np.float 64) – Normalized altitude position

  • num_col (1D np.array dtype np.float 64) – Column numerator coefficients

  • den_col (1D np.array dtype np.float 64) – Column denominator coefficients

  • num_lin (1D np.array dtype np.float 64) – Line numerator coefficients

  • den_lin (1D np.array dtype np.float 64) – Line denominator coefficients

  • scale_col (float 64) – Column scale

  • scale_lon (float 64) – Geodetic longitude scale

  • scale_lin (float 64) – Line scale

  • scale_lat (float 64) – Geodetic latitude scale

Returns:

partials derivatives of inverse localization

Return type:

Tuples(dcol_dlon np.array, dcol_dlat np.array, drow_dlon np.array, drow_dlat np.array)