Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions geemap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8947,7 +8947,10 @@ def ee_to_gdf(

kwargs["expression"] = ee_object
kwargs["fileFormat"] = "GEOPANDAS_GEODATAFRAME"

# Get the source CRS to ensure we can reproject back to it later
# This is important because ee.data.computeFeatures will return a GeoDataFrame
# reprojected to EPSG:4326, Docs in
# https://developers.google.com/earth-engine/apidocs/ee-data-computefeatures
crs = ee_object.first().geometry().projection().crs().getInfo()
gdf = ee.data.computeFeatures(kwargs)

Expand All @@ -8956,8 +8959,13 @@ def ee_to_gdf(

if sort_columns:
gdf = gdf.reindex(sorted(gdf.columns), axis=1)
# Standardize CRS: Set as 4326 initially as a base, then reproject
# to the original geometry's CRS if it differs from 4326.
gdf = gdf.set_crs("EPSG:4326")

if crs and crs.upper() != "EPSG:4326":
gdf = gdf.to_crs(crs)

Comment thread
alepr marked this conversation as resolved.
gdf.crs = crs
return gdf


Expand Down