NCSU GIS/MEA582:
Geospatial Modeling and Analysis

Spatial interpolation and approximation II: splines

Resources:

Text files with color rules:

Start GRASS GIS

Create a new mapset (called e.g. HW_interpolation_2) in nc_spm_08_grass7 project and change working directory:
Settings > GRASS working environment > Change working directory > select/create any directory
or type cd (stands for change directory) into the GUI Console and hit Enter:
cd
Download all text files with color rules (see above) to the selected directory. Now you can use the commands from the assignment requiring the text file without the need to specify the full path to the file.

Explore impact of spline tension parameter on the interpolated surface

Display the input scattered points with elevation stored as attribute named value. Then interpolate elevation rasters from these points using splines with different tension. Compute aspect simultaneously with interpolation and explain impact of tension by using tension=40 (default), tension=10 and tension=160.
g.region rural_1m res=1 -p
v.colors map=elev_lid792_randpts use=attr column=value color=elevation
d.vect elev_lid792_randpts
v.surf.rst input=elev_lid792_randpts elevation=elev_rstdef_1m aspect=asp_rstdef_1m zcolumn=value npmin=140
v.surf.rst input=elev_lid792_randpts elevation=elev_rstt10_1m aspect=asp_rstt10_1m zcolumn=value tension=10 npmin=140
v.surf.rst input=elev_lid792_randpts elevation=elev_rstt160_1m aspect=asp_rstt160_1m zcolumn=value tension=160 npmin=140

Compare the interpolated elevation surfaces using aspect maps.
Change the aspect color table to grey aspect for consistency with assignment 4A.
Save aspect images for your report.

r.colors asp_rstdef_1m color=aspect
r.colors asp_rstt10_1m color=aspect
r.colors asp_rstt160_1m color=aspect
d.erase
d.rast asp_rstdef_1m
d.out.file asp_rst_t40
d.rast asp_rstt10_1m
d.out.file asp_rst_t10
d.rast asp_rstt160_1m
d.out.file asp_rst_t160

Or use 3D views of elev_rstdef_1m, elev_rstt10_1m, elev_rstt160_1m, make sure you switch off the aspect rasters and save the 3 images for your report.

Explore impact of spline smoothing parameter on deviations of the interpolated surface

Compute elevation raster,aspect, and deviations vector point map with different values of smoothing (switch off aspect maps to see the elevations output). Compare summary statistics for deviations for smoothing 0.1 and 10, including root mean square deviation (rmsdevi) provided by r.info of the resulting elevations maps
v.surf.rst input=elev_lid792_randpts elevation=elev_rstdef_1mb aspect=asp_rstdef zcolumn=value smooth=0.1 deviations=elev_rstdef_devi npmin=140
v.surf.rst input=elev_lid792_randpts elevation=elev_rstsm10_1mb aspect=asp_rstsm10 zcolumn=value smooth=10 deviations=elev_rstsm10_devi npmin=140
r.info elev_rstdef_1mb
v.info -c elev_rstdef_devi
v.univar elev_rstdef_devi column=flt1 type=point
r.info elev_rstsm10_1mb
v.info -c elev_rstsm10_devi
v.univar elev_rstsm10_devi column=flt1 type=point
r.colors asp_rstdef color=aspect
d.out.file aspect_smoothdefault
r.colors asp_rstsm10 color=aspect
d.out.file aspect_smooth10

Compute and display deviations maps using the same divergent custom color table. Note that we are interpolating the deviations, not the given elevations.

v.surf.rst input=elev_rstdef_devi elevation=elev_rstdef_devi zcolumn=flt1 npmin=140
v.surf.rst input=elev_rstsm10_devi elevation=elev_rstsm10_devi zcolumn=flt1 npmin=140

Apply the downloaded custom color table deviations_color.txt to the deviation raster. Right click to remove legend from previous map if needed.
Optionally, to view the results in 3D use "elev_rstdef_1mb" for elevation (switch off everything else) and drape the deviations maps as color.

r.colors elev_rstsm10_devi rules=deviations_color.txt
r.colors elev_rstdef_devi rules=deviations_color.txt
d.erase
d.rast elev_rstdef_devi
d.legend elev_rstdef_devi at=2,50,2,6
d.out.file elev_rstdef_devi
d.rast elev_rstsm10_devi
d.legend elev_rstsm10_devi at=2,50,2,6
d.out.file elev_rstsm10_devi
What is the difference in deviations in terms of summary statististics and spatial pattern for the interpolation with the two different smoothing parameters?

Compute predictive error of interpolation

Compute predictive error of interpolation for each point using cross-validation (no raster output, result is points with predictive errors).
d.erase
v.surf.rst -c input=elev_lid792_randpts zcolumn=value cvdev=elev_rstdef_cv npmin=120 segmax=35
v.colors elev_rstdef_cv use=attr column=flt1 rules=deviations_color.txt
v.univar elev_rstdef_cv column=flt1 type=point

Compute raster map of predictive errors and identify locations where the sampling is inadequate leading to large predictive errors.

v.surf.rst input=elev_rstdef_cv elevation=elev_rstdef_cv zcolumn=flt1
r.colors elev_rstdef_cv rules=deviations_color.txt
d.erase
d.rast elev_rstdef_cv
d.legend elev_rstdef_cv at=2,50,2,6
d.out.file elev_rstdef_cv
Optionally, to view the result in 3D use "elev_rstdef_1mb" for elevation (switch off everything else) and drape the crossvalidation map "elev_rstdef_cv" as color.

Interpolate precipitation with influence of topography

Set 3D region for entire North Carolina (read the man page for g.region).
We set tbres to high value - we have just a single level because we are not computing the 3D raster (see lecture for more details).
g.region raster=elev_state_500m -p
g.region t=2000 b=0 tbres=2000 res3=500 -p3

Compute precipitation raster map without influence of elevation (with segmax=700 segmentation is not performed so interpolation function is computed using all points at once).
We will use mask during the interpolation to limit the computation to North Carolina. Zoom to computational region to see the input maps and the result.

d.rast ncmask_500m
r.mask raster=ncmask_500m
v.info -c precip_30ynormals
d.vect precip_30ynormals size=2
v.surf.rst input=precip_30ynormals elevation=precip_annual_500m zcolumn=annual segmax=700

Use the downloaded the color table precip_color.txt.

r.colors precip_annual_500m rules=precip_color.txt
d.erase
d.rast precip_annual_500m
d.legend precip_annual_500m at=2,30,2,5 range=970,2400
d.out.file precip_annual

Compute precipitation raster map with influence of elevation.

We use trivariate spline interpolation and compute the result as a crossection between the trivariate precipitation function and bivariate elevation function. We rescale elevation by 90 to incorporate strong influence of topography and use the 2D cross_output raster for the resulting precipitation map.

v.info -c precip_30ynormals_3d
v.vol.rst input=precip_30ynormals_3d cross_input=elev_state_500m cross_output=precip_anntopo_500m maskmap=elev_state_500m wcolumn=annual zscale=90 segmax=700
r.colors precip_anntopo_500m raster=precip_annual_500m
d.rast precip_anntopo_500m
d.out.file precip_anntopo

Try to explain how was elevation used for the precipitation raster interpolation.

After you are finished, remove mask.

r.mask -r