Skip to content

v0.12.0: Unified view generators, a sturdier TifProcessor and five new data sources

Latest

Choose a tag to compare

@utkucanozturk utkucanozturk released this 30 Nov 12:31
7eeb759

v0.12.0 puts the POI and zonal view generators behind one interface, reworks how TifProcessor handles files and reprojection, and adds five new data sources, with Python 3.11 now the minimum.

Upgrade notes / breaking changes

  • Python 3.11 or newer is required (#69). Python 3.10 reached end of life on 2026-10-01. pip keeps 3.10 users on v0.11.x; to be explicit, pin giga-spatial<0.12.

  • giga-spatial[roads] now needs osmnx>=2.0.6 (#69). OSMRoadsHandler now excludes rest_area and services ways, matching OSMRoadsFetcher and osmnx 2.0.6, so road networks stored by older builds are rebuilt once on their next load.

  • build_distance_graph is removed (deprecated in v0.11.1) (#70). Use SpatialNetwork.from_points or SpatialNetwork.from_point_sets instead. The remaining deprecation warnings now name v0.13 for removal.

  • MercatorTiles reads 2-tuples as (lon, lat). get_quadkeys_from_points, from_points and from_spatial previously swapped tuple coordinates. If you passed (lat, lon) tuples to work around it, switch to (lon, lat), the same order as Shapely Points, H3Hexagons and S2Cells.

  • S2Cells.to_geodataframe skipped cells. Cells that fail conversion are now dropped from every column together (this used to raise a length-mismatch ValueError), and a warning logs how many were skipped.

  • One return contract for map_* methods (#55). Every map_* method on PoiViewGenerator and ZonalViewGenerator now updates and returns self.view (a pd.DataFrame). Empty data fills the target columns with 0, False or NaN instead of returning None, a dict or a GeoDataFrame. Reusing an existing output column raises ValueError unless you pass overwrite=True.

    # Before
    counts = zones.map_points(schools)              # returned dict
    zones.add_variable_to_view(counts, "schools")
    bldg_gdf = zones.map_ms_buildings()             # returned GeoDataFrame
    
    # After
    view = zones.map_points(schools, output_column="schools")  # updates & returns zones.view
    view = zones.map_ms_buildings()                            # updates & returns zones.view (0/NaN if empty)
    bldg_gdf = zones.to_geodataframe()                         # attach geometries when needed

    map_rwi now uses an explicit output_column as given (the default is rwi_{aggregation}), and it raises ValueError when a country has no RWI data.

  • TifProcessor.reproject_to is removed (#62). Use to_crs(...).save_to_file(path), or keep the processor that to_crs(...) returns.

  • Merging rasters in different CRSs now raises ValueError when no target_crs is given. It used to only log a warning and produce a wrong mosaic. Pass target_crs to migrate. Mean merges of integer rasters now return a float dtype (#59).

  • Deprecated: PoiViewGeneratorConfig and ZonalViewGeneratorConfig (pass ensure_available= to the constructor instead), dataset_year and dataset_resolution on map_built_s and map_smod (use year and resolution), the bare-name and output_format= forms of save_view (pass a file path with an extension), and GeometryBasedZonalViewGenerator (use ZonalViewGenerator).

View generators: one interface

  • The new internal BaseViewGenerator now underlies both PoiViewGenerator and ZonalViewGenerator, so map_points, map_polygons, map_rasters, the dataset map_* methods, add_variable_to_view, chain_operations and validate_data_coverage work the same way on both (#55).
  • The zonal hierarchy collapses into one concrete ZonalViewGenerator, and GeometryBasedZonalViewGenerator is now a deprecated thin subclass (#54).
  • Dataset map_* methods and find_nearest_buildings accept an optional handler=, so you can pass a pre-built handler (#53).
  • ensure_available is now a constructor argument on every generator and can be overridden per call. overwrite= is available on all map_* methods.
  • save_view(path) takes a file path, delegates the format to write_dataset, and attaches geometries for .geojson, .gpkg and .shp.
  • aggregate_polygons_to_zones can count polygons natively (value_columns=None with aggregation="count") with the intersects, within and fractional predicates.

TifProcessor architecture

  • New TifProcessor.to_crs(target_crs, resampling_method=None, resolution=None) returns a new, independent processor in the target CRS, the same way clip_to_geometry returns a clipped one (#62).
  • A processor over a file in a non-local data store such as ADLS downloads it once into a local working copy. It no longer reads the whole file into memory on every open, including in each batched-sampling worker.
  • Temporary files have a single owner. Copies and pickled worker copies no longer delete the original's working files, and cleanup() can be called safely more than once. Using a merged, reprojected or clipped processor after cleanup() raises a clear FileNotFoundError.
  • Clips and to_crs results keep their parent's lineage (dataset_paths, is_merged, source_count) and settings. map_rasters merges of a processor list inherit the first processor's settings.
  • CRSs are compared semantically, so an EPSG code and the equivalent WKT count as the same CRS.

New data sources

  • STORM tropical cyclone wind speeds: STORMWindSpeedFetcher returns a global fixed-return-period wind-speed map (10 km, m/s) as a TifProcessor, for the present-day baseline or a 2050 RCP8.5 model. CC0 (#64).
  • GEM Global Seismic Hazard Map: GSHMHandler downloads the GEM GSHM v2026.1 peak ground acceleration points (10% exceedance in 50 years) and loads them for a geometry. CC BY-NC-SA 4.0 (#63).
  • MERIT Hydro: merit_hydro is now in the Earth Engine registry, with 3 arc-second global hydrography (elevation, flow direction, river width, upstream area, HAND and more) (#48).
  • Global Power Plant Database: GlobalPowerPlantHandler loads a WRI release (1.3.0 by default, with 1.1.0 and 1.2.0 also accepted) for a source (#60).
  • PeeringDB facilities: PeeringDBFetcher.fetch_facilities returns facilities as a GeoDataFrame in EPSG:4326, filtered by country or extent (#61).

Fixes

  • Security: API tokens are now redacted from URLs, logs, exceptions and reprs in the Mapbox, Maxar, GeoRepo, REST client, HealthSites, PeeringDB, Giga API and OpenCellID code, through the new shared redact_url and sanitize_exception helpers. Requests still send the real credentials (#66).
  • Grids: country H3, S2 and Mercator grids now cover every part of a multi-part country, including islands. H3Hexagons.from_geometry and S2Cells.from_geometry handle a single Point, and MercatorTiles.from_spatial dispatches points correctly and raises a clear TypeError for unsupported input.
  • Geo processing: annotate_with_admin_regions, map_points_within_polygons and polygon counting no longer modify the inputs you pass in. Admin ties on shared borders are now broken deterministically, and the UTM CRS fallback is consistent across helpers.
  • Generators: custom poi_id_column and zone_id columns are validated, coordinates are read from projected GeoDataFrames correctly, save_view to GeoJSON and GeoPackage works, map_zonal_stats renames the default column, grid generators accept a GeoDataFrame source, a handler passed to map_ms_buildings is kept, and raster temp directories are cleaned up promptly.
  • Overture: the stale default release is gone. A failed "latest" lookup now raises an error asking for an explicit release=, explicit releases are validated against the STAC catalog, and get_available_releases() is new (#52).
  • TifProcessor: to_dataframe_chunked works on multi-band rasters, the sample_by_polygons_batched memory guard warns instead of crashing, sparse to_graph handles rasters with no adjacent valid pixels, to_dataframe accepts a band_names list in single mode, clips work on rgb, rgba and multi processors, and clipped processors over non-local data stores work in map_rasters and batched sampling (#59, #62).

Docs

  • The README and docs home have runnable quickstarts (building footprints for a country, and WorldPop aggregated to admin regions), and the list of covered sources now includes the new ones. Package metadata shares one description (#71).
  • GEM seismic docs now use the Global Seismic Hazard Map name (#72).

pip install giga-spatial --upgrade

Docs: https://unicef.github.io/giga-spatial/
Full changelog: https://github.com/unicef/giga-spatial/blob/main/CHANGELOG.md