Skip to main content

GigaSpatial

PyPI version Python versions License: AGPL-3.0 Downloads Documentation

GigaSpatial acquires published geospatial datasets into a data store you control, loads them for a source, and processes them. A generator maps a dataset onto points of interest or zones, and the result is a view: those places with attributes from the datasets attached. It started in UNICEF's Giga initiative.

Use it for humanitarian, development, connectivity, and climate analysis: map population, building footprints, wealth, and flood hazard onto grids (H3 hexagons, S2 cells, Mercator tiles), administrative boundaries, or custom geometries; estimate population and nearest buildings around points of interest (such as schools, clinics, or cell sites); combine WorldPop, building footprints, and OpenStreetMap into one country dataset in a few lines of Python; and route or connect places along OpenStreetMap road networks.

What it covers

  • Handlers acquire datasets published as files, keep them in your data store, and load them for a country or geometry:
    • Population and settlement: WorldPop (WPPopulationHandler) and GHSL (GHSLDataHandler for GHS_POP, GHS_BUILT_S, GHS_SMOD, building height, and volume)
    • Building footprints: Google-Microsoft combined buildings (GoogleMSBuildingsHandler), Google Open Buildings (GoogleOpenBuildingsHandler), and Microsoft Global Buildings (MSBuildingsHandler)
    • OpenStreetMap road networks: country-scale road networks from Geofabrik extracts (OSMRoadsHandler)
    • Socioeconomic and humanitarian: Meta Relative Wealth Index (RWIHandler) and Humanitarian Data Exchange (HDXHandler)
    • Connectivity and infrastructure: Ookla Speedtest tiles (OoklaSpeedtestHandler), OpenCellID cell towers (OpenCellIDHandler), and WRI Global Power Plant Database (GlobalPowerPlantHandler)
    • Terrain, climate, and hazards: NASA SRTM elevation (NasaSRTMHandler), Copernicus CEMS river flood hazard (CEMSFloodHazardHandler), WRI Aqueduct flood hazard (AqueductFloodHandler), and GEM Global Seismic Hazard Map (GSHMHandler)
    • Administrative boundaries: AdminBoundaries
  • Fetchers query datasets served by an API or database: OpenStreetMap places (OSMLocationFetcher) and road networks (OSMRoadsFetcher), Giga schools (GigaSchoolLocationFetcher, GigaSchoolProfileFetcher, GigaSchoolMeasurementsFetcher, GigaCountriesFetcher), Healthsites.io (HealthSitesFetcher), PeeringDB (PeeringDBFetcher), STORM tropical cyclone wind speeds (STORMWindSpeedFetcher), Overture Maps amenities (OvertureAmenityFetcher), UNICEF SDG indicators (UnicefDataFetcher), M-Lab speed tests in BigQuery (MLabFetcher), and Google Earth Engine (GEEProfiler, including MERIT Hydro).
  • Generators map datasets onto points of interest (PoiViewGenerator) or zones (ZonalViewGenerator, H3ViewGenerator, S2ViewGenerator, MercatorViewGenerator, AdminBoundariesViewGenerator) and return a view.
  • Processing provides raster (TifProcessor) and vector tools for the stored files.
  • Road networks: OSMRoadsFetcher fetches OpenStreetMap roads for a source, OSMRoadsHandler builds them for whole countries from Geofabrik's extracts, and SpatialNetwork and ConnectionPlanner join schools or other points to them, find shortest paths, and plan the roads that connect a set of points.

Files live in a data store: local disk (LocalDataStore), Azure Data Lake Storage (ADLSDataStore), Snowflake (SnowflakeDataStore), or Delta Sharing (DeltaSharingDataStore). Handlers only depend on the abstract DataStore, so other stores can be added by implementing it.

The full list of datasets is on the Datasets page.

Installation

GigaSpatial requires Python 3.11 or above.

pip install giga-spatial

To install every optional integration (Earth Engine, BigQuery, Azure, Snowflake, and others):

pip install "giga-spatial[all]"

The individual extras, such as roads for OpenStreetMap road networks, are listed on the Installation page.

Example

Map population and building footprints onto H3 hexagons

Map WorldPop population and Google-Microsoft building footprints onto H3 cells for Rwanda. The first run downloads the files into the data store, and later runs read the stored files.

from gigaspatial import H3ViewGenerator

zones = H3ViewGenerator(source="RWA", resolution=6)
zones.map_wp_pop(country="RWA")
view = zones.map_buildings(country="RWA")
print(view.head())

view is the H3 cells with population and building_count attached. The same pattern works with S2ViewGenerator, MercatorViewGenerator, and AdminBoundariesViewGenerator.

Rwanda H3 cells at resolution 6 colored by WorldPop population

Estimate population around schools or points of interest

Sum WorldPop population within a 1 km radius around schools or clinics fetched from OpenStreetMap:

from gigaspatial import OSMLocationFetcher, PoiViewGenerator

