## Open the Grass GIS in 'utm38n/ulb_wapor' location/mapset
grass78 /mnt/d/grassdata/utm38n/ulb_wapor
## IMPORT VECTOR DATA: Boundaries of Urmia Lake basin, Miandoab Irrig scheme and Urmia Lake
## Navigate (cd) to the 'Base_layers' folder provided to you
cd /path/to/Base_layers # change the path to actual path in your computer
# Import 'Urmia Lake Basin' boundary shapefile into a vector in Grass GIS
v.import in=UrmiaLB.shp out=ulb
# Import 'Miandoab Irrigation Scheme' boundary shapefile into a vector in Grass GIS
v.import in=Miandoab.shp out=mis
# Import 'Urmia Lake' boundary shapefile into a vector in Grass GIS
v.import in=LakeUrmia.shp out=lake
# set the computational region to Urmia Lake basin and set the computational resolution to 250 m
g.region vector=ulb res=250 -a
## IMPORT RASTER DATA: SRTM V3 data for ULB
## cd to the directory containing elevation raster file
cd /path/to/Base_layers # change the path to actual path in your computer
# Import with reprojection on the fly
r.import input=elevation.tif output=elevation resample=bilinear extent=region resolution=region
In the above code snippet we introduce three modules in Grass GIS - r.import, v.import and g.region.
g.list type=raster pattern="elev*"|cat
g.list type=vector|cat
## Subset a raster map
# 1. Check region settings
g.region -p
# 2. Change region to Miandoab
g.region vect=mis res=250 -a
# print the region
# 3. Subset map
r.mapcalc "elevation_mis = elevation"
r.colors elevation_mis color=elevation
# info for raster map
r.info elevation
# info for vector map
v.info ulb
# history of vector map
v.info ulb -h
# set the region first
g.region vect=ulb res=250 -a
# Create a mask of urmia lake basin
r.mask vect=ulb
# Clip the elevation to Urmia lake basin boundary
r.mapcalc "elevation_ulb = elevation"
# Remove the Mask
r.mask -r
# Univariate statistics of elevation in ulb
r.univar elevation
# extended univar statistics of elevation in ulb
r.univar -e elevation
# Compute 5 and 95 percentile fromthe distribution of elevation in ULB
r.univar -e elevation percentile=5,95
#!/bin/bash
# copy this entire code (including the comments) and paste into an empty text file
# Save this file as "myscript.sh"
# This script print the computational region, list the raster files and Compute
# univariate statistics of elevation
g.region -p
g.list type=raster|cat
r.univar elevation
Now you have "myscript.sh" ready. In the command console, type
# print current mapset
g.mapset -p
# change to a different mapset
g.mapset mapset=PERMANENT
# print mapsets in the search path
g.mapsets -p
# list available mapsets in the location
g.mapsets -l
# add mapset to the search path
g.mapsets mapset=PERMANENT operation=add
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.