dataria.GEO¶
SPARQL-based geospatial data processing and interactive mapping.
This module provides functions to: - Convert SPARQL query results into GeoDataFrames, - Serialize them as GeoJSON, - Generate interactive maps using GeoPandas’ .explore() (via folium).
Functions¶
|
Convert a Pandas DataFrame into a GeoPandas GeoDataFrame using a geometry column. |
|
Generate an interactive map from SPARQL query results or GeoDataFrames. |
Module Contents¶
- dataria.GEO.dataframe_to_geodataframe(df, geo_var, json_filename='result_explore.geojson')¶
Convert a Pandas DataFrame into a GeoPandas GeoDataFrame using a geometry column.
This function extracts a geometry column from the input DataFrame, converts it into a spatial GeoDataFrame, and optionally saves the result as a GeoJSON file.
- Parameters:
df (pd.DataFrame) – Input DataFrame containing geometry data.
geo_var (str) – Name of the column with Shapely geometry objects.
json_filename (str, optional) – Path to save the resulting GeoJSON file.
- Returns:
A spatially enabled GeoDataFrame with WGS84 coordinates.
- Return type:
gpd.GeoDataFrame
- Raises:
ValueError – If the geometry column is missing or empty.
- dataria.GEO.explore(df=None, gdf=None, endpoint_url=None, query=None, geo_var='geom', cluster_weight_var='cluster', csv_filename='query_geodata.csv', json_filename='result_explore.geojson', html_filename='result_map.html', **explore_kwargs)¶
Generate an interactive map from SPARQL query results or GeoDataFrames.
This function fetches data via SPARQL (if needed), transforms it into a GeoDataFrame, and visualizes the result as an interactive Leaflet map using GeoPandas’ .explore() method. Results can be exported as CSV, GeoJSON, and HTML files.
- Parameters:
df (pd.DataFrame, optional) – Input DataFrame. Ignored if gdf is provided.
gdf (gpd.GeoDataFrame, optional) – Input GeoDataFrame. Takes precedence over df.
endpoint_url (str, optional) – SPARQL endpoint to query.
query (str, optional) – SPARQL query string.
geo_var (str) – Column name containing geometry data (default: ‘geom’).
cluster_weight_var (str) – Optional column used to color the map.
csv_filename (str) – Optional file path to export query results as CSV.
json_filename (str) – Optional file path to save the data as GeoJSON.
html_filename (str) – Optional file path to save the interactive map as HTML.
**explore_kwargs – Additional keyword arguments for GeoDataFrame.explore().
- Returns:
An interactive map object rendered with folium.
- Return type:
folium.Map
- Raises:
ValueError – If required inputs are missing or data transformation fails.