geoutils.projtools

GeoUtils.projtools provides a toolset for dealing with different coordinate reference systems (CRS).

Functions

bounds2poly

geoutils.projtools.bounds2poly(boundsGeom, in_crs=None, out_crs=None)[source]

Converts self’s bounds into a shapely Polygon. Optionally, returns it into a different CRS.

Parameters
  • boundsGeom – A geometry with bounds. Can be either a list of coordinates (xmin, ymin, xmax, ymax), a rasterio/Raster object, a geoPandas/Vector object

  • in_crs – Input CRS

  • out_crs – Output CRS

Returns

Output polygon

compare_proj

geoutils.projtools.compare_proj(proj1, proj2)[source]

Compare two projections to see if they are the same, using pyproj.CRS.is_exact_same.

Parameters
  • proj1 (CRS) – The first projection to compare.

  • proj2 (CRS) – The first projection to compare.

Return type

bool

Returns

True if the two projections are the same.

merge_bounds

geoutils.projtools.merge_bounds(bounds_list, merging_algorithm='union')[source]

Merge a list of bounds into single bounds, using either the union or intersection.

Parameters
  • bounds_list – A list of geometries with bounds, i.e. a list of coordinates (xmin, ymin, xmax, ymax), a rasterio/Raster object, a geoPandas/Vector object.

  • merging_algorithm – the algorithm to use for merging, either “union” or “intersection”

Returns

Output bounds (xmin, ymin, xmax, ymax)

reproject_from_latlon

geoutils.projtools.reproject_from_latlon(pts, out_crs, round_=2)[source]

Reproject a set of point from lat/lon to out_crs.

Parameters
  • pts – Input points to be reprojected. Must be of shape (2, N), i.e (x coords, y coords)

  • out_crs – Output CRS

  • round – Output rounding. Default of 2 ensures cm accuracy

Returns

Reprojected points, of same shape as pts.

reproject_points

geoutils.projtools.reproject_points(pts, in_crs, out_crs)[source]

Reproject a set of point from input_crs to output_crs.

Parameters
  • pts – Input points to be reprojected. Must be of shape (2, N), i.e (x coords, y coords)

  • in_crs – Input CRS

  • out_crs – Output CRS

Returns

Reprojected points, of same shape as pts.

reproject_shape

geoutils.projtools.reproject_shape(inshape, in_crs, out_crs)[source]

Reproject a shapely geometry from one CRS into another CRS.

Parameters
  • inshape (BaseGeometry) – Shapely geometry to be reprojected.

  • in_crs (CRS) – Input CRS

  • out_crs (CRS) – Output CRS

Return type

BaseGeometry

Returns

Reprojected geometry

reproject_to_latlon

geoutils.projtools.reproject_to_latlon(pts, in_crs, round_=8)[source]

Reproject a set of point from in_crs to lat/lon.

Parameters
  • pts – Input points to be reprojected. Must be of shape (2, N), i.e (x coords, y coords)

  • in_crs – Input CRS

  • round – Output rounding. Default of 8 ensures cm accuracy

Returns

Reprojected points, of same shape as pts.