giga-spatial 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: giga-spatial
3
- Version: 0.6.0
3
+ Version: 0.6.2
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,32 +51,35 @@ Dynamic: summary
51
51
 
52
52
  # GigaSpatial
53
53
 
54
- # ![GigaSpatial logo](https://github.com/unicef/giga-spatial/blob/main/docs/assets/logo.png)
54
+ # ![GigaSpatial logo](https://raw.githubusercontent.com/unicef/giga-spatial/main/docs/assets/logo.png)
55
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.
56
+ Giga maps schools' Internet access in real time, creates models for innovative financing, and supports governments contracting for connectivity.
57
57
 
58
58
  ---
59
59
 
60
60
  ## About GigaSpatial
61
61
 
62
- **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) and the Global Human Settlement Layer (GHSL). The package is designed to support Giga's mission by providing robust geospatial capabilities for mapping and analyzing school connectivity.
62
+ **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
63
 
64
64
  ### Key Features
65
- - **Data Downloading**: Download geospatial data from various sources.
66
- - **Data Processing**: Process and transform geospatial data, such as GeoTIFF files and vector data.
67
- - **View Generators**: Enrich the spatial context and map data into grid or POI (Point of Interest) locations.
65
+ - **Data Downloading**: Download geospatial data from various sources including GHSL, Microsoft Global Buildings, Google Open Buildings, OpenCellID, and HDX datasets.
66
+ - **Data Processing**: Process and transform geospatial data, such as GeoTIFF files and vector data, with support for compression and efficient handling.
67
+ - **View Generators**:
68
+ - Enrich spatial context with POI (Point of Interest) data
69
+ - Support for raster point sampling and zonal statistics
70
+ - Area-weighted aggregation for polygon-based statistics
68
71
  - **Grid System**: Create and manipulate grid-based geospatial data for analysis and modeling.
69
- - **Data Storage**: Store and retrieve geospatial data in various formats.
70
- - **Configuration Management**: Easily configure paths, API keys, and other settings using environment variables or manual setup.
72
+ - **Data Storage**: Flexible storage options with both local and cloud (ADLS) support.
73
+ - **Configuration Management**:
74
+ - Centralized configuration via environment variables or `.env` file
75
+ - Easy setup of API keys and paths
71
76
 
72
- ---
73
-
74
- ## Supported Datasets
77
+ ### Supported Datasets
75
78
 
76
79
  The `gigaspatial` package supports data from the following providers:
77
80
 
78
81
  <div align="center">
79
- <img src="https://github.com/unicef/giga-spatial/blob/main/docs/assets/datasets.png" alt="Dataset Providers" style="width: 70%; height: auto;"/>
82
+ <img src="https://raw.githubusercontent.com/unicef/giga-spatial/main/docs/assets/datasets.png" alt="Dataset Providers" style="width: 75%; height: auto;"/>
80
83
  </div>
81
84
 
82
85
  ---
@@ -87,20 +90,28 @@ The **view generators** in GigaSpatial are designed to enrich the spatial contex
87
90
 
88
91
  ### Key Capabilities
89
92
  1. **Spatial Context Enrichment**:
90
- - Automatic attribution of geospatial variables to school locations.
91
- - Contextual layers for environmental, infrastructural, and socioeconomic factors.
92
- - Multi-resolution data availability for different analytical needs.
93
+ - Automatic attribution of geospatial variables to school locations
94
+ - Contextual layers for environmental, infrastructural, and socioeconomic factors
95
+ - Multi-resolution data availability for different analytical needs
96
+ - Support for both point and polygon-based enrichment
93
97
 
94
98
  2. **Mapping to Grid or POI Locations**:
95
- - Map geospatial data to grid cells for scalable analysis.
96
- - Map data to POI locations for detailed, location-specific insights.
99
+ - Map geospatial data to grid cells for scalable analysis
100
+ - Map data to POI locations for detailed, location-specific insights
101
+ - Support for chained enrichment using multiple datasets
102
+ - Built-in support for administrative boundary annotations
97
103
 
98
104
  ---
99
105
 
100
106
  ## Why Use GigaSpatial?
101
- - **Efficient Geospatial Handling**: Streamline the process of downloading, processing, and analyzing geospatial data.
102
- - **Scalable Analysis**: Map data to grid cells or POI locations for both scalable and detailed insights.
103
- - **Open Source**: Contribute to and benefit from a collaborative, transparent, and innovative geospatial toolset.
107
+ - **Efficient Geospatial Handling**: Streamline the process of downloading, processing, and analyzing geospatial data
108
+ - **Scalable Analysis**: Map data to grid cells or POI locations for both scalable and detailed insights
109
+ - **Open Source**: Contribute to and benefit from a collaborative, transparent, and innovative geospatial toolset
110
+ - **Modern Architecture**: Built with maintainability and extensibility in mind, featuring:
111
+ - Base handler orchestration for unified lifecycle management
112
+ - Dedicated reader classes for major datasets
113
+ - Modular source resolution for flexible data access
114
+ - Comprehensive error handling and logging
104
115
 
