Fix: ensure correct CRS in ee_to_gdf (fixes #2818)#2823
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ee_to_gdf function in geemap/common.py to explicitly set the initial CRS of the GeoDataFrame to 'EPSG:4326' and then reproject it to the target CRS if one is provided. The review feedback suggests optimizing this process by checking if the target CRS is already 'EPSG:4326' to avoid redundant reprojection overhead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR fixes a CRS labeling mismatch in geemap.ee_to_gdf by aligning the GeoDataFrame’s initial CRS with the Earth Engine computeFeatures output (WGS84 / EPSG:4326) and then reprojecting back to the source FeatureCollection’s CRS.
Changes:
- Set the GeoDataFrame CRS to
EPSG:4326immediately afteree.data.computeFeatures. - Reproject the GeoDataFrame back to the original FeatureCollection CRS via
to_crs().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description of the Issue
The
geemap.ee_to_gdffunction currently assigns the CRS of the originalee.FeatureCollectiondirectly to the resulting GeoDataFrame usinggdf.crs = crs.However, as indicated in the documentation for
ee.data.computeFeatures, the method automatically reprojects all geometries to EPSG:4326 upon conversion. This creates a CRS mismatch where the GeoDataFrame is labeled with the original CRS (e.g., EPSG:32636) while the coordinates are actually in WGS84 (EPSG:4326).Fixes #2818
Proposed Solution
To ensure the GeoDataFrame correctly matches the expected coordinate system, I have updated the function to:
EPSG:4326(matching the API output).to_crs()transformation to project the data back into the original CRS identified from theee.FeatureCollection.Code Changes