giga-spatial 0.6.2__tar.gz → 0.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/.env_sample +2 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/CHANGELOG.md +81 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/PKG-INFO +18 -8
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/README.md +17 -7
- giga_spatial-0.6.4/docs/examples/basic.md +185 -0
- giga_spatial-0.6.4/docs/examples/downloading/ghsl.md +61 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/getting-started/installation.md +17 -10
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/getting-started/quickstart.md +39 -22
- giga_spatial-0.6.4/docs/user-guide/configuration.md +130 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/giga_spatial.egg-info/PKG-INFO +18 -8
- giga_spatial-0.6.4/gigaspatial/__init__.py +1 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/config.py +6 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/__init__.py +7 -3
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/boundaries.py +196 -43
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/ghsl.py +7 -6
- giga_spatial-0.6.4/gigaspatial/handlers/giga.py +786 -0
- giga_spatial-0.6.4/gigaspatial/handlers/hdx.py +509 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/maxar_image.py +1 -2
- giga_spatial-0.6.4/gigaspatial/handlers/rwi.py +155 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/processing/tif_processor.py +88 -2
- giga_spatial-0.6.2/docs/examples/basic.md +0 -249
- giga_spatial-0.6.2/docs/examples/downloading/ghsl.md +0 -38
- giga_spatial-0.6.2/docs/user-guide/configuration.md +0 -76
- giga_spatial-0.6.2/gigaspatial/__init__.py +0 -1
- giga_spatial-0.6.2/gigaspatial/handlers/giga.py +0 -145
- giga_spatial-0.6.2/gigaspatial/handlers/hdx.py +0 -241
- giga_spatial-0.6.2/gigaspatial/handlers/rwi.py +0 -157
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/CODE_OF_CONDUCT.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/CONTRIBUTING.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/LICENSE +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/MANIFEST.in +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/PULL_REQUEST_TEMPLATE.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/.DS_Store +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/core.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/generators.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/grid.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/handlers.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/index.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/api/processing.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/assets/GIGA_horizontal_notext_white.webp +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/assets/datasets.png +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/assets/logo.png +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/changelog.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/contributing.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/examples/advanced.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/examples/downloading/osm.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/examples/index.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/examples/processing/tif.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/examples/use-cases.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/index.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/license.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/stylesheets/extra.css +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/docs/user-guide/index.md +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/giga_spatial.egg-info/SOURCES.txt +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/giga_spatial.egg-info/dependency_links.txt +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/giga_spatial.egg-info/requires.txt +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/giga_spatial.egg-info/top_level.txt +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/adls_data_store.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/data_api.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/data_store.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/local_data_store.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/readers.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/io/writers.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/schemas/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/core/schemas/entity.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/poi.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/zonal/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/zonal/base.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/zonal/geometry.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/generators/zonal/mercator.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/grid/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/grid/mercator_tiles.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/base.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/google_open_buildings.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/mapbox_image.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/microsoft_global_buildings.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/ookla_speedtest.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/opencellid.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/osm.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/overture.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/unicef_georepo.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/handlers/worldpop.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/processing/__init__.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/processing/geo.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/processing/sat_images.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/gigaspatial/processing/utils.py +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/pyproject.toml +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/requirements.txt +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/setup.cfg +0 -0
- {giga_spatial-0.6.2 → giga_spatial-0.6.4}/setup.py +0 -0
@@ -12,6 +12,8 @@ export OPENCELLID_ACCESS_TOKEN=""
|
|
12
12
|
export GEOREPO_API_KEY=""
|
13
13
|
export GEOREPO_USER_EMAIL=""
|
14
14
|
export GIGA_SCHOOL_LOCATION_API_KEY=""
|
15
|
+
export GIGA_SCHOOL_PROFILE_API_KEY=""
|
16
|
+
export GIGA_SCHOOL_MEASUREMENTS_API_KEY=""
|
15
17
|
export ROOT_DATA_DIR=""
|
16
18
|
export BRONZE_DIR=""
|
17
19
|
export SILVER_DIR=""
|
@@ -2,6 +2,87 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [v0.6.4] - 2025-06-19
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- **GigaSchoolProfileFetcher**
|
10
|
+
- New class to fetch and process school profile data from the Giga School Profile API
|
11
|
+
- Supports paginated fetching, filtering by country and school ID
|
12
|
+
- Includes methods to generate connectivity summary statistics by region, connection type, and source
|
13
|
+
|
14
|
+
- **GigaSchoolMeasurementsFetcher**
|
15
|
+
- New class to fetch and process daily real-time connectivity measurements from the Giga API
|
16
|
+
- Supports filtering by date range and school
|
17
|
+
- Includes performance summary generation (download/upload speeds, latency, quality flags)
|
18
|
+
|
19
|
+
- **AdminBoundaries.from_geoboundaries**
|
20
|
+
- New class method to download and process geoBoundaries data by country and admin level
|
21
|
+
- Automatically handles HDX dataset discovery, downloading, and fallback logic
|
22
|
+
|
23
|
+
- **HDXConfig.search_datasets**
|
24
|
+
- Static method to search HDX datasets without full handler initialization
|
25
|
+
- Supports query string, sort order, result count, HDX site selection, and custom user agent
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- Typo in `MaxarImageDownloader` causing runtime error
|
30
|
+
|
31
|
+
### Documentation
|
32
|
+
|
33
|
+
- **Improved Configuration Guide** (`docs/user-guide/configuration.md`)
|
34
|
+
- Added comprehensive table of environment variables with defaults and descriptions
|
35
|
+
- Synced `.env_sample` and `config.py` with docs
|
36
|
+
- Example `.env` file and guidance on path overrides using `config.set_path`
|
37
|
+
- New section on `config.ensure_directories_exist` and troubleshooting tips
|
38
|
+
- Clearer handling of credentials and security notes
|
39
|
+
- Improved formatting and structure for clarity
|
40
|
+
|
41
|
+
## [v0.6.3] - 2025-06-16
|
42
|
+
|
43
|
+
### Added
|
44
|
+
- Major refactor of `HDX` module to align with unified `BaseHandler` architecture:
|
45
|
+
- `HDXConfig`: fully aligned with `BaseHandlerConfig` structure.
|
46
|
+
- Added flexible pattern matching for resource filtering.
|
47
|
+
- Improved data unit resolution by country, geometry, and points.
|
48
|
+
- Enhanced resource filtering with exact and regex options.
|
49
|
+
- `HDXDownloader` fully aligned with `BaseHandlerDownloader`:
|
50
|
+
- Simplified sequential download logic.
|
51
|
+
- Improved error handling, validation, and logging.
|
52
|
+
- `HDXReader` fully aligned with `BaseHandlerReader`:
|
53
|
+
- Added `resolve_source_paths` and `load_all_resources` methods.
|
54
|
+
- Simplified source handling for single and multiple files.
|
55
|
+
- Cleaned up redundant and dataset-specific logic.
|
56
|
+
- Introduced `HDXHandler` as unified orchestration layer using factory methods.
|
57
|
+
|
58
|
+
- Refactor of `RelativeWealthIndex (RWI)` module:
|
59
|
+
- Added new `RWIHandler` class aligned with `HDXHandler` and `BaseHandler`.
|
60
|
+
- Simplified class names: `RWIDownloader` and `RWIReader`.
|
61
|
+
- Enhanced configuration with `latest_only` flag to select newest resources automatically.
|
62
|
+
- Simplified resource filtering and country resolution logic.
|
63
|
+
- Improved code maintainability, type hints, and error handling.
|
64
|
+
|
65
|
+
|
66
|
+
- **New raster multi-band support in TifProcessor:**
|
67
|
+
- Added new `multi` mode for handling multi-band raster datasets.
|
68
|
+
- Automatic band name detection from raster metadata.
|
69
|
+
- Added strict mode validation (`single`, `rgb`, `rgba`, `multi`).
|
70
|
+
- Enhanced error handling for invalid modes and band counts.
|
71
|
+
|
72
|
+
### Fixed
|
73
|
+
- Fixed GHSL tiles loading behavior for correct coordinate system handling:
|
74
|
+
- Moved `TILES_URL` formatting and tile loading to `validate_configuration`.
|
75
|
+
- Ensures proper tile loading after CRS validation.
|
76
|
+
|
77
|
+
### Documentation
|
78
|
+
- Updated and standardized API references across documentation.
|
79
|
+
- Standardized handler method names and usage examples.
|
80
|
+
- Added building enrichment examples for POI processing.
|
81
|
+
- Updated installation instructions.
|
82
|
+
|
83
|
+
### Deprecated
|
84
|
+
- Deprecated direct imports from individual handler modules.
|
85
|
+
|
5
86
|
## [v0.6.2] - 2025-06-11
|
6
87
|
|
7
88
|
### Added
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: giga-spatial
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.4
|
4
4
|
Summary: A package for spatial data download & processing
|
5
5
|
Home-page: https://github.com/unicef/giga-spatial
|
6
6
|
Author: Utku Can Ozturk
|
@@ -51,17 +51,27 @@ Dynamic: summary
|
|
51
51
|
|
52
52
|
# GigaSpatial
|
53
53
|
|
54
|
-
|
55
|
-
Giga is a UNICEF-ITU initiative to connect every school to the Internet and every young person to information, opportunity and choice.
|
56
|
-
Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.
|
54
|
+
## About Giga
|
57
55
|
|
58
|
-
|
56
|
+
[Giga](https://giga.global/) is a UNICEF-ITU initiative to connect every school to the Internet and every young person to information, opportunity and choice.
|
57
|
+
Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.
|
59
58
|
|
60
59
|
## About GigaSpatial
|
61
60
|
|
62
61
|
**GigaSpatial** is a Python package developed as part of the Giga Applied Science Team to handle geospatial data efficiently. It provides tools for downloading, processing, and analyzing geospatial data, enabling users to work with datasets such as OpenStreetMap (OSM), Global Human Settlement Layer (GHSL), Microsoft Global Buildings, Google Open Buildings, and more. The package is designed to support Giga's mission by providing robust geospatial capabilities for mapping and analyzing school connectivity.
|
63
62
|
|
64
|
-
|
63
|
+
## Installation
|
64
|
+
|
65
|
+
See the [installation docs](https://unicef.github.io/giga-spatial/getting-started/installation/) for all details. GigaSpatial requires Python 3.10 or above and depends on the following key packages:
|
66
|
+
|
67
|
+
- geopandas
|
68
|
+
- pandas
|
69
|
+
- shapely
|
70
|
+
- rasterio
|
71
|
+
|
72
|
+
We recommend using a virtual environment for installation. See the [installation docs](https://unicef.github.io/giga-spatial/getting-started/installation/) for more details.
|
73
|
+
|
74
|
+
## Key Features
|
65
75
|
- **Data Downloading**: Download geospatial data from various sources including GHSL, Microsoft Global Buildings, Google Open Buildings, OpenCellID, and HDX datasets.
|
66
76
|
- **Data Processing**: Process and transform geospatial data, such as GeoTIFF files and vector data, with support for compression and efficient handling.
|
67
77
|
- **View Generators**:
|
@@ -74,7 +84,7 @@ Giga maps schools' Internet access in real time, creates models for innovative f
|
|
74
84
|
- Centralized configuration via environment variables or `.env` file
|
75
85
|
- Easy setup of API keys and paths
|
76
86
|
|
77
|
-
|
87
|
+
## Supported Datasets
|
78
88
|
|
79
89
|
The `gigaspatial` package supports data from the following providers:
|
80
90
|
|
@@ -84,7 +94,7 @@ The `gigaspatial` package supports data from the following providers:
|
|
84
94
|
|
85
95
|
---
|
86
96
|
|
87
|
-
|
97
|
+
## View Generators
|
88
98
|
|
89
99
|
The **view generators** in GigaSpatial are designed to enrich the spatial context of school locations and map data into grid or POI locations. This enables users to analyze and visualize geospatial data in meaningful ways.
|
90
100
|
|
@@ -5,17 +5,27 @@
|
|
5
5
|
|
6
6
|
# GigaSpatial
|
7
7
|
|
8
|
-
|
9
|
-
Giga is a UNICEF-ITU initiative to connect every school to the Internet and every young person to information, opportunity and choice.
|
10
|
-
Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.
|
8
|
+
## About Giga
|
11
9
|
|
12
|
-
|
10
|
+
[Giga](https://giga.global/) is a UNICEF-ITU initiative to connect every school to the Internet and every young person to information, opportunity and choice.
|
11
|
+
Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.
|
13
12
|
|
14
13
|
## About GigaSpatial
|
15
14
|
|
16
15
|
**GigaSpatial** is a Python package developed as part of the Giga Applied Science Team to handle geospatial data efficiently. It provides tools for downloading, processing, and analyzing geospatial data, enabling users to work with datasets such as OpenStreetMap (OSM), Global Human Settlement Layer (GHSL), Microsoft Global Buildings, Google Open Buildings, and more. The package is designed to support Giga's mission by providing robust geospatial capabilities for mapping and analyzing school connectivity.
|
17
16
|
|
18
|
-
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
See the [installation docs](https://unicef.github.io/giga-spatial/getting-started/installation/) for all details. GigaSpatial requires Python 3.10 or above and depends on the following key packages:
|
20
|
+
|
21
|
+
- geopandas
|
22
|
+
- pandas
|
23
|
+
- shapely
|
24
|
+
- rasterio
|
25
|
+
|
26
|
+
We recommend using a virtual environment for installation. See the [installation docs](https://unicef.github.io/giga-spatial/getting-started/installation/) for more details.
|
27
|
+
|
28
|
+
## Key Features
|
19
29
|
- **Data Downloading**: Download geospatial data from various sources including GHSL, Microsoft Global Buildings, Google Open Buildings, OpenCellID, and HDX datasets.
|
20
30
|
- **Data Processing**: Process and transform geospatial data, such as GeoTIFF files and vector data, with support for compression and efficient handling.
|
21
31
|
- **View Generators**:
|
@@ -28,7 +38,7 @@ Giga maps schools' Internet access in real time, creates models for innovative f
|
|
28
38
|
- Centralized configuration via environment variables or `.env` file
|
29
39
|
- Easy setup of API keys and paths
|
30
40
|
|
31
|
-
|
41
|
+
## Supported Datasets
|
32
42
|
|
33
43
|
The `gigaspatial` package supports data from the following providers:
|
34
44
|
|
@@ -38,7 +48,7 @@ The `gigaspatial` package supports data from the following providers:
|
|
38
48
|
|
39
49
|
---
|
40
50
|
|
41
|
-
|
51
|
+
## View Generators
|
42
52
|
|
43
53
|
The **view generators** in GigaSpatial are designed to enrich the spatial context of school locations and map data into grid or POI locations. This enables users to analyze and visualize geospatial data in meaningful ways.
|
44
54
|
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# Data Handler Examples
|
2
|
+
|
3
|
+
This guide provides examples of how to use various data handlers in GigaSpatial to access and process different types of spatial data.
|
4
|
+
|
5
|
+
## Population Data (WorldPop)
|
6
|
+
|
7
|
+
```python
|
8
|
+
from gigaspatial.handlers import WorldPopHandler
|
9
|
+
|
10
|
+
# Get population data for a specific country and year
|
11
|
+
config = {
|
12
|
+
"country_code": "KEN",
|
13
|
+
"year": 2020,
|
14
|
+
}
|
15
|
+
|
16
|
+
# Initialize the WorldPop handler
|
17
|
+
worldpop = WorldPopDownloader(config = config)
|
18
|
+
path_to_data = worldpop.download_dataset()
|
19
|
+
```
|
20
|
+
|
21
|
+
## Building Footprints
|
22
|
+
|
23
|
+
### Google Open Buildings
|
24
|
+
|
25
|
+
```python
|
26
|
+
from gigaspatial.handlers import GoogleOpenBuildingsHandler
|
27
|
+
from gigaspatial.generators import PoiViewGenerator
|
28
|
+
from gigaspatial.core.io import LocalDataStore
|
29
|
+
import geopandas as gpd
|
30
|
+
|
31
|
+
# Initialize data store and handlers
|
32
|
+
data_store = LocalDataStore()
|
33
|
+
gob_handler = GoogleOpenBuildingsHandler(data_store=data_store)
|
34
|
+
|
35
|
+
# Example 1: Load building data for a country
|
36
|
+
country_code = "KEN" # Kenya
|
37
|
+
polygons_gdf = gob_handler.load_polygons(country_code, ensure_available=True)
|
38
|
+
print(f"Loaded {len(polygons_gdf)} building polygons")
|
39
|
+
|
40
|
+
# Example 2: Load building data for specific points
|
41
|
+
points = [(36.8219, -1.2921), (36.8172, -1.2867)] # Nairobi coordinates
|
42
|
+
points_gdf = gob_handler.load_polygons(points, ensure_available=True)
|
43
|
+
print(f"Loaded {len(points_gdf)} building polygons for points")
|
44
|
+
|
45
|
+
# Example 3: Map nearest buildings to points using PoiViewGenerator
|
46
|
+
# Initialize POI view generator with points
|
47
|
+
poi_generator = PoiViewGenerator(points=points)
|
48
|
+
|
49
|
+
# Map nearest Google buildings to POIs
|
50
|
+
result_gdf = poi_generator.map_google_buildings(gob_handler)
|
51
|
+
print("\nPOIs with nearest building information:")
|
52
|
+
print(result_gdf[["poi_id", "nearest_google_building_id", "nearest_google_building_distance"]].head())
|
53
|
+
|
54
|
+
# Example 4: Save the enriched POI view
|
55
|
+
output_path = poi_generator.save_view("nairobi_buildings", output_format="geojson")
|
56
|
+
print(f"\nSaved enriched POI view to: {output_path}")
|
57
|
+
```
|
58
|
+
|
59
|
+
This example demonstrates:
|
60
|
+
1. Loading building data for a country or specific points
|
61
|
+
2. Using PoiViewGenerator to map nearest buildings to points of interest
|
62
|
+
3. Saving the enriched POI view with building information
|
63
|
+
|
64
|
+
The resulting GeoDataFrame includes:
|
65
|
+
- Original POI information
|
66
|
+
- Nearest building ID
|
67
|
+
- Distance to the nearest building
|
68
|
+
|
69
|
+
### Microsoft Global Buildings
|
70
|
+
|
71
|
+
```python
|
72
|
+
from gigaspatial.handlers import MSBuildingsDownloader
|
73
|
+
|
74
|
+
# Initialize the handler
|
75
|
+
mgb = MSBuildingsDownloader()
|
76
|
+
|
77
|
+
points = [(1.25214, 5.5124), (3.45234, 12.51232)]
|
78
|
+
|
79
|
+
# Get building footprints
|
80
|
+
list_of_paths = mgb.download(
|
81
|
+
points=points
|
82
|
+
)
|
83
|
+
```
|
84
|
+
|
85
|
+
## Satellite Imagery
|
86
|
+
|
87
|
+
### Maxar Imagery
|
88
|
+
|
89
|
+
```python
|
90
|
+
from gigaspatial.handlers import MaxarImageHandler
|
91
|
+
|
92
|
+
# Initialize woith default config which reads credentials config from your environment
|
93
|
+
maxar = MaxarImageDownloader()
|
94
|
+
|
95
|
+
# Download imagery
|
96
|
+
maxar.download_images_by_coordinates(
|
97
|
+
data=coordinates,
|
98
|
+
res_meters_pixel=0.6,
|
99
|
+
output_dir="bronze/maxar",
|
100
|
+
bbox_size = 300.0,
|
101
|
+
image_prefix = "maxar_"
|
102
|
+
)
|
103
|
+
|
104
|
+
```
|
105
|
+
|
106
|
+
### Mapbox Imagery
|
107
|
+
|
108
|
+
```python
|
109
|
+
from gigaspatial.handlers import MapboxImageDownloader
|
110
|
+
|
111
|
+
# Initialize with your access token or config will be read from your environment
|
112
|
+
mapbox = MapboxImageDownloader(access_token="your_access_token", style_id="mapbox/satellite-v9")
|
113
|
+
|
114
|
+
# Get satellite imagery
|
115
|
+
mapbox.download_images_by_coordinates(
|
116
|
+
data=coordinates,
|
117
|
+
res_meters_pixel=300.0,
|
118
|
+
output_dir="bronze/mapbox",
|
119
|
+
image_size=(256,256),
|
120
|
+
image_prefix="mapbox_"
|
121
|
+
)
|
122
|
+
```
|
123
|
+
|
124
|
+
## Internet Speed Data (Ookla)
|
125
|
+
|
126
|
+
```python
|
127
|
+
from gigaspatial.core.io import LocalDataStore
|
128
|
+
from gigaspatial.handlers import (
|
129
|
+
OoklaSpeedtestTileConfig, CountryOoklaTiles
|
130
|
+
)
|
131
|
+
|
132
|
+
# Initialize OoklaSpeedtestTileConfig for a specific quarter and year
|
133
|
+
ookla_config = OoklaSpeedtestTileConfig(
|
134
|
+
service_type="fixed", year=2023, quarter=3, data_store=LocalDataStore())
|
135
|
+
|
136
|
+
# Download and read the Ookla tile data
|
137
|
+
df = ookla_config.read_tile()
|
138
|
+
print(df.head()) # Display the first few rows of the dataset
|
139
|
+
|
140
|
+
# Generate country-specific Ookla tiles
|
141
|
+
country_ookla_tiles = CountryOoklaTiles.from_country("KEN", ookla_config)
|
142
|
+
|
143
|
+
# Convert to DataFrame and display
|
144
|
+
country_df = country_ookla_tiles.to_dataframe()
|
145
|
+
print(country_df.head())
|
146
|
+
|
147
|
+
# Convert to GeoDataFrame and display
|
148
|
+
country_gdf = country_ookla_tiles.to_geodataframe()
|
149
|
+
print(country_gdf.head())
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
## Administrative Boundaries
|
154
|
+
|
155
|
+
```python
|
156
|
+
from gigaspatial.handlers import AdminBoundaries
|
157
|
+
|
158
|
+
# Load level-1 administrative boundaries for Kenya
|
159
|
+
admin_boundaries = AdminBoundaries.create(country_code="KEN", admin_level=1)
|
160
|
+
|
161
|
+
# Convert to a GeoDataFrame
|
162
|
+
gdf = admin_boundaries.to_geodataframe()
|
163
|
+
```
|
164
|
+
|
165
|
+
|
166
|
+
## OpenStreetMap Data
|
167
|
+
|
168
|
+
```python
|
169
|
+
from gigaspatial.handlers.osm import OSMAmenityFetcher
|
170
|
+
|
171
|
+
# Example 1: Fetching school amenities in Kenya
|
172
|
+
fetcher = OSMAmenityFetcher(country_iso2="KE", amenity_types=["school"])
|
173
|
+
schools_df = fetcher.get_locations()
|
174
|
+
print(schools_df.head())
|
175
|
+
|
176
|
+
# Example 2: Fetching hospital and clinic amenities in Tanzania
|
177
|
+
fetcher = OSMAmenityFetcher(country_iso2="TZ", amenity_types=["hospital", "clinic"])
|
178
|
+
healthcare_df = fetcher.get_locations()
|
179
|
+
print(healthcare_df.head())
|
180
|
+
|
181
|
+
# Example 3: Fetching restaurant amenities in Ghana since 2020
|
182
|
+
fetcher = OSMAmenityFetcher(country_iso2="GH", amenity_types=["restaurant"])
|
183
|
+
restaurants_df = fetcher.get_locations(since_year=2020)
|
184
|
+
print(restaurants_df.head())
|
185
|
+
```
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Downloading and Processing GHSL Data
|
2
|
+
|
3
|
+
This example demonstrates how to download and process data from the Global Human Settlement Layer (GHSL) using the `GHSLDataHandler` class.
|
4
|
+
|
5
|
+
## Prerequisites
|
6
|
+
|
7
|
+
Ensure you have installed the `gigaspatial` package and set up the necessary configuration. Follow the [Installation Guide](../getting-started/installation.md) if you haven't already.
|
8
|
+
|
9
|
+
## Example Code
|
10
|
+
|
11
|
+
```python
|
12
|
+
from gigaspatial.handlers import GHSLDataHandler
|
13
|
+
|
14
|
+
# Initialize the handler with desired product and parameters
|
15
|
+
ghsl_handler = GHSLDataHandler(
|
16
|
+
product="GHS_BUILT_S", # Built-up surface
|
17
|
+
year=2020,
|
18
|
+
resolution=100, # 100m resolution
|
19
|
+
)
|
20
|
+
|
21
|
+
# Download and load data for a specific country
|
22
|
+
country_code = "TUR"
|
23
|
+
downloaded_files = ghsl_handler.load_data(country_code, ensure_available=True)
|
24
|
+
|
25
|
+
# Load the data into a DataFrame
|
26
|
+
df = ghsl_handler.load_into_dataframe(country_code, ensure_available=True)
|
27
|
+
print(df.head())
|
28
|
+
|
29
|
+
# You can also load data for specific points
|
30
|
+
points = [(38.404581, 27.4816677), (39.8915702, 32.7809618)] # Example coordinates
|
31
|
+
df_points = ghsl_handler.load_into_dataframe(points, ensure_available=True)
|
32
|
+
```
|
33
|
+
|
34
|
+
## Explanation
|
35
|
+
|
36
|
+
- **GHSLDataHandler**: This class provides a unified interface for downloading and processing GHSL data.
|
37
|
+
- **Available Products**:
|
38
|
+
- `GHS_BUILT_S`: Built-up surface
|
39
|
+
- `GHS_BUILT_H_AGBH`: Average building height
|
40
|
+
- `GHS_BUILT_H_ANBH`: Average number of building heights
|
41
|
+
- `GHS_BUILT_V`: Building volume
|
42
|
+
- `GHS_POP`: Population
|
43
|
+
- `GHS_SMOD`: Settlement model
|
44
|
+
- **Parameters**:
|
45
|
+
- `product`: The GHSL product to use
|
46
|
+
- `year`: The year of the data (default: 2020)
|
47
|
+
- `resolution`: The resolution in meters (default: 100)
|
48
|
+
- **Methods**:
|
49
|
+
- `load_data()`: Downloads and loads the data
|
50
|
+
- `load_into_dataframe()`: Loads the data into a pandas DataFrame
|
51
|
+
|
52
|
+
## Next Steps
|
53
|
+
|
54
|
+
Once the data is downloaded and processed, you can:
|
55
|
+
1. Store the data using the `DataStore` class
|
56
|
+
2. Visualize the data using `geopandas` and `matplotlib`
|
57
|
+
3. Process the data further using the [Processing Examples](../processing/tif.md)
|
58
|
+
|
59
|
+
---
|
60
|
+
|
61
|
+
[Back to Examples](../index.md)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Installation Guide
|
2
2
|
|
3
|
-
This guide will walk you through the steps to install the `gigaspatial` package on your system. The package is compatible with Python 3.
|
3
|
+
This guide will walk you through the steps to install the `gigaspatial` package on your system. The package is compatible with Python 3.10 and above.
|
4
4
|
|
5
5
|
## Prerequisites
|
6
6
|
|
@@ -12,27 +12,34 @@ python --version
|
|
12
12
|
|
13
13
|
If Python is not installed, you can download it from the [official Python website](https://www.python.org/downloads/).
|
14
14
|
|
15
|
-
## Installing
|
15
|
+
## Installing from PyPI
|
16
16
|
|
17
|
-
|
17
|
+
The easiest way to install `gigaspatial` is directly from PyPI using pip:
|
18
18
|
|
19
|
-
|
19
|
+
```bash
|
20
|
+
pip install giga-spatial
|
21
|
+
```
|
22
|
+
|
23
|
+
This will install the latest stable version of the package along with all its dependencies.
|
24
|
+
|
25
|
+
## Installing from Source
|
26
|
+
|
27
|
+
If you need to install a specific version or want to contribute to the development, you can install from the source:
|
28
|
+
|
29
|
+
1. **Clone the Repository**:
|
20
30
|
```bash
|
21
31
|
git clone https://github.com/unicef/giga-spatial.git
|
22
32
|
cd giga-spatial
|
23
33
|
```
|
24
34
|
|
25
35
|
2. **Install the Package**:
|
26
|
-
Run the following command in your terminal to install the package:
|
27
36
|
```bash
|
28
37
|
pip install .
|
29
38
|
```
|
30
39
|
|
31
|
-
|
32
|
-
|
33
|
-
## Installing in Development Mode
|
40
|
+
### Installing in Development Mode
|
34
41
|
|
35
|
-
If you plan to contribute to the package or modify the source code, you can install it in development mode. This allows you to make changes to the code without reinstalling the package
|
42
|
+
If you plan to contribute to the package or modify the source code, you can install it in development mode. This allows you to make changes to the code without reinstalling the package:
|
36
43
|
|
37
44
|
```bash
|
38
45
|
pip install -e .
|
@@ -71,7 +78,7 @@ If you encounter any issues during installation, consider the following:
|
|
71
78
|
```bash
|
72
79
|
python -m venv venv
|
73
80
|
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
|
74
|
-
pip install .
|
81
|
+
pip install giga-spatial # or pip install . if installing from source
|
75
82
|
```
|
76
83
|
|
77
84
|
---
|
@@ -54,39 +54,57 @@ config.set_path("views", "/path/to/your/views_data")
|
|
54
54
|
|
55
55
|
API keys and tokens should be set through environment variables.
|
56
56
|
|
57
|
-
## Downloading Geospatial Data
|
57
|
+
## Downloading and Processing Geospatial Data
|
58
58
|
|
59
|
-
|
59
|
+
The `gigaspatial` package provides several handlers for different types of geospatial data. Here are examples for two commonly used handlers:
|
60
|
+
|
61
|
+
### GHSL (Global Human Settlement Layer) Data
|
62
|
+
|
63
|
+
The `GHSLDataHandler` provides access to various GHSL products including built-up surface, building height, population, and settlement model data:
|
60
64
|
|
61
65
|
```python
|
62
|
-
from gigaspatial.handlers
|
66
|
+
from gigaspatial.handlers import GHSLDataHandler
|
63
67
|
|
64
|
-
# Initialize the
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
})
|
68
|
+
# Initialize the handler with desired product and parameters
|
69
|
+
ghsl_handler = GHSLDataHandler(
|
70
|
+
product="GHS_BUILT_S", # Built-up surface
|
71
|
+
year=2020,
|
72
|
+
resolution=100, # 100m resolution
|
73
|
+
)
|
71
74
|
|
72
75
|
# Download data for a specific country
|
73
|
-
country_code = "TUR"
|
74
|
-
|
76
|
+
country_code = "TUR"
|
77
|
+
downloaded_files = ghsl_handler.load_data(country_code, ensure_available = True)
|
78
|
+
|
79
|
+
# Load the data into a DataFrame
|
80
|
+
df = ghsl_handler.load_into_dataframe(country_code, ensure_available = True)
|
81
|
+
print(df.head())
|
82
|
+
|
83
|
+
# You can also load data for specific points or geometries
|
84
|
+
points = [(38.404581,27.4816677), (39.8915702, 32.7809618)]
|
85
|
+
df_points = ghsl_handler.load_into_dataframe(points, ensure_available = True)
|
75
86
|
```
|
76
87
|
|
77
|
-
|
88
|
+
### Google Open Buildings Data
|
78
89
|
|
79
|
-
|
90
|
+
The `GoogleOpenBuildingsHandler` provides access to Google's Open Buildings dataset, which includes building footprints and points:
|
80
91
|
|
81
92
|
```python
|
82
|
-
from gigaspatial.
|
93
|
+
from gigaspatial.handlers import GoogleOpenBuildingsHandler
|
83
94
|
|
84
|
-
# Initialize the
|
85
|
-
|
95
|
+
# Initialize the handler
|
96
|
+
gob_handler = GoogleOpenBuildingsHandler()
|
86
97
|
|
87
|
-
#
|
88
|
-
|
89
|
-
|
98
|
+
# Download and load building polygons for a country
|
99
|
+
country_code = "TUR"
|
100
|
+
polygons_gdf = gob_handler.load_polygons(country_code, ensure_available = True)
|
101
|
+
|
102
|
+
# Download and load building points for a country
|
103
|
+
points_gdf = gob_handler.load_points(country_code, ensure_available = True)
|
104
|
+
|
105
|
+
# You can also load data for specific points or geometries
|
106
|
+
points = [(38.404581, 27.4816677), (39.8915702, 32.7809618)]
|
107
|
+
polygons_gdf = gob_handler.load_polygons(points, ensure_available = True)
|
90
108
|
```
|
91
109
|
|
92
110
|
## Storing Geospatial Data
|
@@ -94,7 +112,7 @@ print(processed_data.head())
|
|
94
112
|
You can store the processed data in various formats using the `DataStore` class from the `core.io` module. Here's an example of saving data to a parquet file:
|
95
113
|
|
96
114
|
```python
|
97
|
-
from gigaspatial.core.io
|
115
|
+
from gigaspatial.core.io import LocalDataStore
|
98
116
|
|
99
117
|
# Initialize the data store
|
100
118
|
data_store = LocalDataStore()
|
@@ -113,7 +131,6 @@ from gigaspatial.core.io.writers import write_dataset
|
|
113
131
|
write_dataset(data=processed_data, data_store=data_store, path="/path/to/your/output/processed_data.geojson")
|
114
132
|
```
|
115
133
|
|
116
|
-
|
117
134
|
## Visualizing Geospatial Data
|
118
135
|
|
119
136
|
To visualize the geospatial data, you can use libraries like `geopandas` and `matplotlib`. Here's an example of plotting the processed data on a map:
|