Handlers Module¶
gigaspatial.handlers
¶
boundaries
¶
AdminBoundaries
¶
Bases: BaseModel
Base class for administrative boundary data with flexible fields.
Source code in gigaspatial/handlers/boundaries.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
create(country_code=None, admin_level=0, data_store=None, path=None, **kwargs)
classmethod
¶
Factory method to create AdminBoundaries instance from either GADM or data store.
Source code in gigaspatial/handlers/boundaries.py
from_data_store(data_store, path, admin_level=0, **kwargs)
classmethod
¶
Load and create instance from internal data store.
Source code in gigaspatial/handlers/boundaries.py
from_gadm(country_code, admin_level=0, **kwargs)
classmethod
¶
Load and create instance from GADM data.
Source code in gigaspatial/handlers/boundaries.py
get_schema_config()
classmethod
¶
to_geodataframe()
¶
Convert the AdminBoundaries to a GeoDataFrame.
Source code in gigaspatial/handlers/boundaries.py
AdminBoundary
¶
Bases: BaseModel
Base class for administrative boundary data with flexible fields.
Source code in gigaspatial/handlers/boundaries.py
ghsl
¶
CoordSystem
¶
GHSLDataConfig
¶
Source code in gigaspatial/handlers/ghsl.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
__repr__()
¶
Return a string representation of the GHSL dataset configuration.
Source code in gigaspatial/handlers/ghsl.py
compute_dataset_url(tile_id=None)
¶
Compute the download URL for a GHSL dataset.
Source code in gigaspatial/handlers/ghsl.py
get_intersecting_tiles(geometry, crs=4326)
¶
Find all GHSL tiles that intersect with the provided geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry | Union[Polygon, MultiPolygon, GeoDataFrame] | A geometry or GeoDataFrame to check for intersection with GHSL tiles | required |
crs | Coordinate reference system of the given geometry | 4326 |
Returns:
Type | Description |
---|---|
List[str] | List of URLs for GHSL dataset tiles that intersect with the geometry |
Source code in gigaspatial/handlers/ghsl.py
get_tile_path(tile_id=None)
¶
Construct and return the path for the configured dataset.
Source code in gigaspatial/handlers/ghsl.py
validate_configuration()
¶
Validate that the configuration is valid based on dataset availability constraints.
Specific rules:¶
Source code in gigaspatial/handlers/ghsl.py
GHSLDataDownloader
¶
A class to handle downloads of WorldPop datasets.
Source code in gigaspatial/handlers/ghsl.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
|
__init__(config, data_store=None, logger=None)
¶
Initialize the downloader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Union[GHSLDataConfig, dict[str, Union[str, int]]] | Configuration for the GHSL dataset, either as a GHSLDataConfig object or a dictionary of parameters | required |
data_store | Optional[DataStore] | Optional data storage interface. If not provided, uses LocalDataStore. | None |
logger | Optional[Logger] | Optional custom logger. If not provided, uses default logger. | None |
Source code in gigaspatial/handlers/ghsl.py
download_and_extract_tile(tile_id, file_pattern=None)
¶
Download and extract specific files from GHSL dataset tile zip archives.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_id | tile ID to download and extract | required | |
file_pattern | Optional regex pattern to filter which files to extract (e.g., '.*.tif$' for only TIF files) | None |
Returns:
Type | Description |
---|---|
path to extracted files |
Source code in gigaspatial/handlers/ghsl.py
download_by_country(country, data_store=None, country_geom_path=None, extract=False)
¶
Download GHSL data for a specific country.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country | str | ISO 3166-1 alpha-3 country code, ISO alpha-2 country code or country name | required |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/ghsl.py
download_by_points(points_gdf, extract=False)
¶
Download GHSL data for areas containing specific points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points_gdf | GeoDataFrame | GeoDataFrame containing points of interest | required |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/ghsl.py
google_open_buildings
¶
GoogleOpenBuildingsConfig
dataclass
¶
Configuration for Google Open Buildings dataset files.
Source code in gigaspatial/handlers/google_open_buildings.py
get_tile_path(tile_id, data_type)
¶
Construct the full path for a tile file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_id | str | S2 tile identifier | required |
data_type | Literal['polygons', 'points'] | Type of building data ('polygons' or 'points') | required |
Returns:
Type | Description |
---|---|
Path | Full path to the tile file |
Source code in gigaspatial/handlers/google_open_buildings.py
GoogleOpenBuildingsDownloader
¶
A class to handle downloads of Google's Open Buildings dataset.
Source code in gigaspatial/handlers/google_open_buildings.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
__init__(config=None, data_store=None, logger=None)
¶
Initialize the downloader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Optional[GoogleOpenBuildingsConfig] | Optional configuration for file paths | None |
data_store | Optional[DataStore] | Instance of DataStore for accessing data storage | None |
logger | Optional[Logger] | Optional custom logger. If not provided, uses default logger. | None |
Source code in gigaspatial/handlers/google_open_buildings.py
download_by_country(country_code, data_type='polygons', data_store=None, country_geom_path=None)
¶
Download Google Open Buildings data for a specific country.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country_code | str | ISO 3166-1 alpha-3 country code | required |
data_type | Literal['polygons', 'points'] | Type of data to download ('polygons' or 'points') | 'polygons' |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/google_open_buildings.py
download_by_points(points_gdf, data_type='polygons')
¶
Download Google Open Buildings data for areas containing specific points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points_gdf | GeoDataFrame | GeoDataFrame containing points of interest | required |
data_type | Literal['polygons', 'points'] | Type of data to download ('polygons' or 'points') | 'polygons' |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/google_open_buildings.py
get_download_size_estimate(geometry)
¶
Estimate the download size in MB for a given geometry or GeoDataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry | Union[Polygon, MultiPolygon, GeoDataFrame] | Shapely Polygon/MultiPolygon or GeoDataFrame with geometries | required |
Returns:
Type | Description |
---|---|
float | Estimated size in megabytes |
Source code in gigaspatial/handlers/google_open_buildings.py
mapbox_image
¶
MapboxImageDownloader
¶
Class to download images from Mapbox Static Images API using a specific style
Source code in gigaspatial/handlers/mapbox_image.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
__init__(access_token=config.MAPBOX_ACCESS_TOKEN, style_id=None, data_store=None)
¶
Initialize the downloader with Mapbox credentials
Parameters:
Name | Type | Description | Default |
---|---|---|---|
access_token | str | Mapbox access token | MAPBOX_ACCESS_TOKEN |
style_id | Optional[str] | Mapbox style ID to use for image download | None |
data_store | Optional[DataStore] | Instance of DataStore for accessing data storage | None |
Source code in gigaspatial/handlers/mapbox_image.py
download_images_by_bounds(gdf, output_dir, image_size=(512, 512), max_workers=4, image_prefix='image_')
¶
Download images for given points using the specified style
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf_points | GeoDataFrame containing bounding box polygons | required | |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
max_workers | int | Maximum number of concurrent downloads | 4 |
image_prefix | str | Prefix for output image names | 'image_' |
Source code in gigaspatial/handlers/mapbox_image.py
download_images_by_coordinates(data, res_meters_pixel, output_dir, image_size=(512, 512), max_workers=4, image_prefix='image_')
¶
Download images for given coordinates by creating bounded boxes around points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | Union[DataFrame, List[Tuple[float, float]]] | Either a DataFrame with either latitude/longitude columns or a geometry column or a list of (lat, lon) tuples | required |
res_meters_pixel | float | Size of the bounding box in meters (creates a square) | required |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
max_workers | int | Maximum number of concurrent downloads | 4 |
image_prefix | str | Prefix for output image names | 'image_' |
Source code in gigaspatial/handlers/mapbox_image.py
download_images_by_tiles(mercator_tiles, output_dir, image_size=(512, 512), max_workers=4, image_prefix='image_')
¶
Download images for given mercator tiles using the specified style
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mercator_tiles | MercatorTiles | MercatorTiles instance containing quadkeys | required |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
max_workers | int | Maximum number of concurrent downloads | 4 |
image_prefix | str | Prefix for output image names | 'image_' |
Source code in gigaspatial/handlers/mapbox_image.py
maxar_image
¶
MaxarConfig
¶
Bases: BaseModel
Configuration for Maxar Image Downloader using Pydantic
Source code in gigaspatial/handlers/maxar_image.py
wms_url: str
property
¶
Generate the full WMS URL with connection string
validate_non_empty(value, field)
classmethod
¶
Ensure required credentials are provided
Source code in gigaspatial/handlers/maxar_image.py
MaxarImageDownloader
¶
Class to download images from Maxar
Source code in gigaspatial/handlers/maxar_image.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
__init__(config=None, data_store=None)
¶
Initialize the downloader with Maxar config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Optional[MaxarConfig] | MaxarConfig instance containing credentials and settings | None |
data_store | Optional[DataStore] | Instance of DataStore for accessing data storage | None |
Source code in gigaspatial/handlers/maxar_image.py
download_images_by_bounds(gdf, output_dir, image_size=(512, 512), image_prefix='maxar_image_')
¶
Download images for given points using the specified style
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf_points | GeoDataFrame containing bounding box polygons | required | |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
image_prefix | str | Prefix for output image names | 'maxar_image_' |
Source code in gigaspatial/handlers/maxar_image.py
download_images_by_coordinates(data, res_meters_pixel, output_dir, image_size=(512, 512), image_prefix='maxar_image_')
¶
Download images for given coordinates by creating bounded boxes around points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | Union[DataFrame, List[Tuple[float, float]]] | Either a DataFrame with either latitude/longitude columns or a geometry column or a list of (lat, lon) tuples | required |
res_meters_pixel | float | resolution in meters per pixel | required |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
image_prefix | str | Prefix for output image names | 'maxar_image_' |
Source code in gigaspatial/handlers/maxar_image.py
download_images_by_tiles(mercator_tiles, output_dir, image_size=(512, 512), image_prefix='maxar_image_')
¶
Download images for given mercator tiles using the specified style
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mercator_tiles | MercatorTiles | MercatorTiles instance containing quadkeys | required |
output_dir | Union[str, Path] | Directory to save images | required |
image_size | Tuple[int, int] | Tuple of (width, height) for output images | (512, 512) |
image_prefix | str | Prefix for output image names | 'maxar_image_' |
Source code in gigaspatial/handlers/maxar_image.py
microsoft_global_buildings
¶
MSBuildingsConfig
¶
Configuration for Microsoft Global Buildings dataset files.
Source code in gigaspatial/handlers/microsoft_global_buildings.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
__post_init__()
¶
Validate inputs and set location mapping
Source code in gigaspatial/handlers/microsoft_global_buildings.py
MSBuildingsDownloader
¶
A class to handle downloads of Microsoft's Global ML Building Footprints dataset.
Source code in gigaspatial/handlers/microsoft_global_buildings.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
__init__(config=None, data_store=None, logger=None)
¶
Initialize the downloader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Optional[MSBuildingsConfig] | Optional configuration for customizing file paths. | None |
logger | Optional[Logger] | Optional custom logger. If not provided, uses default logger. | None |
Source code in gigaspatial/handlers/microsoft_global_buildings.py
download_by_country(country_code)
¶
Download Microsoft Global ML Building Footprints data for a specific country.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country_code | str | ISO 3166-1 alpha-3 country code | required |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/microsoft_global_buildings.py
download_by_geometry(geometry)
¶
Download Microsoft Global ML Building Footprints data for a specific geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry | Union[Polygon, MultiPolygon] | Polygon or MultiPolygon geometry | required |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/microsoft_global_buildings.py
download_by_points(points)
¶
Download Microsoft Global ML Building Footprints data for areas containing specific points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points_gdf | GeoDataFrame containing points of interest | required |
Returns:
Type | Description |
---|---|
List[str] | List of paths to downloaded files |
Source code in gigaspatial/handlers/microsoft_global_buildings.py
read_dataset(data_store, path, compression=None, **kwargs)
¶
Read data from various file formats stored in both local and cloud-based storage.
Parameters:¶
data_store : DataStore Instance of DataStore for accessing data storage. path : str, Path Path to the file in data storage. **kwargs : dict Additional arguments passed to the specific reader function.
Returns:¶
pandas.DataFrame or geopandas.GeoDataFrame The data read from the file.
Raises:¶
FileNotFoundError If the file doesn't exist in blob storage. ValueError If the file type is unsupported or if there's an error reading the file.
Source code in gigaspatial/core/io/readers.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
read_datasets(data_store, paths, **kwargs)
¶
Read multiple datasets from data storage at once.
Parameters:¶
data_store : DataStore Instance of DataStore for accessing data storage. paths : list of str Paths to files in data storage. **kwargs : dict Additional arguments passed to read_dataset.
Returns:¶
dict Dictionary mapping paths to their corresponding DataFrames/GeoDataFrames.
Source code in gigaspatial/core/io/readers.py
read_gzipped_json_or_csv(file_path, data_store)
¶
Reads a gzipped file, attempting to parse it as JSON (lines=True) or CSV.
Source code in gigaspatial/core/io/readers.py
read_kmz(file_obj, **kwargs)
¶
Helper function to read KMZ files and return a GeoDataFrame.
Source code in gigaspatial/core/io/readers.py
write_dataset(data, data_store, path, **kwargs)
¶
Write DataFrame or GeoDataFrame to various file formats in Azure Blob Storage.
Parameters:¶
data : pandas.DataFrame or geopandas.GeoDataFrame The data to write to blob storage. data_store : DataStore Instance of DataStore for accessing data storage. path : str Path where the file will be written in data storage. **kwargs : dict Additional arguments passed to the specific writer function.
Raises:¶
ValueError If the file type is unsupported or if there's an error writing the file. TypeError If input data is not a DataFrame or GeoDataFrame.
Source code in gigaspatial/core/io/writers.py
write_datasets(data_dict, data_store, **kwargs)
¶
Write multiple datasets to data storage at once.
Parameters:¶
data_dict : dict Dictionary mapping paths to DataFrames/GeoDataFrames. data_store : DataStore Instance of DataStore for accessing data storage. **kwargs : dict Additional arguments passed to write_dataset.
Raises:¶
ValueError If there are any errors writing the datasets.
Source code in gigaspatial/core/io/writers.py
osm
¶
OSMLocationFetcher
dataclass
¶
A class to fetch and process location data from OpenStreetMap using the Overpass API.
This class supports fetching various OSM location types including amenities, buildings, shops, and other POI categories.
Source code in gigaspatial/handlers/osm.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
__post_init__()
¶
Validate inputs, normalize location_types, and set up logging.
Source code in gigaspatial/handlers/osm.py
fetch_locations(since_year=None, handle_duplicates='separate')
¶
Fetch and process OSM locations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
since_year | int | Filter for locations added/modified since this year. | None |
handle_duplicates | str | How to handle objects matching multiple categories: - 'separate': Create separate entries for each category (default) - 'combine': Use a single entry with a list of matching categories - 'primary': Keep only the first matching category | 'separate' |
Returns:
Type | Description |
---|---|
DataFrame | pd.DataFrame: Processed OSM locations |
Source code in gigaspatial/handlers/osm.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
overture
¶
OvertureAmenityFetcher
¶
A class to fetch and process amenity locations from OpenStreetMap using the Overpass API.
Source code in gigaspatial/handlers/overture.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
__post_init__()
¶
Validate inputs and set up logging.
Source code in gigaspatial/handlers/overture.py
fetch_locations(match_pattern=False, **kwargs)
¶
Fetch and process amenity locations.
Source code in gigaspatial/handlers/overture.py
worldpop
¶
WorldPopConfig
¶
Bases: BaseModel
Source code in gigaspatial/handlers/worldpop.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
dataset_path: Path
property
¶
Construct and return the path for the configured dataset.
dataset_url: str
property
¶
Get the URL for the configured dataset. The URL is computed on first access and then cached for subsequent calls.
validate_configuration()
¶
Validate that the configuration is valid based on dataset availability constraints.
Specific rules: - Post-2020 data is only available at 1km resolution with UN adjustment - School age population data is only available for 2020 at 1km resolution
Source code in gigaspatial/handlers/worldpop.py
WorldPopDownloader
¶
A class to handle downloads of WorldPop datasets.
Source code in gigaspatial/handlers/worldpop.py
__init__(config, data_store=None, logger=None)
¶
Initialize the downloader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Union[WorldPopConfig, dict[str, Union[str, int]]] | Configuration for the WorldPop dataset, either as a WorldPopConfig object or a dictionary of parameters | required |
data_store | Optional[DataStore] | Optional data storage interface. If not provided, uses LocalDataStore. | None |
logger | Optional[Logger] | Optional custom logger. If not provided, uses default logger. | None |
Source code in gigaspatial/handlers/worldpop.py
download_dataset()
¶
Download the configured dataset to the provided output path.
Source code in gigaspatial/handlers/worldpop.py
from_country_year(country, year, **kwargs)
classmethod
¶
Create a downloader instance from country and year.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country | str | Country code or name | required |
year | int | Year of the dataset | required |
**kwargs | Additional parameters for WorldPopConfig or the downloader | {} |
Source code in gigaspatial/handlers/worldpop.py
read_dataset(data_store, path, compression=None, **kwargs)
¶
Read data from various file formats stored in both local and cloud-based storage.
Parameters:¶
data_store : DataStore Instance of DataStore for accessing data storage. path : str, Path Path to the file in data storage. **kwargs : dict Additional arguments passed to the specific reader function.
Returns:¶
pandas.DataFrame or geopandas.GeoDataFrame The data read from the file.
Raises:¶
FileNotFoundError If the file doesn't exist in blob storage. ValueError If the file type is unsupported or if there's an error reading the file.
Source code in gigaspatial/core/io/readers.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
read_datasets(data_store, paths, **kwargs)
¶
Read multiple datasets from data storage at once.
Parameters:¶
data_store : DataStore Instance of DataStore for accessing data storage. paths : list of str Paths to files in data storage. **kwargs : dict Additional arguments passed to read_dataset.
Returns:¶
dict Dictionary mapping paths to their corresponding DataFrames/GeoDataFrames.
Source code in gigaspatial/core/io/readers.py
read_gzipped_json_or_csv(file_path, data_store)
¶
Reads a gzipped file, attempting to parse it as JSON (lines=True) or CSV.
Source code in gigaspatial/core/io/readers.py
read_kmz(file_obj, **kwargs)
¶
Helper function to read KMZ files and return a GeoDataFrame.
Source code in gigaspatial/core/io/readers.py
write_dataset(data, data_store, path, **kwargs)
¶
Write DataFrame or GeoDataFrame to various file formats in Azure Blob Storage.
Parameters:¶
data : pandas.DataFrame or geopandas.GeoDataFrame The data to write to blob storage. data_store : DataStore Instance of DataStore for accessing data storage. path : str Path where the file will be written in data storage. **kwargs : dict Additional arguments passed to the specific writer function.
Raises:¶
ValueError If the file type is unsupported or if there's an error writing the file. TypeError If input data is not a DataFrame or GeoDataFrame.
Source code in gigaspatial/core/io/writers.py
write_datasets(data_dict, data_store, **kwargs)
¶
Write multiple datasets to data storage at once.
Parameters:¶
data_dict : dict Dictionary mapping paths to DataFrames/GeoDataFrames. data_store : DataStore Instance of DataStore for accessing data storage. **kwargs : dict Additional arguments passed to write_dataset.
Raises:¶
ValueError If there are any errors writing the datasets.