SlideShare a Scribd company logo
This and more at my website: https://sites.google.com/site/sorsbysj/
LinkedIn: https://www.linkedin.com/in/skylersorsby
Swath profiles in GRASS gis
Author: Skyler Sorsby
While traditional A-A’ line profiling can produce meaningful 2-D snapshots of topography, visuals of this
type fail to capture the broader morphometric regime. Enter swath profiles (Fig. 1). As the data is
collected for each point in the profile line, the region perpendicular to the profile line is statistically
surveyed (max/mean/min, etc). Thus, the product is a statistically relevant 2-D rendition of a 3-D surface
(Fig. 2). Some have proposed that swath profiles may
be approximated by the superimposition of many
single profiles. However, viewing multiple profiles
superimposed is neither visually appealing nor
representative—the values plotted only describe a
set of finite lines, not a regional average. Other
researchers write high-level algorithms in computing
languages to accomplish the task, yet the visually
powerful effects of a swath profile may be easily
derived with simple tools within the GRASS gis
interface. With this guide, I intend to clearly
illustrate how GRASS may be used to this purpose.
Geospatially, the idea is to order a set of vector
points into a line, and tell each point to collect
statistics of a raster DEM for a set interval
perpendicular to the line. Practically, this may be
accomplished with three tools: v.mkgrid, v.rast.stats,
and v.to.points.
1) v.mkgrid
This GRASS tool allows for the creation of a nxn grid
of vector areas at a user-defined orientation. Each
grid square has a topological feature known as a
centroid. The centroid is the weighted center of the
polygon; thus, for a perfectly symmetrical shape (like
a grid square), each centroid appears halfway
between the square’s edges. For a 1xn (columns x
rows) matrix, this generates a single-column array of
n user-defined rows, with each centroid falling upon
a common straight line. Consequently, if the rows are broad and short, sampling elevation values
(mean/min/max/etc) nwithin the bounds of each row can proxy “looking off to the side” for each
centroid. The trick lies within distillation of these values, computed for each polygonal cell, to the
centroid.
2) v.rast.stats
Once the oriented 1xn grid is created with v.mkgrid, an underlying DEM may be sampled using
v.rast.stats. You’ll need to add a column to your swath grid shapefile first, with v.db.addcol (the syntax
elev double precision works for me)—you’ll need to add a column prior, anytime you wish to upload
values to a vector with v.rast.stats.
Figure 1. Shaded relief map of the Yakima
fold-and-thrust belt. The black dashed line is
a standard topographic line profile. The
white box is a swath.
N
A
A’
This and more at my website: https://sites.google.com/site/sorsbysj/
LinkedIn: https://www.linkedin.com/in/skylersorsby
Figure 2. Elevation profiles from the map in figure 1. The black and gray are the swath profile; the
white dashed line is a line profile.
3) v.to.points
When statistics have been assigned to each cell in the vector grid, these values may be distilled to the
centroid, creating a new vector point file in the process. This is accomplished by using v.to.points—
although documentation hints that this tool is meant for generating points along a line (not the case for
us). This problem may be circumnavigated by checking the “centroids” box under the “feature type”
heading. The result will be a shapefile of points, each point containing the max/mean/min/etc statistics
for elevation of the topography immediately adjacent. Now, the only missing attribute is distance along
the profile. Since each grid square was the same height and each centroid was centered vertically within
each grid square, the distance between the points is simply the height of each grid square. Accordingly,
distance will be a column of linearly-progressing values, easily auto-generated in Excel.
4) v.out.ogr
The final step is to export your point shapefile to Excel as a .csv file, for auto-generation of a distance
column and plotting. This tool may be finicky at times, sometimes requiring an entire file pathway to
save to, others requiring only a name with which to label the containing folder (which will be placed in
your ‘Users’ folder on the C:// drive).
5) Once you’ve exported your elevation graph of min/mean/max elevation from Excel as a pdf, you may
easily augment it in a vector editing program like Inkscape (freeware) or Adobe Illustrator (certainly not
freeware). In Inkscape, I’ve found that the easiest way to create a “filled” min/max envelope (see Fig. 2)
is to make the min/max lines very narrow, connect them with two short vertical segments of the same
color (to close the area), and use the paint bucket tool to give the area some pale color. In Illustrator,
this task is much easier, as closing the area with two vertical lines automatically registers the shape as a
polygon, whose interior “fill” may be set to any color you wish (no paint bucket tool involved-you get
what you pay for!).
6) In the event that you’re working with data in a different coordinate system (say, you have a file of
vector points along the course of a stream, with distance calculated for each point along the length of
the stream—a curvy path), and you need to place your elevation swath profile into those coordinates.
A A’
This and more at my website: https://sites.google.com/site/sorsbysj/
LinkedIn: https://www.linkedin.com/in/skylersorsby
The workflow is the same as above, but involves creation of a second grid, the same height and corner
coordinates, but with much longer rows (to “reach out” orthogonal to the profile line and capture the
values of the other point shapefile whose coordinates you’re attempting to reach into). Here is a
simplified workflow for placing the swath profile into the coorinates of an adjacent river, for example, to
compare the long profile with topographic relief:
1) Have a raster of river points, each point containing distance along the river (you may get a
raster of river lines with the r.watershed, convert the raster to vector lines with r.to.vect, get rid
of everything except your main channel with the digitizer tool, convert to raster points with
v.to.rast (make sure it’s binary—river has a value of 1, else=NULL), multiply by the output of
r.stream.distance to get a raster image of distance along the stream).
2) Create, as before a 1xn grid polygon for the swath profile with v.mkgrid (n is the number of
rows you want)
3) Create another 1xn grid, VERY WIDE, such that the rows line up exactly vertically , but extend
laterally completely across any river points with v.mkgrid
4) Convert the river points to a raster, if you haven’t done this already each cell containing
distance values, with v.to.rast
5) Use v.rast.stats to get the mean distance for each row of the extended polygon (may have to
use the Tk/Tcl GUI for GRASS—my python GUI seems buggy for this tool).
6) Use v.rast.stats to get the elevation statistics for each row of your swath polygon (as you did
before).
7) Distill the swath rows to points with v.to.points, as you did before.
8) Use v.to.rast to convert the extended polygon to a raster with mean distance values (still by
row)
9) Use v.what.rast to sample the extended polygon’s raster and obtain the mean river distance
values for each row in the normal swath polygon.
The basic premise is this: After creating your swath profile, you want to attach a “distance along the
river” coordinate to each elevation—say, to compare structural relief of a linear set of features with a
river’s long profile (and geometry), which certainly ISN’T linear. To do this, you’ll rasterize the river
distance column of your river shapefile (points, I’m assuming), such that a new one column/many row
grid oriented the same way as your swath grid but extending far beyond, can capture the mean values
orthogonal to the swath. The extended grid, having captured the mean river distance, is now rasterized.
The key is that the rasterization has now deposited this orthogonal mean river distance beneath the
centroids of the original swath—effectively “reaching out and pulling in orthogonal river distance”.
Using some sort of out-of-the-box spatial joining technique will not work as a substitute.
This and more at my website: https://sites.google.com/site/sorsbysj/
LinkedIn: https://www.linkedin.com/in/skylersorsby
Figure 3. Map showing the original swath (the narrow grid), the wider
swath (whose sole purpose is to sample river distances, to relaty to the
original swath). When the river distances are used, rather than the
straight-line profile distance, the original swath will align with river-parallel
features (useful for contrasting with changes in planform and geometry as
topographic features are crossed).
Figure 4. A pseudo “swath profile”, made from superimposing adjacent line profiles. Needless to say, it’s
messier and less statistically relevant than a real swath.
,
,
River points containing
downstream distance
Centroids
to which
swath values
are distilled
Large swath grid, to capture river distances for profile
Original swath
This and more at my website: https://sites.google.com/site/sorsbysj/
LinkedIn: https://www.linkedin.com/in/skylersorsby

