Skip to content

Commit

Permalink
updated zonal stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Stewart committed Aug 19, 2022
1 parent 885075d commit f1b5b72
Show file tree
Hide file tree
Showing 15 changed files with 3,657 additions and 1,652 deletions.
20 changes: 16 additions & 4 deletions Notebooks/Implementations/JUP_SURGP_GLO_B_D__LEI_Evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'src.LEI'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_81457/3673388608.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;31m#Import GOST urban functions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"../../\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0msrc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLEI\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'src.LEI'"
]
}
],
"source": [
"import os, sys, logging\n",
"\n",
Expand Down Expand Up @@ -449,7 +461,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
88 changes: 88 additions & 0 deletions Notebooks/Implementations/Mapping_Informality/Untitled.ipynb
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
}
Loading

0 comments on commit f1b5b72

Please sign in to comment.