schools = OSMLocationFetcher(country="RWA", location_types=["school"]).fetch_locations()
view = PoiViewGenerator(schools).map_wp_pop(country="RWA", map_radius_meters=1000)
print(view[["population"]].head())

Download building footprints for a country

Download combined Google Open Buildings and Microsoft Global Buildings footprints for a country and load them as a GeoDataFrame:

from gigaspatial import GoogleMSBuildingsHandler

buildings = GoogleMSBuildingsHandler()
buildings.ensure_data_available("ATG")  # downloads country GeoParquet on first run; no API key needed
gdf = buildings.load_data("ATG")
print(len(gdf), gdf.columns.tolist())

Pass any ISO3 country code, a bounding box, or a polygon. Country files are cached in your data store so later runs read locally.

Load WorldPop population and aggregate to administrative regions

Load a country's WorldPop population raster as a TifProcessor and sum population per administrative region:

from gigaspatial import AdminBoundaries, WPPopulationHandler

pop = WPPopulationHandler(year=2025, resolution=1000)
raster = pop.load_data("RWA", merge_rasters=True)  # downloads GeoTIFF on first run; no API key needed
provinces = AdminBoundaries.create("RWA", admin_level=1).to_geodataframe()
provinces["population"] = raster.sample_by_polygons(provinces.geometry, stat="sum")
print(provinces[["name", "population"]])

You can also sample at coordinates with raster.sample_by_coordinates(...), or use GHSLDataHandler(product="GHS_POP", year=2020, resolution=1000) for Global Human Settlement Layer population.

See Combining datasets for a country and Population around points for more workflows.

How GigaSpatial compares to other tools

  • Hand-built geopandas, rasterio, rasterstats, pyrosm, and osmnx pipelines: GigaSpatial uses geopandas, rasterio, and h3 under the hood, and replaces custom per-dataset download scripts, tile stitching, CRS projection, and buffer or zonal loops with handlers, fetchers, and generators that run in a few lines of Python.
  • Grid libraries (h3-py, h3ronpy, h3-toolkit): h3-py indexes coordinates and geometries into H3 cell IDs. H3ViewGenerator, S2ViewGenerator, MercatorViewGenerator, AdminBoundariesViewGenerator, and ZonalViewGenerator in GigaSpatial acquire published country datasets (WorldPop, GHSL, Google and Microsoft buildings, Relative Wealth Index) into your data store and map them directly onto H3 hexagons, S2 cells, Mercator tiles, administrative boundaries, or custom polygons.
  • Cloud catalogs and spatial engines (Google Earth Engine, Microsoft Planetary Computer, PostGIS, DuckDB, Apache Sedona): Cloud platforms and spatial databases run queries inside their own infrastructure. GigaSpatial downloads and caches published datasets into a data store you control (local disk, Azure Data Lake Storage, or Snowflake) and also provides optional GEEProfiler (giga-spatial[gee]), BigQueryClient (giga-spatial[bq]), and DuckDB or Trino integrations when you want them.

Documentation

Why open source?

At Giga, we believe in the power of open-source technologies to accelerate progress and innovation. By keeping our tools and systems open, we:

  • Encourage collaboration and contributions from a global community.
  • Ensure transparency and trust in our methodologies.
  • Empower others to adopt, adapt, and extend our tools to meet their needs.

Contributing

Contributions are welcome, from bug reports to new datasets. See the contribution guidelines to get started.

Everyone taking part is expected to follow the Code of Conduct.

Get in touch

About Giga

Giga is a UNICEF-ITU initiative to connect every school to the Internet and every young person to information, opportunity and choice. Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.

GigaSpatial is developed by Giga's applied science team at UNICEF.

Licensed under AGPL-3.0-or-later.

Metadata

Release files for giga-spatial 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for giga-spatial 0.12.0
File Size Uploaded Provenance Actions
giga_spatial-0.12.0.tar.gz 3.7 MB Without provenance Details for giga_spatial-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for giga-spatial 0.12.0
File Interpreter ABI Platform Actions
giga_spatial-0.12.0-py3-none-any.whl Python 3 none any Details for giga_spatial-0.12.0-py3-none-any.whl

Total release size: 4.2 MB

Release files / giga_spatial-0.12.0.tar.gz

Download URL giga_spatial-0.12.0.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
245d90b06378fa75cb8a4f71cf188423f68f13b042377e78a3cab881f996d420
BLAKE2b-256 checksum
How to use checksums
e275178f3c33b7e7c9751ab13a2b104697f33a017c7e9bb6928c4d599481a415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / giga_spatial-0.12.0-py3-none-any.whl

Download URL giga_spatial-0.12.0-py3-none-any.whl
Size 485.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d24ab66cafd5acc63dc540ca5c25f1d3c5addec1e281952b462bd0bb9ee4ab4d
BLAKE2b-256 checksum
How to use checksums
7a630984d9f1589deaa7482202849d1499fcbeb45456583d8c64b4ff3f34bb96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for giga-spatial 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page