More Related Content

PPTX
Manejo del Bosque Natural y Restauración en Nicaragua
PPT
Reconocimiento cuencas hidrograficas.pptx
PDF
Reglamento Actividades Maritimas Fluviales Y Lacustres Ley 26620
PDF
Cartografía y Fotogrametría Unidad 4
DOCX
Inventario Forestal
PDF
3.1 actividades del abastecimiento troceo arrime y arrastre
PPTX
383083585 planimetria-pptx
PDF
Calculation of sinuosity in GRASS GIS
Manejo del Bosque Natural y Restauración en Nicaragua
Reconocimiento cuencas hidrograficas.pptx
Reglamento Actividades Maritimas Fluviales Y Lacustres Ley 26620
Cartografía y Fotogrametría Unidad 4
Inventario Forestal
3.1 actividades del abastecimiento troceo arrime y arrastre
383083585 planimetria-pptx
Calculation of sinuosity in GRASS GIS

Similar to Create swath profiles in GRASS GIS (20)

PDF
Derive hypsometric curves in GRASS GIS
PDF
Watershed Analysis with GRASS
PPTX
Mastering_ArcGIS_Pro_CH11_ADA_AU_Accessible.pptx
PDF
Józsa e.
PDF
Dmitriy Kolesov - GIS as an environment for integration and analysis of spati...
PDF
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
PDF
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
PDF
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
PPTX
Watershed Delineation Using ArcMap
PPT
GEOSTATISTICAL_ANALYST
ODP
Corso Pat Jgrasshorton 2008 10 17
PPT
STATISTICAL_SURFACES.ppt
PPTX
Geographic information system and remote sensing
PDF
Introduction to geomorphology in GRASS GIS - by Skyler Sorsby
DOCX
Tutorial
PDF
Tutorialinterpolationam en
PDF
HEC-GEORASTutorials.PDF
PDF
2018 GIS in Education: GIS Watershed Delineation and Morphometric Analysis of...
ODP
Geospatial Data in R
Derive hypsometric curves in GRASS GIS
Watershed Analysis with GRASS
Mastering_ArcGIS_Pro_CH11_ADA_AU_Accessible.pptx
Józsa e.
Dmitriy Kolesov - GIS as an environment for integration and analysis of spati...
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
Solution Manual for Mastering ArcGIS 7th Edition Price 007809514X 9780078095146
Watershed Delineation Using ArcMap
GEOSTATISTICAL_ANALYST
Corso Pat Jgrasshorton 2008 10 17
STATISTICAL_SURFACES.ppt
Geographic information system and remote sensing
Introduction to geomorphology in GRASS GIS - by Skyler Sorsby
Tutorial
Tutorialinterpolationam en
HEC-GEORASTutorials.PDF
2018 GIS in Education: GIS Watershed Delineation and Morphometric Analysis of...
Geospatial Data in R
Ad

