[GIS] How to use gdal_grid with VRT

gdalimportrastervrt

It seems to be that I'm too stupid to use gdal_grid. I have a
file called dgm-10-epsg-32633.csv with equidistant samples 10x10m in this form.

  X,Y,Z
  386700,6068670.000,.000
  386710,6068670.000,.000
  386720,6068670.000,.000
  386730,6068670.000,.000
  386740,6068670.000,.000
  386750,6068670.000,.000
  386760,6068670.000,.000
  ...

Before I start the computation I've calculated the extent.

Extent3d default {
  nanZ 9.999000e+03
  minX 3.700000e+05
  maxX 4.200000e+05
  minY 6.000000e+06
  maxY 6.068670e+06
  minZ -4.148000e+01
  maxZ 1.596600e+02
  count 31307010
  centerX 3.948742e+05
  centerY 6.031587e+06
  centerZ 6.993280e+00
  rangeX 5.000000e+04
  rangeY 6.867000e+04
  rangeZ 2.011400e+02
}

to get the parameters for -txe and -tye and -outsize.

I wrote a vrt file and the content looks like this

<OGRVRTDataSource>
    <OGRVRTLayer name="dgm-10-epsg-32633">
        <SrcDataSource>dgm-10-epsg-32633.csv</SrcDataSource> 
    <LayerSRS>epsg:32633</LayerSRS> 
    <GeometryType>wkbPoint</GeometryType> 
    <GeometryField encoding="PointFromColumns" x="X" y="Y" z="Z"/> 
   </OGRVRTLayer>
</OGRVRTDataSource> 

and ogrifno gives me a valid response to data description.

$ ogrinfo -so dgm-10-epsg-32633.vrt
INFO: Open of `dgm-10-epsg-32633.vrt'
      using driver `VRT' successful.
1: dgm-10-epsg-32633 (Point)

If I call the commandline:

$ gdal_grid \
  -a nearest:radius1=10:radius2=10:angle=0.0:nodata=9999\
  -txe 3.7e+05 4.2e+05 \
  -tye 6e+06 6.06e+06 \
  -outsize 5000 6867 \
  -of GTiff -ot Float32 \
  -zfield Z \
  dgm-10-epsg-32633.vrt \
  dgm-10-epsg-32633.tif

I get always the help message without any explanation:

Usage: gdal_grid [--help-general] [--formats]
    [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
          CInt16/CInt32/CFloat32/CFloat64}]
    [-of format] [-co "NAME=VALUE"]
    [-zfield field_name]
    [-a_srs srs_def] [-spat xmin ymin xmax ymax]
    [-clipsrc <xmin ymin xmax ymax>|WKT|datasource|spat_extent]
    [-clipsrcsql sql_statement] [-clipsrclayer layer]

Available algorithms and parameters with their's defaults:
    Inverse distance to a power (default)
        invdist:power=2.0:smoothing=0.0:radius1=0.0:radius2=0.0:angle=0.0:max_points=0:min_points=0:nodata=0.0
    Moving average
        average:radius1=0.0:radius2=0.0:angle=0.0:min_points=0:nodata=0.0
    Nearest neighbor
        nearest:radius1=0.0:radius2=0.0:angle=0.0:nodata=0.0
    Various data metrics
        <metric name>:radius1=0.0:radius2=0.0:angle=0.0:min_points=0:nodata=0.0
        possible metrics are:
            minimum
            maximum
            range
            count
            average_distance
            average_distance_pts

What is wrong on this stuff?

Best Answer

It appears that you are missing the '-l dgm-10-epsg-32633' before your vrt-file. In essence, it doesn't know which layer of the vrt-file to use (even if there only is one layer). See the example in the man-page of gdal_grid: gdal.org/gdal_grid.html