Ai/automazione Best Repository

GeoLibre Python: Interactive Geospatial Maps

GeoLibre Python: Interactive Geospatial Maps

GeoLibre is a Python library that enables rapid creation of interactive web applications for geospatial data visualization and analysis. It combines the power of Streamlit with established GIS libraries like Geopandas and Rasterio.

GeoLibre Key Features

Feature Description Operational Benefits
:——————- :—————————————————————————- :——————————————————————————–
Vector Visualization Loads and displays points, lines, polygons from Geopandas DataFrames. Rapid mapping of boundaries, routes, points of interest.
Raster Visualization Supports georeferenced images (e.g., satellite, DEM) with Rasterio. Land analysis, environmental monitoring, elevation models.
Interactive Maps Based on Folium/Leaflet, with zoom, pan, configurable tooltips and popups. Intuitive data exploration, quick identification of details.
Streamlit Dashboard Transforms Python scripts into interactive web apps with widgets. Easy sharing with non-technical users, rapid prototyping of GIS solutions.
Layer Control Manages layer visibility (on/off) directly from the UI. Immediate comparison between different datasets on the same map.

GeoLibre emerged from the need to democratize access and visualization of geospatial data, often confined to complex and expensive desktop software. In an organization with 2,000 endpoints and hundreds of VMs, the ability to quickly analyze the geographical distribution of assets, incidents, or resources can significantly reduce response times and improve planning. Imagine needing to visualize the density of security alerts on a map to identify geographical hot-spots, or the distribution of IoT sensors. GeoLibre offers an agile solution, leveraging the Python ecosystem already familiar to many data scientists and engineers, to transform raw data into actionable visual insights in minutes. This article will guide you through the installation and practical use of GeoLibre, so you can start creating your interactive maps today.

Tested on: Ubuntu 24.04 LTS · Python 3.10 · GeoLibre 0.1.0 · July 2026

Prerequisites / Test Environment

To follow this guide, you will need a Python 3.8+ environment with pip installed. It is recommended to create a virtual environment to isolate project dependencies. The commands have been tested on an Ubuntu 24.04 LTS system but are compatible with any Linux distribution, macOS, or Windows with Python correctly configured.

To begin, install GeoLibre and its main dependencies:

python3 -m venv geolibre_env
source geolibre_env/bin/activate
pip install geolibre

This installation includes Streamlit, Geopandas, and Folium, the fundamental libraries GeoLibre relies on for geospatial data management and visualization.

1. Load and visualize vector data (Points)

The most common use case is visualizing points from a tabular dataset, such as a CSV file or a Geopandas DataFrame. Let’s assume we have a 5g_cell_data.csv file with latitude, longitude, and cell_id columns.

Create a file named app_points.py:

import streamlit as st
import geolibre as gl
import pandas as pd

st.set_page_config(layout="wide")
st.title("Interactive 5G Cell Map")

# Load data (replace with your path or load from file)
data = {
    'cell_id': ['Cell_A', 'Cell_B', 'Cell_C', 'Cell_D', 'Cell_E'],
    'latitude': [41.9028, 41.8919, 41.9050, 41.8800, 41.9100],
    'longitude': [12.4964, 12.5113, 12.4800, 12.5000, 12.5200]
}
df = pd.DataFrame(data)

st.write("### 5G Cell Data")
st.dataframe(df)

# Initialize the map
mappa = gl.Map(center=[df['latitude'].mean(), df['longitude'].mean()], zoom=12)

# Add points from DataFrame
mappa.add_points_from_dataframe(
    df,
    lat='latitude',
    lon='longitude',
    tooltip='cell_id',
    color='red',
    radius=8
)

# Display the map in Streamlit
st.write("### Map Visualization")
mappa.st_map(height=600)

To run the application and view the map in your browser:

streamlit run app_points.py

A web page will open showing a table with the data and an interactive map with the cell points. You can zoom, pan, and click on the points to see the tooltip.

2. Work with complex vector layers (Polygons)

GeoLibre also supports more complex vector layers like polygons, ideal for representing geographical areas, administrative boundaries, or coverage zones. We will use a GeoJSON file, a standard format for geospatial data.

Create an app_polygons.py file and a rome_boundaries.geojson file (you can find examples online or generate your own).

import streamlit as st
import geolibre as gl
import geopandas as gpd

st.set_page_config(layout="wide")
st.title("Interactive Administrative Boundaries Map")

# Load a GeoJSON (fictitious example, replace with a real GeoJSON)
# Example GeoJSON for a single polygon (e.g., a district of Rome)
geoj_data = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {"name": "District_A", "population": 15000},
            "geometry": {
                "type": "Polygon",
                "coordinates": [[
                    [12.49, 41.90], [12.50, 41.90], [12.50, 41.89], [12.49, 41.89], [12.49, 41.90]
                ]]
            }
        },
        {
            "type": "Feature",
            "properties": {"name": "District_B", "population": 22000},
            "geometry": {
                "type": "Polygon",
                "coordinates": [[
                    [12.50, 41.91], [12.51, 41.91], [12.51, 41.90], [12.50, 41.90], [12.50, 41.91]
                ]]
            }
        }
    ]
}

# Convert to GeoDataFrame
gdf = gpd.GeoDataFrame.from_features(geoj_data['features'], crs="EPSG:4326")

st.write("### Geographical District Data")
st.dataframe(gdf)

