Skip to content

Commit

Permalink
changed centroid calculation to use web_mercator
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVerhaert committed Dec 24, 2024
1 parent 23248c2 commit 0839394
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/openeo_gfmap/manager/job_splitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,18 @@ def split_job_s2sphere(

if gdf.crs is None:
raise ValueError("The GeoDataFrame must contain a CRS")

# Store the original CRS of the GeoDataFrame and reproject to EPSG:3857
original_crs = gdf.crs
gdf = gdf.to_crs(epsg=3857)

# Add a centroid column to the GeoDataFrame and convert it to EPSG:4326
gdf["centroid"] = gdf.geometry.centroid

# Reproject the GeoDataFrame to its orginial CRS
gdf = gdf.to_crs(original_crs)

# Set the GeoDataFrame's geometry to the centroid column and reproject to EPSG:4326
gdf = gdf.set_geometry("centroid")
gdf = gdf.to_crs(epsg=4326)

Expand Down

0 comments on commit 0839394

Please sign in to comment.