Profile¶
Extracts the profile of a raster along a line: its values at regular steps, every cell size, with their distance from the start of the line and their position. On an elevation model it gives the cross sections of the valleys and the long profiles of the rivers; on any other raster, how a value changes along a path.
The line is given as the coordinates of its vertexes, or as the lines of a vector. With a vector, each line gives a profile, written into a CSV file named after a field of the line. The values are the ones of the cells, not interpolated: on detailed elevation models this is precise enough, on coarse ones the profile shows the steps of the cells.
Details¶
The line is sampled every cell size, the smaller of the two resolutions, from its start to its end, which is always the last point. Each point takes the value of the cell it falls in, without interpolation; the points outside the raster or on novalues get the novalue -9999.
With coordinates, the profile is the output matrix. With a vector, each line gives a profile: with an output folder and an id field, each one is written into the CSV file named after its id; without them, only the first line is used. The mean slope of each profile, the mean of the slopes between its points, is printed.
Parameters¶
Extracts the profile of a raster along a line, given as coordinates or as the lines of a vector: the values of the raster at regular steps along the line, with their progressive distance and position.
Toolbox folder: Raster Processing
Status: Experimental
Keywords: OmsProfile, Raster
Authors: Andrea Antonello
Class: org.hortonmachine.modules.Profile
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
raster file |
The raster to sample, usually an elevation model. |
||
|
String |
The vertexes of the line, as a comma separated list of easting,northing pairs: easting1,northing1,easting2,northing2,… Used instead of the vector if given. |
||
|
vector file |
The optional vector of the lines to trace the profiles on. |
||
|
String |
With a vector, the field of the lines that names their CSV file. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output folder |
With a vector, the folder of the CSV files of the profiles, one per line. |
|
|
double[][] |
The profile of the last line, a row per point: progressive distance, value, easting, northing. |
Example¶
The example compares the section of a valley of the sample elevation model of the manual, dtm_flanginec.tif in docs/manual/modules/maps/data, before and after the dam built by BobTheBuilder, along its crest. It writes the two profiles into a table:
import org.hortonmachine.gears.utils.files.FileUtilities
import org.hortonmachine.modules.Profile
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// a section across the valley, along the crest of the dam of BobTheBuilder
var section = "1638168,5112472,1638492,5112148"
var terrain = new Profile()
terrain.inRaster = folder + "dtm_flanginec.tif"
terrain.inCoordinates = section
terrain.process()
var withDam = new Profile()
withDam.inRaster = folder + "dtm_dam.tif"
withDam.inCoordinates = section
withDam.process()
// each row of the profiles: progressive distance, elevation, easting, northing
var csv = new StringBuilder("distance,with_dam,terrain\n")
for (int i = 0; i < terrain.outProfile.length; i++) {
csv.append(String.format("%.1f,%.1f,%.1f%n", terrain.outProfile[i][0], withDam.outProfile[i][1],
terrain.outProfile[i][1]))
}
FileUtilities.writeFile(csv.toString(), new File(folder + "dam_section.csv"))
The section of the valley along the crest of the dam: the terrain descends into the valley and climbs the other slope, the dam fills the valley at 1310 m between the slopes.¶