-
-
Notifications
You must be signed in to change notification settings - Fork 464
Fix NASA Earth data search error #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16108,7 +16108,8 @@ def nasa_data_granules_to_gdf( | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| df = pd.json_normalize([dict(i.items()) for i in granules]) | ||||||||||||||||||||||||||
| df.columns = [col.split(".")[-1] for col in df.columns] | ||||||||||||||||||||||||||
| df = df.drop("Version", axis=1) | ||||||||||||||||||||||||||
| if "Version" in df.columns: | ||||||||||||||||||||||||||
| df = df.drop("Version", axis=1) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def get_bbox(rectangles): | ||||||||||||||||||||||||||
| xmin = min(rectangle["WestBoundingCoordinate"] for rectangle in rectangles) | ||||||||||||||||||||||||||
|
|
@@ -16136,9 +16137,10 @@ def get_polygon(coordinates): | |||||||||||||||||||||||||
| elif "GPolygons" in df.columns: | ||||||||||||||||||||||||||
| df["geometry"] = df["GPolygons"].apply(get_polygon) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| gdf = gpd.GeoDataFrame(df, geometry="geometry") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| gdf.crs = crs | ||||||||||||||||||||||||||
| if "geometry" in df.columns: | ||||||||||||||||||||||||||
| gdf = gpd.GeoDataFrame(df, geometry="geometry", crs=crs) | ||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||
| gdf = gpd.GeoDataFrame(df) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+16140
to
16144
|
||||||||||||||||||||||||||
| 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) |
There was a problem hiding this comment.
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 validatenasa_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).