-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benjamin Stewart
committed
Aug 19, 2022
1 parent
885075d
commit f1b5b72
Showing
15 changed files
with
3,657 additions
and
1,652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
Notebooks/Implementations/Mapping_Informality/Untitled.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/home/wb411133/.local/lib/python3.7/site-packages/geopandas/_compat.py:110: UserWarning: The Shapely GEOS version (3.8.0-CAPI-1.13.1 ) is incompatible with the GEOS version PyGEOS was compiled with (3.9.0-CAPI-1.16.2). Conversions between both will be slow.\n", | ||
" shapely_geos_version, geos_capi_version_string\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import sys, os, importlib\n", | ||
"import rasterio, geojson\n", | ||
"\n", | ||
"import pandas as pd\n", | ||
"import geopandas as gpd\n", | ||
"\n", | ||
"from shapely.geometry import box" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"aoi_file = \"/home/public/Data/COUNTRY/BDI/Bujumbura_AOI.geojson\"\n", | ||
"buildings_master = \"/home/public/Data/COUNTRY/BDI/WP_Builidngs_Stats/DA/AFRICA_BURUNDI_building_32735.shp\"\n", | ||
"sel_buildings_file = \"/home/wb411133/data/Country/BDI/WP_Builidngs_Stats/DA/Bujumbura_buildings.shp\"\n", | ||
"if not os.path.exists(os.path.dirname(sel_buildings_file)):\n", | ||
" os.makedirs(os.path.dirname(sel_buildings_file))\n", | ||
"inAOI = gpd.read_file(aoi_file)\n", | ||
"all_buildings = gpd.read_file(buildings_master)\n", | ||
"inAOI = inAOI.to_crs(all_buildings.crs)\n", | ||
"sIndex = all_buildings.sindex" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 40, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not os.path.exists(sel_buildings_file):\n", | ||
" sel_idx = list(sIndex.intersection(inAOI.total_bounds))\n", | ||
" possible_buildings = all_buildings.loc[sel_idx]\n", | ||
" sel_buildings = possible_buildings.loc[possible_buildings.intersects(inAOI.unary_union)]\n", | ||
" sel_buildings.to_file(sel_buildings_file)\n", | ||
"else:\n", | ||
" sel_buildings = gpd.read_file(sel_buildings_file)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python (geog)", | ||
"language": "python", | ||
"name": "geog" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.