Extracting vector basin statistics from raster-based data.
A number of important watershed charachteristics such as climate, slope, land use and land cover are represented as a raster grid. Using a software packaged called StarSpan, we were able to develop a technique for automated exctraction of basin-level statistics from these raster grids. This document also describes the processing steps to create the raster inputs.
Prepping the input rasters
Temperature
Fertilizer
(See Mapping Fertilizer and Pesticide Distribution)
Pesticide
(See Mapping Fertilizer and Pesticide Distribution)
Water Balance
Vegetation
Elevation
Slope
Soil Order
Soil Erodibility
Wilderness
Tree Cover
Percent Irrigation
Humidity
Glaciers
Lakes and Water Bodies
Human Induced Soil Degradation
Potential Evapotranspiration
Precipitation
RUSLE
(see Modelling Global Erosion Potential by River Basin - A GIS based RUSLE model)
Protected Areas
Human Footprint
Resevoir Depth
StarSpan software overview
Specialized GIS Utility written at UCDavis to extract raster summaries from polygon layers.
Please cite the software in published papers as follows (modifying
the formatting as appropriate):
Rueda, C.A., Greenberg, J.A., and Ustin, S.L. StarSpan: A Tool for
Fast Selective Pixel Extraction from Remotely Sensed Data. (2005).
Center for Spatial Technologies and Remote Sensing (CSTARS), University
of California at Davis, Davis, CA.
Summary of a continuous raster layer by watershed; Temperature
river |
numPixels |
avg_Band1 |
min_Band1 |
max_Band1 |
stdev_Band1 |
Alabama |
385 |
16.75 |
13.24 |
19.22 |
1.17 |
Alazeya |
622 |
-13.29 |
-14.89 |
-12.53 |
0.43 |
Altamaha |
129 |
17.47 |
15.44 |
19.44 |
0.97 |
Amazon |
16811 |
24.98 |
0.97 |
27.86 |
3.55 |
Summary of a discrete raster layer (ie categorical) by watershed; Vegetation Class
FID |
class |
count |
0 |
0 |
20075 |
0 |
1 |
1393 |
0 |
3 |
418 |
0 |
5 |
180 |
0 |
6 |
18 |
0 |
7 |
846332 |
0 |
8 |
56641 |
0 |
9 |
973 |
0 |
10 |
17001 |
0 |
15 |
102 |
0 |
16 |
43453 |
1 |
0 |
5394 |
1 |
1 |
3649 |
1 |
2 |
26 |
1 |
3 |
1671 |
1 |
5 |
60 |
1 |
6 |
41 |
1 |
7 |
449868 |
1 |
8 |
113827 |
1 |
9 |
1362 |
1 |
10 |
79181 |
1 |
16 |
16858 |
By taking the sum total count for each feature(FID), you can determine the percentage of each veg class covering the watershed.
Setup
The raster_stats.py script on cabrillo (in /home/perry/scripts/) does all work flow while starspan and postgis do the heavy lifting.
raster_stats.py requires a very specific data structure in order to work properly:
- Create and define in the script an "outputs" directory to hold temp files and an "outshp" directory to store the output shapefiles.
- A raster directory that stores each of your rasters in a data structure like "./rastername/continent_rastername.tif"
- A vector basins directory with 2 shpfiles: continent_basins.shp (polygon basins) and continent_pours.shp (point pours)
- A postgres database in which to store and join all the data, must
have postgis installed as well as discrete_pivot.sql
- All of the rasters must be configured as either a discrete or continuous raster in the script
- All of the config options are hardcoded in the script.
Once all that is in place, simply run
./raster_stats.py continent database