Given the following .vrt file which I manually created:

    <OGRVRTLayer name="DGM5_BE">
        <GeometryField encoding="PointFromColumns" x="x" y="y" z="d"/>

and the associated DGM5_BE.txt - here are the first lines:


I run the following command to convert the DGM5:

$ gdal_grid -of GTiff -ot Float32 -l DGM5_BE DGM5_BE.vrt DGM5_BE.tif

This fails with the following error message:

ERROR 1: Failed to open datasource `DGM5_BE.txt'.
No point geometry found on layer DGM5_BE, skipping.

2 Answers 2


From the CSV driver documentation:

Starting with GDAL 1.8.0, for files structured as CSV, but not ending with .CSV extension, the 'CSV:' prefix can be added before the filename to force loading by the CSV driver.

Either rename DGM5_BE.txt to DGM5_BE.csv or change the <SrcDataSource> element to:

  • Thx. I can't believe how long it takes to calculate a TIFF! I already added --config GDAL_NUM_THREADS ALL_CPUS. Is there recommendable format other than TIFF which can be used in QGIS?
    – JJD
    Commented Jul 4, 2014 at 13:47
  • The problem is that triangulation is only a single thread process, irrespective of how many CPU threads you allow this process it can only use 1 to triangulate with the other threads for reading/writing. There are options that do slow down a TIFF, what compression are you using? I don't think you will get any more performance from this process regardless of the output format. Commented Aug 9, 2018 at 3:58

For what its worth I created a demo that shows example usage of gdal_grid.

def main():
    Demo using gdal_grid


    from os.path import exists
    import ubelt as ub
    import geopandas as gpd
    import numpy as np

    # Generate Demo Data Ungridded data
    # Generate a random value at points along the African continent
    xyz = []
    world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
    rng = np.random.RandomState(0)
    for shape in world[world['continent'] == 'Africa'].geometry:
        if shape.type == 'MultiPolygon':
            for geom in shape.geoms:
                for x, y in geom.exterior.coords:
                    z = rng.rand()
                    xyz.append((x, y, z))
        elif shape.type == 'Polygon':
            for x, y in shape.exterior.coords:
                z = rng.rand()
                xyz.append((x, y, z))
    xyz = np.array(xyz)

    # Write the demo data to a CSV file
    lines = ['x;y;d']
    for x, y, z in xyz:
    text = '\n'.join(lines)
    with open('tmp.csv', 'w') as file:

    # I was unable to get the command to work with the CSV file alone
    # I needed to create a VRT that pointed at the CVS file.
    with open('tmp.vrt', 'w') as file:
                <OGRVRTLayer name="tmp">
                    <GeometryField encoding="PointFromColumns" x="x" y="y" z="d"/>

    # Can modify these but they are not needed
    minx, miny = xyz.T[0:2].min(axis=1)
    maxx, maxy = xyz.T[0:2].max(axis=1)
    lonext = maxx - minx
    latext = maxy - miny
    ar = latext / lonext
    xres = int(512)
    yres = int(xres * ar)

    # Call the GDAL Grid command
    command = (
        'gdal_grid '
        # '-ot Float32 -of GTiff '
        # '-zfield d '
        # '-a_srs EPSG:4326 '
        # f'-txe {minx - 1} {maxy + 1} '
        # f'-tye {miny - 1} {maxx + 1} '
        # f'-outsize {xres} {yres} '
        # '-a invdist:power=2.0:smoothing=1.0 '
        # '-a nearest:radius1=1.0:radius2=1.0 '
        # '-a linear:radius=1.0 '
        'tmp.vrt tmp.tif')

    info = ub.cmd(command, verbose=3)
    assert info['ret'] == 0

    if exists('tmp.tif'):
        # Show the result if it worked
        import tifffile
        data = tifffile.imread('tmp.tif')
        from matplotlib import pyplot as plt
        print('data.shape = {!r}'.format(data.shape))

The result is this:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.