Xyz2Raster¶
Converts a text file of XYZ triplets on a regular grid into a raster. Many elevation models, especially the lidar ones of the public administrations, are distributed this way: a line for each cell, with the coordinates of its center and its elevation.
The points must be on a regular grid, whose resolution has to be given, together with the coordinate reference system of the coordinates, since the text file doesn’t have them. Each point becomes the value of the cell centered on it, and the cells without a point are novalue: it is a conversion, not an interpolation. To make a raster from scattered points, as the ones of a survey, use SurfaceInterpolator.
The values can be separated by spaces, tabs or by a given separator; the lines that are not three numbers, as a header, are skipped.
Details¶
The points must be the centers of the cells of a regular grid with the given resolution, as written by Raster2Xyz: the bounds of the raster are the ones of the points, enlarged by half a cell. It is not an interpolation: the cells without a point are novalue, and the points that are not on the grid end up in the cell they fall in. To make a raster from scattered points, use SurfaceInterpolator.
The lines that are not three numbers, as a header, are skipped. The values are separated by spaces or tabs, or by the given separator.
Parameters¶
Converts a text file of XYZ triplets on a regular grid, as the ones of the lidar elevation models distributed as text, into a raster: each point becomes the value of the cell centered on it.
Toolbox folder: Raster Processing
Status: Certified
Keywords: Raster, Conversion
Authors: Andrea Antonello
Class: org.hortonmachine.modules.Xyz2Raster
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
file |
The text file of the XYZ triplets, on a regular grid. |
||
|
Double |
The resolution of the grid of the points, in the units of the coordinates. |
||
|
CRS code |
The code of the coordinate reference system of the points, as authority and number (ex. EPSG:32632). |
||
|
String |
The separator of the values, as a regular expression. If not set, any sequence of spaces or tabs. |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The generated raster. |
Example¶
The example reads back into a raster the triplets of the sample elevation model of the manual written by Raster2Xyz:
import org.hortonmachine.modules.Raster2Xyz
import org.hortonmachine.modules.Xyz2Raster
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// the elevation model as a text file of triplets: easting, northing and elevation
var raster2xyz = new Raster2Xyz()
raster2xyz.inRaster = folder + "dtm_flanginec.tif"
raster2xyz.outFile = folder + "dtm_flanginec.xyz"
raster2xyz.process()
// and back to a raster, with the resolution and the CRS of the points
var xyz2raster = new Xyz2Raster()
xyz2raster.inFile = folder + "dtm_flanginec.xyz"
xyz2raster.pRes = 10.0
xyz2raster.pCode = "EPSG:3003"
xyz2raster.outRaster = folder + "dtm_from_xyz.tif"
xyz2raster.process()