The Degree of Urbanization (DoU) is a method for quantifying urbanization using thresholds applied to gridded population data. More information on the DoU can be found here.
---------------------------------------------------------------------------ModuleNotFoundErrorTraceback (most recent call last)
CellIn[1],line96importpandasaspd8importGOSTurban.UrbanRasterasurban----> 9importGOSTRocks.mapMiscasmapMiscModuleNotFoundError: No module named 'GOSTRocks'
# Define input population rastertutorial_folder="../../data/tutorial_data"aoi_file=os.path.join(tutorial_folder,"AOI.geojson")pop_file=os.path.join(tutorial_folder,"wp_2020_1k_AOI.tif")# Define output filesout_urban=os.path.join(tutorial_folder,"urban_extents.geojson")out_hd_urban=os.path.join(tutorial_folder,"hd_urban_extents.geojson")inAOI=gpd.read_file(aoi_file)# Shouldn't need to execute this unless you change your AOI;# you will need to find a global population to extract fromifnotos.path.exists(pop_file):sys.path.append("../../../gostrocks/src")importGOSTRocks.rasterMiscasrMiscglobal_population="/path/to/global/pop_layer/ppp_2020_1km_Aggregated.tif"inR=rasterio.open(global_population)rMisc.clipRaster(inR,inAOI,pop_file)inR=rasterio.open(pop_file)# Initiate the urban calculatorurban_calculator=urban.urbanGriddedPop(inR)
---------------------------------------------------------------------------NameErrorTraceback (most recent call last)
CellIn[3],line1----> 1mapMisc.static_map_raster(inR,thresh=[1,5,50,100,300,1000,3000])NameError: name 'mapMisc' is not defined
# Extract the urban extents (minimum density 300/km2, minimum total population 5000)urban_extents=urban_calculator.calculateUrban(densVal=300,totalPopThresh=5000,smooth=False,queen=False,verbose=True)urban_extents["Type"]=1urban_extents.head()
00:23:33 : Read in urban data
00:23:33 : Creating Shape 0
00:23:37 : Creating Shape 1000
00:23:40 : Creating Shape 2000
00:23:44 : Creating Shape 3000
00:23:47 : Creating Shape 4000
00:23:50 : Creating Shape 5000
00:23:53 : Creating Shape 6000
00:23:55 : Creating Shape 7000
ID
Pop
geometry
Type
0
6044
18641.011719
POLYGON ((-78.75958 44.38292, -78.75958 44.349...
1
1
6045
147162.718750
POLYGON ((-79.71792 44.42458, -79.71792 44.416...
1
2
6046
8065.728516
POLYGON ((-79.90958 44.33292, -79.90958 44.324...
1
3
6047
18561.923828
POLYGON ((-79.55125 44.36625, -79.55125 44.357...
1
4
6049
11521.957031
POLYGON ((-69.78458 44.34125, -69.78458 44.316...
1
# Map of urban extentsmapMisc.static_map_vector(urban_extents,"Type")
---------------------------------------------------------------------------NameErrorTraceback (most recent call last)
CellIn[5],line21# Map of urban extents----> 2mapMisc.static_map_vector(urban_extents,"Type")NameError: name 'mapMisc' is not defined
# Extract the high density urban extents (minimum density 1500/km2, minimum total population 50000)hd_urban_extents=urban_calculator.calculateUrban(densVal=1500,totalPopThresh=50000,smooth=True,queen=True,# high density extents use queen's case contiguity, andverbose=True,)# High density extents have hole smoothing applied.hd_urban_extents["Type"]=2hd_urban_extents.head()
00:23:56 : Read in urban data
00:23:56 : Creating Shape 0
00:24:01 : Creating Shape 1000
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/numpy/core/_methods.py:49: RuntimeWarning: overflow encountered in reduce
return umr_sum(a, axis, dtype, out, keepdims, initial, where)
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/GOSTurban/UrbanRaster.py:404: UserWarning: Geometry is in a geographic CRS. Results from 'buffer' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
xxGeom["geometry"] = xxGeom.buffer((popRaster.res[0] / 2))
---------------------------------------------------------------------------NameErrorTraceback (most recent call last)
CellIn[7],line1----> 1mapMisc.static_map_vector(hd_urban_extents,"Type",colormap="Blues")NameError: name 'mapMisc' is not defined
---------------------------------------------------------------------------NameErrorTraceback (most recent call last)
CellIn[8],line21combo_extents=pd.concat([urban_extents,hd_urban_extents])----> 2mapMisc.static_map_vector(combo_extents,"Type",colormap="magma")NameError: name 'mapMisc' is not defined