Skip to content

Comments

Fix NASA Earth data search error#1293

Merged
giswqs merged 1 commit intomasterfrom
nasa
Feb 2, 2026
Merged

Fix NASA Earth data search error#1293
giswqs merged 1 commit intomasterfrom
nasa

Conversation

@giswqs
Copy link
Member

@giswqs giswqs commented Feb 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 2, 2026 02:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts NASA Earthdata granule-to-GeoDataFrame conversion to avoid errors when optional fields are missing in the returned metadata.

Changes:

  • Guarded removal of the Version field to avoid KeyError when absent.
  • Made GeoDataFrame construction conditional on presence of a geometry column (bounding rectangles/polygons).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16111 to +16112
if "Version" in df.columns:
df = df.drop("Version", axis=1)
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

This change adds new edge-case handling (missing "Version" column; missing geometry inputs). There are existing unit tests for leafmap.common (tests/test_common.py), but none cover the NASA Earthdata helpers. Please add tests that validate nasa_data_granules_to_gdf() does not raise when "Version" is absent and that the no-geometry case is handled in a defined way (e.g., raises a specific error or returns a DataFrame).

Copilot uses AI. Check for mistakes.
Comment on lines +16140 to 16144
if "geometry" in df.columns:
gdf = gpd.GeoDataFrame(df, geometry="geometry", crs=crs)
else:
gdf = gpd.GeoDataFrame(df)

Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

When neither "BoundingRectangles" nor "GPolygons" exists, this now returns a GeoDataFrame without an active geometry column (and without CRS). That conflicts with the function’s contract ("Converts … to a GeoDataFrame") and can break callers expecting gdf.geometry/gdf.crs, and to_file() will not be able to write geospatial formats without a geometry column. Consider raising a clear ValueError in this branch (optionally suggesting the required fields), or returning a plain pandas DataFrame / providing a non-geospatial export path when output is set.

Suggested change
if "geometry" in df.columns:
gdf = gpd.GeoDataFrame(df, geometry="geometry", crs=crs)
else:
gdf = gpd.GeoDataFrame(df)
if "geometry" not in df.columns:
raise ValueError(
"Unable to construct a GeoDataFrame from granules: expected either "
"'BoundingRectangles' or 'GPolygons' fields in the input to derive "
"geometry. The resulting table has no 'geometry' column."
)
gdf = gpd.GeoDataFrame(df, geometry="geometry", crs=crs)

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

@github-actions github-actions bot temporarily deployed to pull request February 2, 2026 02:31 Inactive
@giswqs giswqs merged commit 52f9fc7 into master Feb 2, 2026
22 checks passed
@giswqs giswqs deleted the nasa branch February 2, 2026 02:59
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.

1 participant