# Initialize the map
mappa = gl.Map(center=[41.90, 12.50], zoom=12)

# Add polygons from GeoDataFrame
mappa.add_gdf(
    gdf,
    name='Districts',
    style_function=lambda x: {'fillColor': 'blue', 'color': 'black', 'weight': 1, 'fillOpacity': 0.5},
    tooltip_columns=['name', 'population']
)

# Add layer control
mappa.add_layer_control()

st.write("### Polygon Visualization on Map")
mappa.st_map(height=600)

Run with:

streamlit run app_polygons.py

You will see the polygons represented on the map. The LayerControl will allow you to toggle layer visibility. This functionality is crucial when working with multiple overlapping datasets. Read also: Prometheus Alerting: Telegram, Email, PagerDuty with AlertManager

3. Visualize Raster Data

For raster data, such as satellite imagery or digital elevation models (DEMs), GeoLibre integrates with Rasterio. Let’s assume you have a dem.tif file (a typical georeferenced raster format).

import streamlit as st
import geolibre as gl
import rasterio
import numpy as np

st.set_page_config(layout="wide")
st.title("Interactive Raster Data Map")

# Create a fictitious raster for demonstration
# In a real scenario, you would use rasterio.open('path/to/your/file.tif')
height = 100
width = 100
rows, cols = np.indices((height, width))
data = np.sin(rows / 10) + np.cos(cols / 10)
transform = rasterio.transform.from_bounds(12.48, 41.88, 12.52, 41.92, width, height)

# Initialize the map
mappa = gl.Map(center=[41.90, 12.50], zoom=12)

# Add the raster layer
mappa.add_raster(data, transform, caption='Fictitious DEM', cmap='viridis')

# Display the map in Streamlit
st.write("### Raster Data Visualization on Map")
mappa.st_map(height=600)

Run with streamlit run app_raster.py. This will allow you to display raster data directly on the map, combining the richness of spatial information with GeoLibre’s interactivity. Read also: LVM Snapshot: Safe Rollback for Critical Updates

Common Errors and Troubleshooting

  • Missing geopandas or rasterio dependencies: Although pip install geolibre should install the main dependencies, sometimes in complex environments, some system libraries required for geopandas or rasterio might be missing. Ensure you have libspatialindex-dev (on Debian/Ubuntu) or gdal-devel (on Fedora/CentOS) installed before installing GeoLibre.
    sudo apt-get update && sudo apt-get install libspatialindex-dev
  • st.set_page_config() error: This command must be the first thing Streamlit executes. Ensure there is no other Streamlit code (e.g., st.title() or st.write()) before st.set_page_config() in your script.
  • Data not displayed correctly: Always check that the lat and lon columns in your DataFrame are numerical and that the values fall within a valid geographical range (-90 to 90 for latitude, -180 to 180 for longitude). A common error is swapping latitude and longitude, or using non-standard coordinate formats.

FAQ — Frequently Asked Questions

Is GeoLibre suitable for production applications with large datasets?

GeoLibre, being based on Streamlit, is excellent for rapid prototyping, interactive analysis, and internal dashboards. For extremely large datasets or applications with very high-performance requirements, it might be necessary to optimize queries or consider more robust backend solutions, while still using Streamlit/GeoLibre for the visualization frontend.

Can I customize the map’s appearance?

Absolutely. GeoLibre exposes many of Folium and Leaflet’s functionalities. You can customize colors, icons, tooltips, popups, and add specific styles through the add_points_from_dataframe, add_gdf, and add_raster functions, often by passing custom style functions or parameters directly to the calls.

Is it possible to integrate GeoLibre with a geospatial database like PostGIS?

Yes, you can connect GeoLibre to PostGIS or other geospatial databases. The typical workflow would be to use sqlalchemy and geopandas.read_postgis to load data directly from the database into a GeoDataFrame, and then pass this GeoDataFrame to GeoLibre for visualization. This allows you to leverage the power of PostGIS for spatial queries and GeoLibre for the frontend.

Does GeoLibre support projections other than EPSG:4326 (WGS84)?

Internally, web maps based on Leaflet/Folium primarily operate with EPSG:4326. If your data is in a different projection, geopandas offers functions to reproject GeoDataFrames (e.g., gdf.to_crs("EPSG:4326")) before passing them to GeoLibre. This is a standard step when working with geospatial data from various sources.

Conclusions with Operational Takeaways

GeoLibre represents a significant bridge between the complexity of geospatial data and the ease of use of interactive web applications in Python. Its integration with Streamlit allows sysadmins, data scientists, and analysts to create functional and sharable dashboards with minimal effort. The ability to transform a simple spreadsheet with coordinates into an interactive map is a game-changer for rapid analysis and visualization of critical scenarios, from IT resource distribution to mapping security events. Adopting GeoLibre can reduce the time spent on data visualization and increase its usability within your team. Read also: Elasticsearch OOM: Cluster RED from Unassigned Shard

Sources

Updated: July 2026

Share this article:

Written by

Rosario Giordano

Rosario Giordano is a system administrator and IT consultant specializing in cybersecurity and cloud, with over 20 years of experience managing enterprise Linux infrastructures. His areas of expertise include SSH hardening, Kubernetes platforms, PostgreSQL databases, VMware/ Proxmox virtualization, and compliance with NIS2 and ISO 27001 security frameworks