## Open the Grass GIS in 'utm38n/ulb_wapor' location/mapset
grass78 /mnt/d/grassdata/utm38n/ulb_wapor
## Set the region to ULB
g.region vect=ulb res=250 -a
## remove any Mask
r.mask -r
## We have imported all the vector files (Base_layers) in the previous section.
## Now let us import all the WaPOR data into the grass gis mapset.
## Navigate (cd) to the '' folder provided to you
cd /path/to/Data_ULB/Wapor # change the path to actual path in your computer
## Let us import all the AETI maps first
cd AETI
## List all the maps in the folder
ls
## let us use a 'for' loop to import all the maps in to GRASS GIS mapset in one go.
for i in `ls *.tif`; do
out=`echo ${i}|cut -d. -f1`
r.import in=${i} out=${out} extent=region resolution=region
done
## press enter
## Now Let us import all the precipitation maps
cd /path/to/Data_ULB/Wapor/PCP
## let us use a 'for' loop to import all the maps in to GRASS GIS mapset in one go.
for i in `ls *.tif`; do
out=`echo ${i}|cut -d. -f1`
r.import in=${i} out=${out} extent=region resolution=value resolution_value=2500
done
## press enter
## Now Let us import all the Land cover maps
cd /path/to/Data_ULB/Wapor/LCC
## let us use a 'for' loop to import all the maps in to GRASS GIS mapset in one go.
for i in `ls *.tif`; do
out=`echo ${i}|cut -d. -f1`
r.import in=${i} out=${out} extent=region resolution=region
done
## press enter
Now you want to just list the AETI data for the year 2019. USE g.list as shown below:
## below command list the raster maps AETI of year 2019
g.list rast mapset=. pattern=L1_AETI_2019*|cat
## Change the pattern above to select sub samples of maps
## Set the region to ULB
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
r.mask vect=ulb --o
## List all the AETI maps in Grass mapset
g.list rast mapset=. pattern=L1_AETI*|cat
## let us use a 'for' loop to apply scale factor to all the AETI maps in the mapset in one go.
for i in `g.list rast mapset=. pattern=L1_AETI*|cat`; do
r.mapcalc "${i}_scaled = ${i} * 0.1"
done
## press enter
## List all the PCP maps in Grass mapset
g.list rast mapset=. pattern=L1_PCP*|cat
## let us use a 'for' loop to apply scale factor to all the AETI maps in the mapset in one go.
for i in `g.list rast mapset=. pattern=L1_PCP*|cat`; do
r.mapcalc "${i}_scaled = ${i} * 0.1"
done
## press enter
## Set the region to ULB
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
r.mask vect=ulb --o
## List all the AETI maps in Grass mapset
g.list rast mapset=. pattern=L1_AETI*scaled|cat
## select the maps you want to aggregate and save it into a text file using notepad.(see below screenshot)
## Assuming the file with map names is maps_aeti.txt
## below code aggregate the maps using the function "sum"
r.series file=maps_aeti.txt out=AETI_annual_2017_18 method=sum
## List all the PCP scaled maps in Grass mapset
g.list rast mapset=. pattern=L1_PCP*scaled|cat
## select the maps you want to aggregate and save it into a text file using notepad.(see below screenshot)
## Assuming the file with map names is maps_pcp.txt
## below code aggregate the maps using the function "sum"
r.series file=maps_pcp.txt out=PCP_annual_2017_18 method=sum
## press enter
# Compute univariate statistics of the annual maps
r.univar -e AETI_annual_2017_18
r.univar -e PCP_annual_2017_18
## press enter
## Set the region to ULB
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
r.mask vect=ulb --o
# First list all the LCC maps
g.list rast mapset=. pattern=L1_LCC*|cat
# First let us assign category names to each land cover id as per WaPOR Catalog
# https://wapor.apps.fao.org/catalog/WAPOR_2/1/L1_LCC_A
# A text file with category details are developed and provided to you as 'rules_lcc.txt' inside 'Base_layers' folder.
r.category map=L1_LCC_2018 rules=rules.txt sep=comma
# Below command compute the surface area of each Land cover type in hectares.
r.report L1_LCC_2018 units=k -e -n -h
## Set the region to ULB
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
r.mask vect=ulb --o
# Use the below univar command with zones and -t flag to compute stats per land cover type
# For Annual AETI
r.univar -t AETI_annual_2017_18 zones=L1_LCC_2018 sep=, output=AETI_stats_2017_18.csv
# For Annual PCP
r.univar -t PCP_annual_2017_18 zones=L1_LCC_2018 sep=, output=PCP_stats_2017_18.csv
## Set the region to ULB
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
r.mask vect=ulb --o
## Assign a color palette to Annual AETI map
## below note that the color palette is inverted with (-n) flag and applied histo equalization using (-e) flags
r.colors -n -e map=AETI_annual_2017_18 color=gyr
## Assign a color palette to Annual AETI map
r.colors map=PCP_annual_2017_18 color=precipitation
## Create map layout for annual AETI
# Open a monitor
d.mon wx0
# erase everything in the monitor
d.erase -f
# Display a raster map
d.rast map=AETI_annual_2017_18
# Display a vector map
d.vect map=ulb type=boundary
# Add raster legend
d.legend -t -d raster=AETI_annual_2017_18 title="AETI(mm/year)" title_fontsize=20 font=sans fontsize=18
# Add North arrow
d.northarrow style=1b text_color=black
# Add Scale
d.barscale units=kilometers label=km
# Before creating the next map layout erase everything in wx0 monitor
d.erase -f
# Now Create map layout for annual PCP
# Display a raster map
d.rast map=PCP_annual_2017_18
# Display a vector map
d.vect map=ulb type=boundary
# Add raster legend
d.legend -t -d raster=PCP_annual_2017_18 title=AETI title_fontsize=20 font=sans fontsize=18
# Add North arrow
d.northarrow style=1b text_color=black
# Add Scale
d.barscale units=kilometers label=km
## navigate to the output folder where you want the exported raster maps in tif format
cd /mnt/path/to/outputfolder
g.region vect=ulb res=250 -a
## Apply a mask to restrict further analysis to ULB
## If a mask is applied the exported map will be also clipped to the mask
r.mask vect=ulb --o
# Use the below commands to export the annual AETI and PCP to geotiff (.tif)
# For Annual AETI
r.out.gdal in=AETI_annual_2017_18 out=AETI_annual_2017_18.tif
# For Annual PCP
r.out.gdal in=PCP_annual_2017_18 out=PCP_annual_2017_18.tif
Last changed: 2021-07-07
GRASS GIS manual main index | Topics index | Keywords Index | Full index | Raster index | Vector index | Temporal index |
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License - Thanks to Vaclav Petras for the style.