dataria.GEO =========== .. py:module:: dataria.GEO .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: dataria.GEO.dataframe_to_geodataframe dataria.GEO.explore Module Contents --------------- .. py:function:: 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. :param df: Input DataFrame containing geometry data. :type df: pd.DataFrame :param geo_var: Name of the column with Shapely geometry objects. :type geo_var: str :param json_filename: Path to save the resulting GeoJSON file. :type json_filename: str, optional :returns: A spatially enabled GeoDataFrame with WGS84 coordinates. :rtype: gpd.GeoDataFrame :raises ValueError: If the geometry column is missing or empty. .. py:function:: 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. :param df: Input DataFrame. Ignored if `gdf` is provided. :type df: pd.DataFrame, optional :param gdf: Input GeoDataFrame. Takes precedence over `df`. :type gdf: gpd.GeoDataFrame, optional :param endpoint_url: SPARQL endpoint to query. :type endpoint_url: str, optional :param query: SPARQL query string. :type query: str, optional :param geo_var: Column name containing geometry data (default: 'geom'). :type geo_var: str :param cluster_weight_var: Optional column used to color the map. :type cluster_weight_var: str :param csv_filename: Optional file path to export query results as CSV. :type csv_filename: str :param json_filename: Optional file path to save the data as GeoJSON. :type json_filename: str :param html_filename: Optional file path to save the interactive map as HTML. :type html_filename: str :param \*\*explore_kwargs: Additional keyword arguments for `GeoDataFrame.explore()`. :returns: An interactive map object rendered with folium. :rtype: folium.Map :raises ValueError: If required inputs are missing or data transformation fails.