Skip to content

As a data user, I want to export query results as GeoJSONΒ #154

Description

@jordanpadams

Checked for duplicates

Yes - I've already checked

πŸ§‘β€πŸ”¬ User Persona(s)

Data User, GIS Analyst, Web Developer, Data Visualization Engineer

πŸ’ͺ Motivation

...so that I can visualize product footprints and metadata on web maps using tools like Leaflet, Mapbox, QGIS, and other GIS platforms.

πŸ“– Additional Details

Current Behavior:

  • βœ… as_dataframe() exports to pandas DataFrame
  • ❌ No GeoJSON export capability
  • ❌ Users must manually extract spatial fields and construct GeoJSON

Proposed Solution:
Export results as valid GeoJSON with spatial geometries:

# Export with spatial field configuration
geojson = products.has_target("Mars").observationals().as_geojson(
    lat_field="orex:Spatial.orex:latitude",
    lon_field="orex:Spatial.orex:longitude",
    output_file="mars_data.geojson"
)

# Support different geometry types
products.as_geojson(
    geometry_type="bbox",
    lat_min_field="geom:bbox.lat_min",
    lat_max_field="geom:bbox.lat_max",
    lon_min_field="geom:bbox.lon_min",
    lon_max_field="geom:bbox.lon_max"
)

# Select specific properties to include
products.as_geojson(
    lat_field="orex:Spatial.orex:latitude",
    lon_field="orex:Spatial.orex:longitude",
    properties=["pds:Identification_Area.pds:title", "lidvid"]
)

GeoJSON Output Structure:

{
  "type": "FeatureCollection",
  "features": [{
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [-122.5, 37.8]
    },
    "properties": {
      "lidvid": "urn:nasa:pds:...:1.0",
      "title": "Mars Image",
      "start_date_time": "2020-01-01T00:00:00Z"
    },
    "id": "urn:nasa:pds:...:1.0"
  }]
}

Implementation Approach:

  1. Add as_geojson() method to QueryBuilder
  2. Support Point, BBox/Polygon geometry types
  3. Configurable property selection
  4. Handle missing/invalid spatial data gracefully
  5. Use standard library json (no new dependencies)

Related:


For Internal Dev Team To Complete

Acceptance Criteria

Given a user wants to visualize PDS products on a web map
When I perform products.as_geojson(lat_field="...", lon_field="...")
Then I expect a valid GeoJSON FeatureCollection with product metadata and geometries

βš™οΈ Engineering Details

To be filled by Engineering Node Team

πŸŽ‰ I&T

To be filled by Engineering Node Team

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
ToDo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions