s2d2.image_coordinate_tools

Module Contents

Functions

pix2map(geotransform, i, j)

transform local image coordinates to map coordinates

map2pix(geotransform, x, y)

transform map coordinates to local image coordinates

pix_centers(geotransform[, rows, cols, make_grid])

provide the pixel coordinate from the axis, or the whole grid

get_bbox(geotransform[, rows, cols])

given array meta data, calculate the bounding box

create_local_crs()

create spatial refence of local horizontal datum

s2d2.image_coordinate_tools.pix2map(geotransform, i, j)[source]

transform local image coordinates to map coordinates

Parameters:
  • geotransform (tuple, size={(6,1), (8,1)}) – georeference transform of an image.

  • i (np.array, ndim={1,2,3}, dtype=float) – row coordinate(s) in local image space

  • j (np.array, ndim={1,2,3}, dtype=float) – column coordinate(s) in local image space

Returns:

  • x (np.array, size=(m), ndim={1,2,3}, dtype=float) – horizontal map coordinate.

  • y (np.array, size=(m), ndim={1,2,3}, dtype=float) – vertical map coordinate.

See also

map2pix

Notes

Two different coordinate system are used here:

indexing   |           indexing    ^ y
system 'ij'|           system 'xy' |
           |                       |
           |       i               |       x
   --------+-------->      --------+-------->
           |                       |
           |                       |
image      | j         map         |
based      v           based       |
s2d2.image_coordinate_tools.map2pix(geotransform, x, y)[source]

transform map coordinates to local image coordinates

Parameters:
  • geotransform (tuple, size=(6,1)) – georeference transform of an image.

  • x (np.array, size=(m), ndim={1,2,3}, dtype=float) – horizontal map coordinate.

  • y (np.array, size=(m), ndim={1,2,3}, dtype=float) – vertical map coordinate.

Returns:

  • i (np.ndarray, ndim={1,2,3}, dtype=float) – row coordinate(s) in local image space

  • j (np.ndarray, ndim={1,2,3}, dtype=float) – column coordinate(s) in local image space

See also

pix2map

Notes

Two different coordinate system are used here:

indexing   |           indexing    ^ y
system 'ij'|           system 'xy' |
           |                       |
           |       i               |       x
   --------+-------->      --------+-------->
           |                       |
           |                       |
image      | j         map         |
based      v           based       |
s2d2.image_coordinate_tools.pix_centers(geotransform, rows=None, cols=None, make_grid=True)[source]

provide the pixel coordinate from the axis, or the whole grid

Parameters:
  • geotransform (tuple, size={(6,), (8,)}) – georeference transform of an image.

  • rows (integer, {x ∈ ℕ | x ≥ 0}, default=None) – amount of rows in an image.

  • cols (integer, {x ∈ ℕ | x ≥ 0}, default=None) – amount of collumns in an image.

  • make_grid (bool, optional) – Should a grid be made. The default is True.

Returns:

  • X (np.ndarray, dtype=float) –

    • “make_grid” : size=(m,n)

    • otherwise : size=(1,n)

  • Y (np.ndarray, dtype=float) –

    • “make_grid” : size=(m,n)

    • otherwise : size=(m,1)

See also

map2pix, pix2map

Notes

Two different coordinate system are used here:

indexing   |           indexing    ^ y
system 'ij'|           system 'xy' |
           |                       |
           |       j               |       x
   --------+-------->      --------+-------->
           |                       |
           |                       |
image      | i         map         |
based      v           based       |
s2d2.image_coordinate_tools.get_bbox(geotransform, rows=None, cols=None)[source]

given array meta data, calculate the bounding box

Parameters:
  • geotransform (tuple, size=(6,)) – georeference transform of an image.

  • rows (integer, {x ∈ ℕ | x ≥ 0}) – amount of rows in an image.

  • cols (integer, {x ∈ ℕ | x ≥ 0}) – amount of collumns in an image.

Returns:

bbox – bounding box, in the following order: min max X, min max Y

Return type:

np.ndarray, size=(4,), dtype=float

Notes

Two different coordinate system are used here:

indexing   |           indexing    ^ y
system 'ij'|           system 'xy' |
           |                       |
           |       i               |       x
   --------+-------->      --------+-------->
           |                       |
           |                       |
image      | j         map         |
based      v           based       |
s2d2.image_coordinate_tools.create_local_crs()[source]

create spatial refence of local horizontal datum

Returns:

crs – the coordinate reference system via GDAL SpatialReference description

Return type:

{osr.SpatialReference, string}