LinesRasterizer

Converts lines into a raster: the cells crossed by a line get its value, a constant or the one of a numeric field, the others are novalue. The lines become chains of cells one cell wide and connected also by the corners, as the paths of the flow directions, so a vector network, as a mapped river network, can take the place of the network extracted from an elevation model, or burn the channels into it with Carver.

The grid is given by its bounds and its number of rows and columns, or it is taken from a raster, which must have the coordinate reference system of the lines. For polygons, use ScanLineRasterizer; for points, PointsRasterizer.

Details

Every segment of the lines becomes the chain of cells that joins the cells of its two vertices, with the Bresenham algorithm: the chain is 8-connected, one cell wide, as a path of the flow directions, so a rasterized network can be used where the network extracted from the elevation would be. A segment that touches a cell only on a corner can leave it out. Where lines cross, the cell keeps the largest value, as the higher order of two streams that join. The parts of the lines outside of the grid are left out.

The value of the cells is the one of the numeric field of the line, or the constant category without a field. The grid is the one of the optional raster, or the one of the bounds, rows and columns.

Parameters

Converts lines to a raster: the cells crossed by a line get its value, the others are novalue.

Toolbox folder: Raster Processing
Status: Certified
Keywords: Raster, Vector, Lines, Rasterize
Authors: Andrea Antonello
Class: org.hortonmachine.modules.LinesRasterizer

Inputs

Parameter

Type

Unit

Default

Description

inVector

vector file

The lines to rasterize.

fCat

String

The optional numeric field of the lines with the value of their cells.

pCat

double

1.0

The value of the cells if no field is given.

inRaster

raster file

An optional raster that gives the grid, instead of bounds, rows and columns.

pNorth

Double

The north bound of the region to consider

pSouth

Double

The south bound of the region to consider

pWest

Double

The west bound of the region to consider

pEast

Double

The east bound of the region to consider

pRows

Integer

The rows of the region to consider

pCols

Integer

The cols of the region to consider

Outputs

Parameter

Type

Unit

Description

outRaster

output file

The rasterized lines.

Example

The example runs on the sample elevation model of the manual, dtm_flanginec.tif in docs/manual/modules/maps/data, each module on the outputs of the previous ones. It rasterizes the network of NetworkAttributesBuilder with the Strahler order of its reaches:

import org.hortonmachine.modules.LinesRasterizer

// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"

// the network of NetworkAttributesBuilder, with the Strahler order of each reach, on the grid of the elevation model
var rasterizer = new LinesRasterizer()
rasterizer.inVector = folder + "net_attributes.shp"
rasterizer.fCat = "strahler"
rasterizer.inRaster = folder + "dtm_flanginec.tif"
rasterizer.outRaster = folder + "net_strahler.tif"
rasterizer.process()
The network rasterized with the Strahler order of each reach.

The network rasterized with the Strahler order of its reaches: at the confluences the cell keeps the higher order.