Rational
Take a set of shapefiles, download the ESA WorldCover GeoTIFFs that the shapefile elements cover and determine the percentage of each land use type in each shape file element.
Input Files
Shapefile
.shp
.cpg
.dbf
.prj
.shx
Learn how to produce this shapefile from a CSV of sample names, latitudes and longitudes here: Site Locations to Shapefile
Scripts Used
Environmental Data / Land Use - ESA WorldCover
download-from-shapefile.py
percent.py
landuse_pies.py
Steps
1. Downloading ESA LandCover tiles
python download_from_shapefile.py -s '/path/to/shapefile/output_shapes.shp'
Arguments
- Path to your
.shp
(e.g. output_shapes.shp)
Outputs
- A number of
.tif
files titledESA_WorldCover_10m_2021_v200_XXXXXX_Map.tif
- There can be a variation in the number of files downloaded depending on the spread of your collection sites, normally 2 or 3 if it's within the state.
- This
.tif
file is essentially like a map with multiple layers of a particular region; some groups (shapes/polygons) will be covered in one file, and other groups will be in another.
2. Extracting Land Use within Shapefiles
python percent.py '/path/to/geotiffs_folder' 'path/to/shapefile.shp' landuse_output.csv
Don’t worry about the warnings as long as it says “Results saved to …”
Each column in the CSV represents a percentage of each land type contained within each shapefile element.
ESA Land Use Codes
Layer (Class) | Colour (RGB) | Hex | Colour | Map Code |
---|---|---|---|---|
Trees | 0,100,0 | #006400 | Trees | 10 |
Shrub Land | 255, 187, 34 | #FFBB22 | Shrub Land | 20 |
Grassland | 255, 255, 76 | #FFFF4C | Grassland | 30 |
Cropland | 240, 150, 255 | #F096FF | Cropland | 40 |
Built | 250, 0, 0 | #FA0000 | Built | 50 |
Bare / Sparse Vegetation | 180, 180, 180 | #B4B4B4 | Bare / Sparse Vegetation | 60 |
Snow and Ice | 240, 240, 240 | #F0F0F0 | Snow and Ice | 70 |
Permanent Water Bodies | 0, 100, 200 | #0064C8 | Permanent Water Bodies | 80 |
Herbaceous Wetland | 0, 150, 160 | #0096A0 | Herbaceous Wetland | 90 |
Mangroves | 0, 207, 117 | #00CF75 | Mangroves | 95 |
Moss and Lichen | 250, 230, 160 | #FAE6A0 | Moss and Lichen | 100 |
Arguments
- Path to your
.shp
from previous steps (e.g. output_shapes.shp) - Path to a directory (folder) containing GeoTIFFs downloaded in previous step (e.g. /geotifs)
Outputs
- CSV containing assigned groups and the percentage of each land use type that the shapefile polygon contains (e.g. landuse_output.csv)
3. Generating a Map of Land Use in Each Group (optional)
python landuse_pies.py '/path/to/shapefile/output_shapes.shp' '/path/to/landuse/percentages/landuse_output.csv'
Arguments
- Path to your
.shp
from previous steps (e.g. output_shapes.shp) - Path to the CSV of land use percentages produced in previous step (e.g. landuse_output.csv)
Outputs
- HTML map containing group polygons and pie charts of land use cover (landuse_pies.html)