This package is deprecated and not maintened, in favour of shp2ncmask, which is more generic.
Script and examples to build a netcdf mask of a country
Packages used:
- urllib
- zipfile
- pathlib
- texttable
- datetime
- numpy
- pandas
- xarray
- geopandas
- shapely
Use your package manager or pip to install them.
The generic command to use is:
python3 exec.py -i "gridfile_definition.txt" -o output.nc -src gadm36,country,level,subselect
Where:
-i
: the grid file, see the examples folder, the choice of the projection is fixed by the EPSG,-o
: the netcdf output file,-src
: the source, currently only GADM 3.6 is supported (see below)
Furthermore:
-list
: iflevel > 0
, print a list of zone,-bounds
: print the bounds in lat/lon coordinates, and in the projection defined by the EPSG in the grid file.
- This package use the GADM data to build the netcdf mask, available here.
- The GADM data use the ISO 3166-1 alpha-3 norm to describe countries, see here.
The arguments of -src
options take the form gadm36,country,level,subselect
, where:
country
is the ISO 3166-1 alpha-3 code,level
is the "administrative" level, e.g. for France 0 is the country, 1 is the regions, 2 the departments, etc,subselect
permits to select a particular element of a level. See examples below.
In all figures below, the "False" values of the mask is represented by blue
zone, and the "True" values are replaced by the function
Run the command:
python3 exec.py -i examples/params_WGS84_FRA.txt -o output/mask_France_WGS84.nc -src gadm36,FRA,0
python3 exec.py -i examples/params_WGS84_FRA.txt -o output/mask_France_Occitanie_WGS84.nc -src gadm36,FRA,1,NAME_1=Occitanie
Run the command:
python3 exec.py -i examples/params_LambertIIcarto_FRA.txt -o output/mask_France_LambertII.nc -src gadm36,FRA,0
python3 exec.py -i examples/params_LambertIIcarto_FRA.txt -o output/mask_France_Occitanie_LambertII.nc -src gadm36,FRA,1,NAME_1=Occitanie
Run the command:
python3 exec.py -i examples/params_WGS84_ITA.txt -o output/mask_Italy_WGS84.nc -src gadm36,ITA,0
python3 exec.py -i examples/params_WGS84_ITA.txt -o output/mask_Italy_Sicily_WGS84.nc -src gadm36,ITA,1,NAME_1=Sicily
The script proposed here is based on the following tutorial