I have two files:
fileLUse.tif
defines land cover classes in GeoTiff format (from https://www.esa-landcover-cci.org/?q=node/164)fileRegions.shp
defines administrative borders and it is a shapefile (from https://gadm.org)
Both files are EPSG 4326, that if I understood it well it is WTS84 datum with coordinates system (no projected) and cover the whole World.
I need to select the land use classes from fileLUse
whose value is in a certain range ([40-130]) and compute the area and area ratio of this aggregate for each region in fileRegions
.My "output" would then be a CSV with region name (from fileRegions), total area, share of aggregate land use.
My main problem is that the files are not projected, so I don't really know how to give them a unit, as all "equal area" projections I saw are specific for a certain area of the World.
Which approach should I take ? I could use QGIS, GRASS, R, Python... (I'm on Linux)
[EDIT]
What I have done so far:
- Computed 0/1 binary data of Land Covers in the interested range:
gdal_calc.py -A fileLUse.tif --outfile=fileNatVegAreas.tif --calc="logical_and(A>=40,A<=140)"
- I used rasterstats to get the mean/count of each "polygon"
from rasterstats import zonal_statsstats = zonal_stats("fileRegions.shp", "fileNatVegAreas.tif")
What I am left with:
stats
is a vector of dictionaries with the various stats, e.g.
>>> stats[0]{'min': 0.0, 'max': 1.0, 'mean': 0.5842002754571467, 'count': 739861}
How do I link back my stats to the field "RegionName" in my shapefile, and possibly export everything as a CSV ?