-
Notifications
You must be signed in to change notification settings - Fork 658
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Goal
Add built-in support for reading, transforming, and displaying geospatial data via the geopandas library, making it easier to build map-based dashboards and spatial analytics apps with Preswald.
📌 Motivation
Preswald users are increasingly working with geospatial datasets—such as shapefiles, GeoJSON, and spatial CSVs—but currently must manually transform and flatten geometry fields before displaying them.
By natively integrating with geopandas, Preswald can:
- Seamlessly support geospatial file formats
- Simplify loading and preprocessing of spatial data
- Prepare data for use with upcoming
geo()component or Plotly maps - Unlock use cases in real estate, environment, logistics, and more
✅ Acceptance Criteria
- Add
geopandasas a supported backend dependency (pip install geopandas) - Automatically use
geopandas.read_file()when:type = "geojson"ortype = "shapefile"inpreswald.toml
- Handle loading of:
.geojson,.shp,.gpkg
- Convert
GeoDataFrameto a regular DataFrame with flattenedgeometry(WKT or GeoJSON format) - Add
flatten_geometry = true|falsetoggle in data config - Ensure compatibility with
get_df()and downstream components (table(),plotly(), etc.) - Raise informative errors if
geopandasis missing or file path is invalid
🛠 Implementation Plan
1. Update Data Loader in data.py
import geopandas as gpd
def load_geospatial_source(config):
df = gpd.read_file(config["path"])
if config.get("flatten_geometry", True):
df["geometry"] = df["geometry"].apply(lambda g: g.__geo_interface__)
return dfDetect .geojson, .shp, .gpkg, or type = "geojson" in preswald.toml.
2. Example preswald.toml
[data.city_boundaries]
type = "geojson"
path = "data/cities.geojson"
flatten_geometry = true🧪 Testing Plan
- Load sample
.geojsonand.shpfiles - Confirm
connect()andget_df()return valid DataFrame - Use
table(df)andplotly()to inspect spatial columns - Test behavior with and without
flatten_geometry
📚 Docs To Update
-
docs/configuration.mdx→ Addtype = "geojson"/shapefile+flatten_geometry -
docs/sdk/geo.mdx(future) → Add examples usinggeometrycolumn - Add note about installing
geopandasvia extras:pip install preswald[geo]
🧩 Related Files
preswald/engine/managers/data.pypreswald.toml- Optional sample:
examples/earthquakes.geojson
🔮 Future Enhancements
- Detect and reproject coordinates (
.to_crs()) - Add spatial filter DSL (
where geometry intersects...) - Integrate with
geo()map-rendering component - Support live streaming geospatial data
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request