# Home assignment 4¶

Last updated: 2022-06-22 18:56:07


## Question 1¶

• Read the statisticalareas_demography2019.gdb polygon layer of statistical areas in Israel into a GeoDataFrame.

• Aggregate (dissolve) the layer by town name ('SHEM_YISHUV' column) to get a layer with towns geometries and sums of population ('Pop_Total' column) per town.

• Find the five towns with the biggest total population.

• Print the resulting layer

• Plot the resulting layer. The polygons need to be colored proportionally to their total population size.

/home/michael/.local/lib/python3.8/site-packages/geopandas/_compat.py:111: UserWarning: The Shapely GEOS version (3.8.0-CAPI-1.13.1 ) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.
warnings.warn(

SHEM_YISHUV geometry Pop_Total
505 ירושלים MULTIPOLYGON (((220493.425 6250... 936427.0
1248 תל אביב -יפו POLYGON ((177050.124 659998.455... 460616.0
414 חיפה POLYGON ((197767.727 742002.003... 285317.0
1109 ראשון לציון POLYGON ((181309.543 650317.156... 254385.0
1036 פתח תקווה POLYGON ((187650.526 664188.886... 247955.0 ## Question 2¶

• Calculate and plot the density (stops per $$km^2$$) of public transport stops (stops.txt) per town (muni_il.shp). Go through the following steps.

• Read the towns (muni_il.shp) layer (see Sample data).

• Aggregate the towns layer according to the 'Muni_Heb' column, to dissolve the separate polygons per town (see Aggregation (.dissolve)).

• Read the stops.txt table and convert it to a point layer (see Table to point layer).

• Transform the stops layer to the CRS of towns (ITM).

• Calculate the number of stops per town. Hint: use spatial join to join stops to the towns layer, then use aggregation to get a table of stop counts per town, and, finally, join the counts table back to the towns layer.

• Calculate town area in $$km^2$$, then divide the stop count by area to get stops density.

• Plot the towns layer using using the 'Reds' colormap (cmap='Reds') with a legend (legend=True).

Muni_Heb geometry stop_id area_km2 stops_per_km2
0 אבו גוש POLYGON ((209794.406 635294.812... 27.0 1.891242 14.276336
1 אבו סנאן POLYGON ((217396.500 765040.394... 48.0 6.695647 7.168836
2 אבן יהודה POLYGON ((189450.453 688895.625... 64.0 8.265724 7.742818
3 אום אל פחם MULTIPOLYGON (((212450.609 7126... 85.0 26.028285 3.265678
4 אופקים POLYGON ((164381.876 581681.897... 137.0 10.378556 13.200295
... ... ... ... ... ...
304 שפרעם POLYGON ((215441.445 748330.218... 135.0 19.582997 6.893736
305 תל אביב - יפו POLYGON ((180416.398 672604.306... 1076.0 53.897944 19.963656
306 תל מונד POLYGON ((192511.156 685447.871... 13.0 7.126842 1.824090
307 תל שבע POLYGON ((189005.110 574100.751... 17.0 9.421015 1.804477
308 תמר MULTIPOLYGON (((223749.969 5237... 55.0 1570.567236 0.035019

309 rows × 5 columns 