GeoPython Exercises - A
👥 Population Analysis
Create a Python script that iterates over the cities (municities) and prints:
The name of each city
The population in 2020
The change in population from 2015 to 2020
The population density in persons per 100 square meters
Assumptions/Data
You have a vector file containing municities and their respective attributes (name, pop2020, pop2015):
data/ncr.gpkg.The population data is stored as integers.
Expected Output
City: City1
Population in 2020: 100000
Change in population from 2015 to 2020: 5000
Population density: 10000.0 persons/100sqm
City: City2
Population in 2020: 200000
Change in population from 2015 to 2020: 10000
Population density: 20000.0 persons/100sqm
... (iterate over all cities)# Write your solution here👥👥 Population Analysis 2
Compute for a simple annual average rate of change of the population from 1990 to 2020 for each municity.
Map the results.
Assumptions/Data
You have a vector file containing municities and their respective attributes (name, pop2020, pop2015):
data/ncr.gpkg.The population data is stored as integers.
Expected Output
A map showing the average rate of change of the population from 1990 to 2020 for each municity in NCR.
# Write your solution here💧 Calculating NDWI
The formula for NDWI using a Landsat satellite image is:
NDWI = (Green - NIR) / (Green + NIR)
For the Landsat image:
Band 2 is the Green band.
Band 4 is the Near-Infrared (NIR) band.
Tasks
Use
numpyto calculate the ndwi array.Create a plot of your results. Use
cmap='Blues'so that water shows up as dark blue.
Expected Output
A plot displaying the NDWI values across the study area.
Water bodies (e.g., lakes, rivers) should appear as dark blue in the plot due to the Blues colormap.
The plot should include a legend to interpret NDWI values.
BONUS
Download your own Landsat data (e.g. from GEE) and try to run it on that data.
# Write your solution here🌳 Finding dense forest pixels
Tasks
Download Landsat imagery for your area of interest.
Compute for the NDVI of the area.
Apply a boolean mask called
dense_forestor all pixels where the NDVI value is strictly greater than 0.7.Use np.sum() to count exactly how many pixels meet this criteria.
Display the mask.
Expected Output
The number of dense forest pixels.
A map of dense forest pixels.
Tip
If the area is too big or processing is taking too long, you can clip the image to a smaller AOI.
# Write your solution here