105
116
  ## Why Open Source?
106
117
 
@@ -1,6 +1,6 @@
1
- giga_spatial-0.6.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
2
- gigaspatial/__init__.py,sha256=cID1jLnC_vj48GgMN6Yb1FA3JsQ95zNmCHmRYE8TFhY,22
3
- gigaspatial/config.py,sha256=UC8vjlVUaVaCz_fSu0l3_4O6SOllnkapcpayFvE3TYs,7969
1
+ giga_spatial-0.6.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
2
+ gigaspatial/__init__.py,sha256=jFlbxEJFS0G44LE-yXXVSwXACA1J_NyYDk5E20_2zpc,22
3
+ gigaspatial/config.py,sha256=yMf1ofOU0_I6iKDqshiFSYmK6TDIVpPm1AZo4e2okHU,8166
4
4
  gigaspatial/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  gigaspatial/core/io/__init__.py,sha256=y4QNWx6US1-adTuAO_NZwLmjzSQj25HNDL5hUGvEHZc,263
6
6
  gigaspatial/core/io/adls_data_store.py,sha256=Zv-D_8d_2h57HnCUTJb0JWWjXqR_0XH4F8Nu_UFZK9E,11975
@@ -21,8 +21,8 @@ gigaspatial/grid/__init__.py,sha256=H8SnNAMDafJXJ9bUp2zU0Z3t6s8niqY5rGP5nFhnbLA,
21
21
  gigaspatial/grid/mercator_tiles.py,sha256=Z_3M4sy1tyxywAo2wmBb6niBP3x-IWgwMkmUp8LOSDg,10492
22
22
  gigaspatial/handlers/__init__.py,sha256=gh6LIzqr2fASX4fEzQ20v1j_IhnYpym-lcgOkAGHrdE,1430
23
23
  gigaspatial/handlers/base.py,sha256=rL94c3wDjsqzLp4na8FfYXW6tNjVGX6v4M-Ce4LrAro,26413
24
- gigaspatial/handlers/boundaries.py,sha256=184Ytmf3eBWR-BKcuAUDSg8MJSrcPw0L17qLIkUwxHI,11071
25
- gigaspatial/handlers/ghsl.py,sha256=EgFbrqh9Sb86dx4LlOXU804zi-yRCUqqSZWmmvxkRuU,27747
24
+ gigaspatial/handlers/boundaries.py,sha256=hoO-b5MlFYwlCWogApcFyEx6OnxMJG29lqJurNGwOWg,11260
25
+ gigaspatial/handlers/ghsl.py,sha256=YTXuhjSjNMl11nmgd6ZOtVMsJGg2PxDcZn4pu8aaypc,27749
26
26
  gigaspatial/handlers/giga.py,sha256=2aP1EenDAQXn-h-uCyuVxEVZvAFEvrL17_z0MiS8FDs,4867
27
27
  gigaspatial/handlers/google_open_buildings.py,sha256=Liqk7qJhDtB4Ia4uhBe44LFcf-XVKBjRfj-pWlE5erY,16594
28
28
  gigaspatial/handlers/hdx.py,sha256=8VAEHfO8UgvEx6_Xdx0_vNsPqO18z5Iiq6TjuEbg05k,8789
@@ -41,7 +41,7 @@ gigaspatial/processing/geo.py,sha256=D-S3IlhQwLIxrCcxy6NhNmKLrOIjoRHfK_eZJGKpe2U
41
41
  gigaspatial/processing/sat_images.py,sha256=YUbH5MFNzl6NX49Obk14WaFcr1s3SyGJIOk-kRpbBNg,1429
42
42
  gigaspatial/processing/tif_processor.py,sha256=4qCNx6ODtVsYm6lbSToIdUCrduIrPsWFBAABTQ2Vs24,17259
43
43
  gigaspatial/processing/utils.py,sha256=HC85vGKQakxlkoQAkZmeAXWHsenAwTIRn7jPKUA7x20,1500
