Commit f056be07 authored by Nicolas Garcia Ospina's avatar Nicolas Garcia Ospina
Browse files

Improved Albers projection readability

parent a2771370
Pipeline #23021 passed with stage
in 4 minutes and 8 seconds
......@@ -153,22 +153,25 @@ class TileProcessor:
def reproject_polygon(input_polygon, input_crs, target_crs):
"""
Returns a (multi)polygon object transformed from input_crs to target_crs. if
"aea" is specified as target crs, returns the Albers equal area transformed
"albers" is specified as target crs, returns the Albers equal area transformed
polygon.
More information on the Albers equal area can be found at:
https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/albers.htm
Args:
input_polygon (shapely.geometry.polygon.Polygon): Polygon object to reproject.
input_crs (str): Initial crs of the input_polygon (e.g. "epsg:4326").
target_crs (str): Target crs for the final polygon object. If "aea" is
target_crs (str): Target crs for the final polygon object. If "albers" is
specified, process the complete Albers equal area transformation.
Returns:
geometry (shapely.geometry.polygon.Polygon): Polygon object reprojected to
target_crs.
"""
if target_crs == "aea":
if target_crs == "albers":
project = pyproj.Transformer.from_proj(
pyproj.Proj(input_crs),
pyproj.Proj("epsg:4326"),
......@@ -182,12 +185,12 @@ class TileProcessor:
miny, maxy = sorted([bbox[1], bbox[3]])
# Use the resulting coordinates to perform the transformation
project_aea = pyproj.Proj(
project_albers = pyproj.Proj(
"+proj=aea +lat_1={} +lat_2={} +lat_0={} +lon_0={}".format(
miny, maxy, (miny + maxy) / 2.0, (minx + maxx) / 2.0
)
)
geometry = transform(project_aea, input_polygon)
geometry = transform(project_albers, input_polygon)
else:
project = pyproj.Transformer.from_proj(
......@@ -264,7 +267,7 @@ class TileProcessor:
Albers equal area system.
"""
polygon = TileProcessor.reproject_polygon(input_polygon, polygon_crs, "aea")
polygon = TileProcessor.reproject_polygon(input_polygon, polygon_crs, "albers")
return polygon.area
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment