GDAL-VECTOR-GRID(1)
β¨ NAME β¨
okay so bestie, this is gdal-vector-grid(1) β the manual page for gdal-vector-grid β and it does exactly what it says on the tin: Create a regular grid from scattered points. π
Added in version 3.11. π
πΈ SYNOPSIS πΈ
Usage: gdal vector grid <SUBCOMMAND> [OPTIONS]
where <SUBCOMMAND> is one of:
- average: Create a regular grid from scattered points using moving average interpolation.
- average-distance: Create a regular grid from scattered points using the average distance between the grid node (center of the search ellipse) and all of the data points in the search ellipse.
- average-distance-points: Create a regular grid from scattered points using the average distance between the data points in the search ellipse.
- count: Create a regular grid from scattered points using the number of points in the search ellipse.
- invdist: Create a regular grid from scattered points using weighted inverse distance interpolation.
- invdistnn: Create a regular grid from scattered points using weighted inverse distance interpolation nearest neighbour.
- linear: Create a regular grid from scattered points using linear/barycentric interpolation.
- maximum: Create a regular grid from scattered points using the maximum value in the search ellipse.
- minimum: Create a regular grid from scattered points using the minimum value in the search ellipse.
- nearest: Create a regular grid from scattered points using nearest neighbor interpolation.
- range: Create a regular grid from scattered points using the difference between the minimum and maximum values in the search ellipse.
Common Options:
-h, --help Display help message and exit
--json-usage Display usage as JSON document and exit
--config <KEY>=<VALUE> Configuration option [may be repeated]
π DESCRIPTION π
This program is giving main character energy: it creates a regular grid (a raster, bestie) from scattered data that it reads from a vector dataset. The input data gets interpolated to fill grid nodes with values, and you can choose from various interpolation methods. Slay. π¦
You can also set the GDAL_NUM_THREADS configuration option to parallelize the processing. The value to specify is the number of worker threads, or ALL_CPUS to use all the cores/CPUs of the computer. No cap, that's a whole multitasking moment. β‘
Since GDAL 3.12, this algorithm can be part of a gdal pipeline. π
β¨ OPTIONS COMMON TO ALL ALGORITHMS β¨
π Standard options π
-f,--of,--format,--output-format <OUTPUT-FORMAT>β Which output raster format to use. Allowed values may be given bygdal --formats | grep raster | grep + | sort. π--co,--creation-option <NAME>=<VALUE>β Many formats have one or more optional dataset creation options that can be used to control particulars about the file created. For instance, the GeoPackage driver supports creation options to control the version. π
May be repeated.
The dataset creation options available vary by format driver, and some simple formats have no creation options at all. A list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. See Vector drivers format specific documentation for legal creation options for each format.
Note that dataset creation options are different from layer creation options. π
--overwriteβ Allow program to overwrite existing target file or dataset. Otherwise, by default, gdal errors out if the target file or dataset already exists. so yes, it will scream if you don't mean it π-l,--layer,--layer-name <LAYER-NAME>β Indicates the layer(s) from the datasource that will be used for input features. May be specified multiple times. π--sql <SQL>|@<filename>β An SQL statement to be evaluated against the datasource to produce a virtual layer of features to be burned in. The@filenamesyntax can be used to indicate that the content is in the pointed filename. β¨--extent <xmin>,<ymin>,<xmax>,<ymax>β Set georeferenced extents. The values must be expressed in georeferenced units. If not specified, the extent of the output file will be the extent of the vector layers. πΊοΈ--resolution <xres>,<yres>β Set target resolution. The values must be expressed in georeferenced units. Both must be positive values. Note that--resolutioncannot be used with--size. π«Ά--size <xsize>,<ysize>β Set output file size in pixels and lines. Note that--sizecannot be used with--resolution. π--ot,--datatype,--output-data-type <OUTPUT-DATA-TYPE>β Force the output bands to be of the indicated data type. Defaults toFloat64. π--crs <CRS>β Override the projection for the output file. If not specified, the projection of the input vector file will be used if available. When using this option, no reprojection of features from the CRS of the input vector to the specified CRS of the output raster, so use only this option to correct an invalid source CRS. The<CRS>may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4,EPSG:nor a file containing the WKT. π--bbox <xmin>,<ymin>,<xmax>,<ymax>β Select only points contained within the specified bounding box. π¦--zfield <field_name>β Identifies an attribute field on the features to be used to get a Z value from. This value overrides the Z value read from the feature geometry record (naturally, if you have a Z value in the geometry, otherwise you have no choice and should specify a field name containing a Z value). π§--zincrease <increase_value>β Addition to the attribute field on the features to be used to get a Z value from. The addition should be the same unit as the Z value. The result value will be Z value + Z increase value. The default value is0. β--zmultiply <multiply_value>β This is multiplication ratio for the Z field. This can be used for a shift from e.g. feet to meters or from elevation to depth. The result value will be(Z value + Z increase value) * Z multiply value. The default value is1. π₯
π¦ Advanced options π¦
--oo,--open-option <NAME>=<VALUE>β Dataset open option (format specific). May be repeated. πΈ--if,--input-format <format>β Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions. May be repeated. π
π INVDIST ALGORITHM π
Interpolation using an inverse distance to a power. β¨
When --min-points-per-quadrant or --max-points-per-quadrant is specified, the actual algorithm used is "invdistnn". π
π Options π
--power <val>β Weighting power (default2.0). β‘--smoothing <val>β Smoothing parameter (default0.0). π§΄--radius <val>β Set first and second radius (mutually exclusive with--radius1and--radius2). By default, uses the whole point array. π―--radius1 <val>β The first radius (X axis if rotation angle is0) of the search ellipse. By default, uses the whole point array. π--radius2 <val>β The second radius (Y axis if rotation angle is0) of the search ellipse. By default, uses the whole point array. πͺοΈ--angle <val>β Angle of search ellipse rotation in degrees (counter clockwise, default is0). π--max-points <val>β Maximum number of data points to use. Do not search for more points than this number. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation. π«--min-points <val>β Minimum number of data points to use. If less points in the search ellipse than the specified value are found, the grid node considered empty and will be filled with the nodata value. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation. π³οΈ--max-points-per-quadrant <val>β Maximum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will only take into account up tomax_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated. π²--min-points-per-quadrant <val>β Minimum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will collect at leastmin_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated. π³--nodata <val>β Nodata value to fill empty points (default is0). π
π¦ INVDISTNN ALGORITHM π¦
okay so this one is interpolation using an inverse distance to a power, but with nearest neighbor searching instead of the whole-array vibe. it's ideal when --max-points is used, fr fr. π
and the quadrant tea, bestie: when --min-points-per-quadrant or --max-points-per-quadrant is specified, the search will start with the closest point to the point being interpolated from the first quadrant, then the closest point to the point being interpolated from the second quadrant, etc. up to the 4th quadrant, and will continue with the next closest point in the first quadrant, etc. until --max-points and/or --max-points-per-quadrant thresholds are reached. it's giving methodical. it's giving organized. β¨
Required option
--radius <val>β Set search radius (mutually exclusive with--radius1and--radius2). Required. like, you literally cannot skip this one bestie. π«Ά
Options
--power <val>β Weighting power (default2.0).--smoothing <val>β Smoothing parameter (default0.0).--max-points <val>β Maximum number of data points to use. Do not search for more points than this number. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation.--min-points <val>β Minimum number of data points to use. If less points in the search ellipse than the specified value are found, the grid node considered empty and will be filled with the nodata value. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation.--max-points-per-quadrant <val>β Maximum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will only take into account up tomax_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--min-points-per-quadrant <val>β Minimum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will collect at leastmin_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--nodata <val>β Nodata value to fill empty points (default is0).
πΈ AVERAGE ALGORITHM πΈ
Interpolation using a moving average algorithm. soft, smooth, gentle β the algorithm equivalent of a weighted blanket. π
and yep, the quadrant saga continues: when --min-points-per-quadrant or --max-points-per-quadrant is specified, the search will start with the closest point to the point being interpolated from the first quadrant, then the closest point to the point being interpolated from the second quadrant, etc. up to the 4th quadrant, and will continue with the next closest point in the first quadrant, etc. until --max-points and/or --max-points-per-quadrant thresholds are reached. same energy, different algorithm bestie π
Options
--radius <val>β Set first and second radius (mutually exclusive with--radius1and--radius2. By default, uses the whole point array.--radius1 <val>β The first radius (X axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--radius2 <val>β The second radius (Y axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--angle <val>β Angle of search ellipse rotation in degrees (counter clockwise, default is0).--max-points <val>β Maximum number of data points to use. Do not search for more points than this number. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation.--min-points <val>β Minimum number of data points to use. If less points in the search ellipse than the specified value are found, the grid node considered empty and will be filled with the nodata value. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation.--max-points-per-quadrant <val>β Maximum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will only take into account up tomax_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--min-points-per-quadrant <val>β Minimum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will collect at leastmin_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--nodata <val>β Nodata value to fill empty points (default is0).
π¦ NEAREST ALGORITHM π¦
Interpolation using a nearest neighbor algorithm. it does exactly what it says on the tin, no notes, no cap. take the closest point's value and move on. iconic behavior honestly π
Options
--radius <val>β Set first and second radius (mutually exclusive with--radius1and--radius2. By default, uses the whole point array.--radius1 <val>β The first radius (X axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--radius2 <val>β The second radius (Y axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--angle <val>β Angle of search ellipse rotation in degrees (counter clockwise, default is0).--nodata <val>β Nodata value to fill empty points (default is0).
β¨ LINEAR ALGORITHM β¨
Linear interpolation by computing a Delaunay triangulation of the point cloud, finding in which triangle of the triangulation the point is, and by doing linear interpolation from its barycentric coordinates within the triangle. If the point is not in any triangle, depending on the radius, the algorithm will use the value of the nearest point or the nodata value. honestly the geometry of it all? ate. π₯
Options
--radius <val>β In case the point to be interpolated does not fit into a triangle of the Delaunay triangulation, use that maximum distance to search a nearest neighbour, or use nodata otherwise. If unset, the search distance is infinite. If set to0, nodata value will be always used.--nodata <val>β Nodata value to fill empty points (default is0).
π DATA METRICS ALGORITHMS π
plot twist bestie β besides the interpolation functionality, gdal vector grid can be used to compute some data metrics using the specified window and output grid geometry. these metrics are:
- minimum: Minimum value found in grid node search ellipse.
- maximum: Maximum value found in grid node search ellipse.
- range: A difference between the minimum and maximum values found in grid node search ellipse.
- count: A number of data points found in grid node search ellipse.
- average-distance: An average distance between the grid node (center of the search ellipse) and all of the data points found in grid node search ellipse.
- average-distance-points: An average distance between the data points found in grid node search ellipse. The distance between each pair of points within ellipse is calculated and average of all distances is set as a grid node value.
All the metrics have the same set of options: π
--radius <val>β Set first and second radius (mutually exclusive with--radius1and--radius2. By default, uses the whole point array.--radius1 <val>β The first radius (X axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--radius2 <val>β The second radius (Y axis if rotation angle is0) of the search ellipse. By default, uses the whole point array.--angle <val>β Angle of search ellipse rotation in degrees (counter clockwise, default is0).--min-points <val>β Minimum number of data points to use. If less points in the search ellipse than the specified value are found, the grid node considered empty and will be filled with the nodata value. This may only used if the search ellipse is set (both radii are non-zero). By default, no limitation.--max-points-per-quadrant <val>β Maximum number of data points to use per quadrant. By default, no limitation. When specified, the algorithm will only take into account up tomax_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--min-points-per-quadrant <val>β Minimum number of data points to use per quadrant. By default, no limitation. If that number is not reached, the point being interpolated will be set with the nodata value. When specified, the algorithm will collect at leastmin_points_per_quadrantpoints for each of the right-top, left-top, right-bottom and right-top quadrant relative to the point being interpolated.--nodata <val>β Nodata value to fill empty points (default is0).
and once again for the people in the back: when --min-points-per-quadrant or --max-points-per-quadrant is specified, the search will start with the closest point to the point being interpolated from the first quadrant, then the closest point to the point being interpolated from the second quadrant, etc. up to the 4th quadrant, and will continue with the next closest point in the first quadrant, etc. until --max-points and/or --max-points-per-quadrant thresholds are reached. π
πΈ READING COMMA SEPARATED VALUES πΈ
okay bestie listen up, because this part is the cheat code π
Sometimes all you have is a text file full of comma separated XYZ values (yes, the classic CSV). and you're like... can gdal vector grid eat this? and the answer is YES but you need to do a little ritual first β¨
All you have to do is make a virtual dataset header (VRT) for your CSV file and then hand that VRT over as the input datasource for gdal vector grid. The whole VRT format tea is on the VRT -- OGR Virtual Format description page if you want the deep lore.
Here's a lil baby example. Say we got a CSV file named dem.csv that looks like:
Easting,Northing,Elevation
86943.4,891957,139.13
87124.3,892075,135.01
86962.4,892321,182.04
87077.6,891995,135.01
...
For that data we're gonna create a dem.vrt header that says:
<OGRVRTDataSource>
<OGRVRTLayer name="dem">
<SrcDataSource>dem.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<GeometryField encoding="PointFromColumns" x="Easting" y="Northing" z="Elevation"/>
</OGRVRTLayer>
</OGRVRTDataSource>
So what is this actually saying π§ It specifies a so-called 2.5D geometry with three coordinates: X, Y and Z. And the Z value? That's the one getting used for the interpolation. iconic behaviour honestly.
Now you can use dem.vrt with all OGR programs β start with ogrinfo to test that everything works fine π The datasource will contain a single layer called "dem" filled with point features constructed from the values in the CSV file. And with this technique you can handle CSV files with more than three columns, switch columns around, etc. the possibilities are endless fr fr.
okay now the final step:
gdal vector grid invdist dem.vrt demv.tif
Or, if we do not wish to use a VRT file:
gdal vector grid invdist -l dem -oo X_POSSIBLE_NAMES=Easting \
-oo Y_POSSIBLE_NAMES=Northing --zfield=Elevation dem.csv dem.tif
And if your CSV file does not contain column headers, it can be handled in the VRT file like this:
<GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
The Comma Separated Value (.csv) description page has all the details on the CSV format that GDAL supports, if you're nosy like me π
Added in version 3.12. (yes it's new, we love a fresh drop β¨)
π¦ GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) π¦
This program supports serializing the command line as a JSON file using the GDALG output format. That resulting file can then be opened as a raster dataset using the GDALG: GDAL Streamed Algorithm driver, and it'll apply the specified pipeline in a on-the-fly / streamed way. slay, no temp copies, just vibes π
NOTE: However β and this is the important bit β this algorithm is not natively streaming compatible. Consequently a temporary dataset will be generated, which may cause significant processing time at opening. so like... don't be shocked when it sits there thinking for a while, it's doing its best π
π RETURN STATUS CODE π
The program returns status code 0 in case of success, and non-zero in case of error. And lowkey important: non-blocking errors emitted as warnings are considered as a successful execution. so a warning is not a fail, okay? don't panic π«Ά
π EXAMPLES π
β¨ Example 1: Create a raster from a VRT datasource using inverse distance to a power β¨
gdal vector grid invdist --power=2.0 --smoothing=1.0 --extent=85000,894000,89000,890000 \
--size=400,400 -l dem dem.vrt dem.tif
This example creates a raster TIFF file from the VRT datasource described in the Reading comma separated values section, using the inverse distance to a power method. Values to interpolate will be read from the Z value of the geometry record. classic π
πΈ Example 2: Read values to interpolate from an attribute field πΈ
gdal vector grid invdist --zfield=Elevation --config GDAL_NUM_THREADS ALL_CPUS \
--power=2.0 --smoothing=1.0 --extent=85000,894000,89000,890000 \
--size=400,400 -l dem dem.vrt dem.tif
This command does the same thing as the previous one, but it reads the values to interpolate from the attribute field specified with the --zfield option instead of the geometry record. So in this case X and Y coordinates are being taken from the geometry and Z is being taken from the "Elevation" field. oh and GDAL_NUM_THREADS is also set to parallelize the computation, because we're efficient like that β
π AUTHOR π
Even Rouault <even.rouault@spatialys.com>
π COPYRIGHT π
1998-2026
and that's the whole page bestie, you made it to the end π₯Ήπ this was the GDAL-VECTOR-GRID(1) manual page, dated Aug 18, 2026 β go grid something cute, ily, bye π¦
π¦ where this page comes from
- alpine 3.24: gdal-doc 3.13.3-r0 Β· MIT
- arch rolling: gdal 3.13.3-6 Β· MIT
- ubuntu stonking: gdal-bin 3.13.3+dfsg-1ubuntu4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms