Skip to content

Fix: ensure correct CRS in ee_to_gdf (fixes #2818)#2823

Open
alepr wants to merge 2 commits into
gee-community:masterfrom
alepr:issue_2818
Open

Fix: ensure correct CRS in ee_to_gdf (fixes #2818)#2823
alepr wants to merge 2 commits into
gee-community:masterfrom
alepr:issue_2818

Conversation

@alepr

@alepr alepr commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description of the Issue

The geemap.ee_to_gdf function currently assigns the CRS of the original ee.FeatureCollection directly to the resulting GeoDataFrame using gdf.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:

  1. Explicitly set the CRS of the resulting GeoDataFrame to EPSG:4326 (matching the API output).
  2. Perform a to_crs() transformation to project the data back into the original CRS identified from the ee.FeatureCollection.

Code Changes

# Set the correct initial CRS from the API response
gdf = gdf.set_crs("EPSG:4326")

# Reproject to the original CRS
if crs:
    gdf = gdf.to_crs(crs)

Copilot AI review requested due to automatic review settings July 9, 2026 13:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread geemap/common.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:4326 immediately after ee.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.

Comment thread geemap/common.py
Comment thread geemap/common.py
Comment thread geemap/common.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exporting of geometries to geodataframe with non 4326 CRS results in mismatch

3 participants