44
- giga_spatial-0.6.0.dist-info/METADATA,sha256=aiay3xH1NKvaG4NlKw_IYoES1jNnNZk1P_5mxXjr2uY,6297
45
- giga_spatial-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- giga_spatial-0.6.0.dist-info/top_level.txt,sha256=LZsccgw6H4zXT7m6Y4XChm-Y5LjHAwZ2hkGN_B3ExmI,12
47
- giga_spatial-0.6.0.dist-info/RECORD,,
44
+ giga_spatial-0.6.2.dist-info/METADATA,sha256=PXfUtURxAxnej1IDhF3MGbOOdC8MYgsGtRHHTiPjQSQ,7104
45
+ giga_spatial-0.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
+ giga_spatial-0.6.2.dist-info/top_level.txt,sha256=LZsccgw6H4zXT7m6Y4XChm-Y5LjHAwZ2hkGN_B3ExmI,12
47
+ giga_spatial-0.6.2.dist-info/RECORD,,
gigaspatial/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.0"
1
+ __version__ = "0.6.2"
gigaspatial/config.py CHANGED
@@ -33,6 +33,12 @@ class Config(BaseSettings):
33
33
  default="", alias="GIGA_SCHOOL_LOCATION_API_KEY"
34
34
  )
35
35
 
36
+ ROOT_DATA_DIR: Path = Field(
37
+ default=Path("."),
38
+ description="Root directory for all data tiers",
39
+ alias="ROOT_DATA_DIR",
40
+ )
41
+
36
42
  BRONZE_DATA_DIR: Path = Field(
37
43
  default=Path("bronze"),
38
44
  description="Root directory for raw/bronze tier data",
@@ -129,12 +135,12 @@ class Config(BaseSettings):
129
135
  f"Invalid tier: {tier}. Must be one of 'bronze', 'silver', 'gold', or 'views'."
130
136
  )
131
137
 
132
- base_dir = getattr(self, f"{tier.upper()}_DATA_DIR")
138
+ tier_dir = getattr(self, f"{tier.upper()}_DATA_DIR")
133
139
  type_dir = self.DATA_TYPES[data_type]
134
140
  if version:
135
- return base_dir / type_dir / version
141
+ return self.ROOT_DATA_DIR / tier_dir / type_dir / version
136
142
  else:
137
- return base_dir / type_dir
143
+ return self.ROOT_DATA_DIR / tier_dir / type_dir
138
144
 
139
145
  def get_admin_path(
140
146
  self,
@@ -230,19 +230,22 @@ class AdminBoundaries(BaseModel):
230
230
  elif country_code is not None:
231
231
  from gigaspatial.handlers.unicef_georepo import GeoRepoClient
232
232
 
233
- client = GeoRepoClient()
234
-
235
- if client.check_connection():
236
- cls.logger.info("GeoRepo connection successful.")
237
- return cls.from_georepo(
238
- iso3_code,
239
- admin_level=admin_level,
240
- )
241
- else:
233
+ try:
234
+ client = GeoRepoClient()
235
+ if client.check_connection():
236
+ cls.logger.info("GeoRepo connection successful.")
237
+ return cls.from_georepo(
238
+ iso3_code,
239
+ admin_level=admin_level,
240
+ )
241
+ except ValueError as e:
242
242
  cls.logger.warning(
243
- "GeoRepo connection check failed. Falling back to GADM."
243
+ f"GeoRepo initialization failed: {str(e)}. Falling back to GADM."
244
244
  )
245
- return cls.from_gadm(iso3_code, admin_level, **kwargs)
245
+ except Exception as e:
246
+ cls.logger.warning(f"GeoRepo error: {str(e)}. Falling back to GADM.")
247
+
248
+ return cls.from_gadm(iso3_code, admin_level, **kwargs)
246
249
  else:
247
250
  raise ValueError(
248
251
  "Either country_code or (data_store, path) must be provided."
@@ -74,7 +74,7 @@ class GHSLDataConfig(BaseHandlerConfig):
74
74
 
75
75
  def __post_init__(self):
76
76
  super().__post_init__()
77
- self.TILES_URL = self.TILES_URL.format(self.coord_system)
77
+ self.TILES_URL = self.TILES_URL.format(self.coord_system.value)
78
78
  self._load_tiles()
79
79
 
80
80
  def _load_tiles(self):
@@ -375,10 +375,9 @@ class GHSLDataDownloader(BaseHandlerDownloader):
375
375
 
376
376
  for file in files_to_extract:
377
377
  extracted_path = output_path.parent / Path(file).name
378
- with zip_ref.open(file) as source, open(
379
- extracted_path, "wb"
380
- ) as target:
381
- shutil.copyfileobj(source, target)
378
+ with zip_ref.open(file) as source:
379
+ file_content = source.read()
380
+ self.data_store.write_file(str(extracted_path), file_content)
382
381
  extracted_files.append(extracted_path)
383
382
  self.logger.info(f"Extracted {file} to {extracted_path}")
384
383