1gdal_grid(1) General Commands Manual gdal_grid(1)
2
3
4
6 gdal_grid - .TH "gdal_grid" 1 "Fri Apr 22 2011" "GDAL"
7
9 gdal_grid - creates regular grid from the scattered data
10
12 Usage: gdal_grid [--help-general] [--formats]
13 [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
14 CInt16/CInt32/CFloat32/CFloat64}]
15 [-of format] [-co "NAME=VALUE"]
16 [-zfield field_name]
17 [-a_srs srs_def] [-spat xmin ymin xmax ymax]
18 [-l layername]* [-where expression] [-sql select_statement]
19 [-txe xmin xmax] [-tye ymin ymax] [-outsize xsize ysize]
20 [-a algorithm[:parameter1=value1]*] [-q]
21 <src_datasource> <dst_filename>
22
24 This program creates regular grid (raster) from the scattered data read
25 from the OGR datasource. Input data will be interpolated to fill grid
26 nodes with values, you can choose from various interpolation methods.
27
28 -ot type:
29 For the output bands to be of the indicated data type.
30
31 -of format:
32 Select the output format. The default is GeoTIFF (GTiff). Use the
33 short format name.
34
35 -txe xmin xmax:
36 Set georeferenced X extents of output file to be created.
37
38 -tye ymin ymax:
39 Set georeferenced Y extents of output file to be created.
40
41 -outsize xsize ysize:
42 Set the size of the output file in pixels and lines.
43
44 -a_srs srs_def:
45 Override the projection for the output file. The srs_def may be any
46 of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file
47 containing the WKT.
48
49 -zfield field_name:
50 Identifies an attribute field on the features to be used to get a Z
51 value from. This value overrides Z value read from feature geometry
52 record (naturally, if you have a Z value in geometry, otherwise you
53 have no choice and should specify a field name containing Z value).
54
55 -a [algorithm[:parameter1=value1][:parameter2=value2]...]:
56 Set the interpolation algorithm or data metric name and
57 (optionally) its parameters. See INTERPOLATION ALGORITHMS and DATA
58 METRICS sections for further discussion of available options.
59
60 -spat xmin ymin xmax ymax:
61 Adds a spatial filter to select only features contained within the
62 bounding box described by (xmin, ymin) - (xmax, ymax).
63
64 -clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent:
65 Adds a spatial filter to select only features contained within the
66 specified bounding box (expressed in source SRS), WKT geometry
67 (POLYGON or MULTIPOLYGON), from a datasource or to the spatial
68 extent of the -spat option if you use the spat_extent keyword. When
69 specifying a datasource, you will generally want to use it in
70 combination of the -clipsrclayer, -clipsrcwhere or -clipsrcsql
71 options.
72
73 -clipsrcsql sql_statement:
74 Select desired geometries using an SQL query instead.
75
76 -clipsrclayer layername:
77 Select the named layer from the source clip datasource.
78
79 -clipsrcwhere expression:
80 Restrict desired geometries based on attribute query.
81
82 -l layername:
83 Indicates the layer(s) from the datasource that will be used for
84 input features. May be specified multiple times, but at least one
85 layer name or a -sql option must be specified.
86
87 -where expression:
88 An optional SQL WHERE style query expression to be applied to
89 select features to process from the input layer(s).
90
91 -sql select_statement:
92 An SQL statement to be evaluated against the datasource to produce
93 a virtual layer of features to be processed.
94
95 -co 'NAME=VALUE':
96 Passes a creation option to the output format driver. Multiple -co
97 options may be listed. See format specific documentation for legal
98 creation options for each format.
99
100 -q:
101 Suppress progress monitor and other non-error output.
102
103 src_datasource:
104 Any OGR supported readable datasource.
105
106 dst_filename:
107 The GDAL supported output file.
108
110 There are number of interpolation algorithms to choose from.
111
112 invdist
113 Inverse distance to a power. This is default algorithm. It has
114 following parameters:
115
116 power:
117 Weighting power (default 2.0).
118
119 smoothing:
120 Smoothing parameter (default 0.0).
121
122 radius1:
123 The first radius (X axis if rotation angle is 0) of search ellipse.
124 Set this parameter to zero to use whole point array. Default is
125 0.0.
126
127 radius2:
128 The second radius (Y axis if rotation angle is 0) of search
129 ellipse. Set this parameter to zero to use whole point array.
130 Default is 0.0.
131
132 angle:
133 Angle of search ellipse rotation in degrees (counter clockwise,
134 default 0.0).
135
136 max_points:
137 Maximum number of data points to use. Do not search for more points
138 than this number. This is only used if search ellipse is set (both
139 radiuses are non-zero). Zero means that all found points should be
140 used. Default is 0.
141
142 min_points:
143 Minimum number of data points to use. If less amount of points
144 found the grid node considered empty and will be filled with NODATA
145 marker. This is only used if search ellipse is set (both radiuses
146 are non-zero). Default is 0.
147
148 nodata:
149 NODATA marker to fill empty points (default 0.0).
150
151 average
152 Moving average algorithm. It has following parameters:
153
154 radius1:
155 The first radius (X axis if rotation angle is 0) of search ellipse.
156 Set this parameter to zero to use whole point array. Default is
157 0.0.
158
159 radius2:
160 The second radius (Y axis if rotation angle is 0) of search
161 ellipse. Set this parameter to zero to use whole point array.
162 Default is 0.0.
163
164 angle:
165 Angle of search ellipse rotation in degrees (counter clockwise,
166 default 0.0).
167
168 min_points:
169 Minimum number of data points to use. If less amount of points
170 found the grid node considered empty and will be filled with NODATA
171 marker. Default is 0.
172
173 nodata:
174 NODATA marker to fill empty points (default 0.0).
175
176 Note, that it is essential to set search ellipse for moving average
177 method. It is a window that will be averaged when computing grid nodes
178 values.
179
180 nearest
181 Nearest neighbor algorithm. It has following parameters:
182
183 radius1:
184 The first radius (X axis if rotation angle is 0) of search ellipse.
185 Set this parameter to zero to use whole point array. Default is
186 0.0.
187
188 radius2:
189 The second radius (Y axis if rotation angle is 0) of search
190 ellipse. Set this parameter to zero to use whole point array.
191 Default is 0.0.
192
193 angle:
194 Angle of search ellipse rotation in degrees (counter clockwise,
195 default 0.0).
196
197 nodata:
198 NODATA marker to fill empty points (default 0.0).
199
201 Besides the interpolation functionality gdal_grid can be used to
202 compute some data metrics using the specified window and output grid
203 geometry. These metrics are:
204
205 minimum:
206 Minimum value found in grid node search ellipse.
207
208 maximum:
209 Maximum value found in grid node search ellipse.
210
211 range:
212 A difference between the minimum and maximum values found in grid
213 node search ellipse.
214
215 count:
216 A number of data points found in grid node search ellipse.
217
218 average_distance:
219 An average distance between the grid node (center of the search
220 ellipse) and all of the data points found in grid node search
221 ellipse.
222
223 average_distance_pts:
224 An average distance between the data points found in grid node
225 search ellipse. The distance between each pair of points within
226 ellipse is calculated and average of all distances is set as a grid
227 node value.
228
229 All the metrics have the same set of options:
230
231 radius1:
232 The first radius (X axis if rotation angle is 0) of search ellipse.
233 Set this parameter to zero to use whole point array. Default is
234 0.0.
235
236 radius2:
237 The second radius (Y axis if rotation angle is 0) of search
238 ellipse. Set this parameter to zero to use whole point array.
239 Default is 0.0.
240
241 angle:
242 Angle of search ellipse rotation in degrees (counter clockwise,
243 default 0.0).
244
245 min_points:
246 Minimum number of data points to use. If less amount of points
247 found the grid node considered empty and will be filled with NODATA
248 marker. This is only used if search ellipse is set (both radiuses
249 are non-zero). Default is 0.
250
251 nodata:
252 NODATA marker to fill empty points (default 0.0).
253
255 Often you have a text file with a list of comma separated XYZ values to
256 work with (so called CSV file). You can easily use that kind of data
257 source in gdal_grid. All you need is create a virtual dataset header
258 (VRT) for you CSV file and use it as input datasource for gdal_grid.
259 You can find details on VRT format at Virtual Format description page.
260
261 Here is a small example. Let we have a CSV file called dem.csv
262 containing
263
264 Easting,Northing,Elevation
265 86943.4,891957,139.13
266 87124.3,892075,135.01
267 86962.4,892321,182.04
268 87077.6,891995,135.01
269
270 For above data we will create dem.vrt header with the following
271 content:
272
273 <OGRVRTDataSource>
274 <OGRVRTLayer name="dem">
275 <SrcDataSource>dem.csv</SrcDataSource>
276 <GeometryType>wkbPoint</GeometryType>
277 <GeometryField encoding="PointFromColumns" x="Easting" y="Northing" z="Elevation"/>
278 </OGRVRTLayer>
279 </OGRVRTDataSource>
280
281 This description specifies so called 2.5D geometry with three
282 coordinates X, Y and Z. Z value will be used for interpolation. Now you
283 can use dem.vrt with all OGR programs (start with ogrinfo to test that
284 everything works fine). The datasource will contain single layer called
285 'dem' filled with point features constructed from values in CSV file.
286 Using this technique you can handle CSV files with more than three
287 columns, switch columns, etc.
288
289 If your CSV file does not contain column headers then it can be handled
290 in the following way:
291
292 <GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
293
294 Comma Separated Value description page contains details on CSV format
295 supported by GDAL/OGR.
296
298 The following would create raster TIFF file from VRT datasource
299 described in READING COMMA SEPARATED VALUES section using the inverse
300 distance to a power method. Values to interpolate will be read from Z
301 value of geometry record.
302
303 gdal_grid -a invdist:power=2.0:smoothing=1.0 -txe 85000 89000 -tye 894000 890000 -outsize 400 400 -of GTiff -ot Float64 -l dem dem.vrt dem.tiff
304
305 The next command does the same thing as the previos one, but reads
306 values to interpolate from the attribute field specified with -zfield
307 option instead of geometry record. So in this case X and Y coordinates
308 are being taken from geometry and Z is being taken from the 'Elevation'
309 field.
310
311 gdal_grid -zfield "Elevation" -a invdist:power=2.0:smoothing=1.0 -txe 85000 89000 -tye 894000 890000 -outsize 400 400 -of GTiff -ot Float64 -l dem dem.vrt dem.tiff
312
314 Andrey Kiselev <dron@ak4719.spb.edu>
315
316
317
318GDAL Fri Apr 22 2011 gdal_grid(1)