Recently uploaded (20)

PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PPTX
famous lake in india and its disturibution and importance
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
PDF
Phytochemical Investigation of Miliusa longipes.pdf
DOCX
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PPTX
SCIENCE10 Q1 5 WK8 Evidence Supporting Plate Movement.pptx
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPTX
microscope-Lecturecjchchchchcuvuvhc.pptx
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Taita Taveta Laboratory Technician Workshop Presentation.pptx
INTRODUCTION TO EVS | Concept of sustainability
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
famous lake in india and its disturibution and importance
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
Phytochemical Investigation of Miliusa longipes.pdf
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
SCIENCE10 Q1 5 WK8 Evidence Supporting Plate Movement.pptx
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
Classification Systems_TAXONOMY_SCIENCE8.pptx
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
Biophysics 2.pdffffffffffffffffffffffffff
bbec55_b34400a7914c42429908233dbd381773.pdf
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
microscope-Lecturecjchchchchcuvuvhc.pptx
Ad

Create swath profiles in GRASS GIS

  • 1. This and more at my website: https://sites.google.com/site/sorsbysj/ LinkedIn: https://www.linkedin.com/in/skylersorsby Swath profiles in GRASS gis Author: Skyler Sorsby While traditional A-A’ line profiling can produce meaningful 2-D snapshots of topography, visuals of this type fail to capture the broader morphometric regime. Enter swath profiles (Fig. 1). As the data is collected for each point in the profile line, the region perpendicular to the profile line is statistically surveyed (max/mean/min, etc). Thus, the product is a statistically relevant 2-D rendition of a 3-D surface (Fig. 2). Some have proposed that swath profiles may be approximated by the superimposition of many single profiles. However, viewing multiple profiles superimposed is neither visually appealing nor representative—the values plotted only describe a set of finite lines, not a regional average. Other researchers write high-level algorithms in computing languages to accomplish the task, yet the visually powerful effects of a swath profile may be easily derived with simple tools within the GRASS gis interface. With this guide, I intend to clearly illustrate how GRASS may be used to this purpose. Geospatially, the idea is to order a set of vector points into a line, and tell each point to collect statistics of a raster DEM for a set interval perpendicular to the line. Practically, this may be accomplished with three tools: v.mkgrid, v.rast.stats, and v.to.points. 1) v.mkgrid This GRASS tool allows for the creation of a nxn grid of vector areas at a user-defined orientation. Each grid square has a topological feature known as a centroid. The centroid is the weighted center of the polygon; thus, for a perfectly symmetrical shape (like a grid square), each centroid appears halfway between the square’s edges. For a 1xn (columns x rows) matrix, this generates a single-column array of n user-defined rows, with each centroid falling upon a common straight line. Consequently, if the rows are broad and short, sampling elevation values (mean/min/max/etc) nwithin the bounds of each row can proxy “looking off to the side” for each centroid. The trick lies within distillation of these values, computed for each polygonal cell, to the centroid. 2) v.rast.stats Once the oriented 1xn grid is created with v.mkgrid, an underlying DEM may be sampled using v.rast.stats. You’ll need to add a column to your swath grid shapefile first, with v.db.addcol (the syntax elev double precision works for me)—you’ll need to add a column prior, anytime you wish to upload values to a vector with v.rast.stats. Figure 1. Shaded relief map of the Yakima fold-and-thrust belt. The black dashed line is a standard topographic line profile. The white box is a swath. N A A’
  • 2. This and more at my website: https://sites.google.com/site/sorsbysj/ LinkedIn: https://www.linkedin.com/in/skylersorsby Figure 2. Elevation profiles from the map in figure 1. The black and gray are the swath profile; the white dashed line is a line profile. 3) v.to.points When statistics have been assigned to each cell in the vector grid, these values may be distilled to the centroid, creating a new vector point file in the process. This is accomplished by using v.to.points— although documentation hints that this tool is meant for generating points along a line (not the case for us). This problem may be circumnavigated by checking the “centroids” box under the “feature type” heading. The result will be a shapefile of points, each point containing the max/mean/min/etc statistics for elevation of the topography immediately adjacent. Now, the only missing attribute is distance along the profile. Since each grid square was the same height and each centroid was centered vertically within each grid square, the distance between the points is simply the height of each grid square. Accordingly, distance will be a column of linearly-progressing values, easily auto-generated in Excel. 4) v.out.ogr The final step is to export your point shapefile to Excel as a .csv file, for auto-generation of a distance column and plotting. This tool may be finicky at times, sometimes requiring an entire file pathway to save to, others requiring only a name with which to label the containing folder (which will be placed in your ‘Users’ folder on the C:// drive). 5) Once you’ve exported your elevation graph of min/mean/max elevation from Excel as a pdf, you may easily augment it in a vector editing program like Inkscape (freeware) or Adobe Illustrator (certainly not freeware). In Inkscape, I’ve found that the easiest way to create a “filled” min/max envelope (see Fig. 2) is to make the min/max lines very narrow, connect them with two short vertical segments of the same color (to close the area), and use the paint bucket tool to give the area some pale color. In Illustrator, this task is much easier, as closing the area with two vertical lines automatically registers the shape as a polygon, whose interior “fill” may be set to any color you wish (no paint bucket tool involved-you get what you pay for!). 6) In the event that you’re working with data in a different coordinate system (say, you have a file of vector points along the course of a stream, with distance calculated for each point along the length of the stream—a curvy path), and you need to place your elevation swath profile into those coordinates. A A’
  • 3. This and more at my website: https://sites.google.com/site/sorsbysj/ LinkedIn: https://www.linkedin.com/in/skylersorsby The workflow is the same as above, but involves creation of a second grid, the same height and corner coordinates, but with much longer rows (to “reach out” orthogonal to the profile line and capture the values of the other point shapefile whose coordinates you’re attempting to reach into). Here is a simplified workflow for placing the swath profile into the coorinates of an adjacent river, for example, to compare the long profile with topographic relief: 1) Have a raster of river points, each point containing distance along the river (you may get a raster of river lines with the r.watershed, convert the raster to vector lines with r.to.vect, get rid of everything except your main channel with the digitizer tool, convert to raster points with v.to.rast (make sure it’s binary—river has a value of 1, else=NULL), multiply by the output of r.stream.distance to get a raster image of distance along the stream). 2) Create, as before a 1xn grid polygon for the swath profile with v.mkgrid (n is the number of rows you want) 3) Create another 1xn grid, VERY WIDE, such that the rows line up exactly vertically , but extend laterally completely across any river points with v.mkgrid 4) Convert the river points to a raster, if you haven’t done this already each cell containing distance values, with v.to.rast 5) Use v.rast.stats to get the mean distance for each row of the extended polygon (may have to use the Tk/Tcl GUI for GRASS—my python GUI seems buggy for this tool). 6) Use v.rast.stats to get the elevation statistics for each row of your swath polygon (as you did before). 7) Distill the swath rows to points with v.to.points, as you did before. 8) Use v.to.rast to convert the extended polygon to a raster with mean distance values (still by row) 9) Use v.what.rast to sample the extended polygon’s raster and obtain the mean river distance values for each row in the normal swath polygon. The basic premise is this: After creating your swath profile, you want to attach a “distance along the river” coordinate to each elevation—say, to compare structural relief of a linear set of features with a river’s long profile (and geometry), which certainly ISN’T linear. To do this, you’ll rasterize the river distance column of your river shapefile (points, I’m assuming), such that a new one column/many row grid oriented the same way as your swath grid but extending far beyond, can capture the mean values orthogonal to the swath. The extended grid, having captured the mean river distance, is now rasterized. The key is that the rasterization has now deposited this orthogonal mean river distance beneath the centroids of the original swath—effectively “reaching out and pulling in orthogonal river distance”. Using some sort of out-of-the-box spatial joining technique will not work as a substitute.
  • 4. This and more at my website: https://sites.google.com/site/sorsbysj/ LinkedIn: https://www.linkedin.com/in/skylersorsby Figure 3. Map showing the original swath (the narrow grid), the wider swath (whose sole purpose is to sample river distances, to relaty to the original swath). When the river distances are used, rather than the straight-line profile distance, the original swath will align with river-parallel features (useful for contrasting with changes in planform and geometry as topographic features are crossed). Figure 4. A pseudo “swath profile”, made from superimposing adjacent line profiles. Needless to say, it’s messier and less statistically relevant than a real swath. , , River points containing downstream distance Centroids to which swath values are distilled Large swath grid, to capture river distances for profile Original swath
  • 5. This and more at my website: https://sites.google.com/site/sorsbysj/ LinkedIn: https://www.linkedin.com/in/skylersorsby