[GIS] GDAL grid produces NoData

gdalgrids-graticulesnodatarastervrt

I have a series of text files that represent X,Y,Z elevation data. I'm trying to use the GDAL grid command line tool to convert these text files to raster GeoTIFs. My files are space delimited and so I have created VRT files that point to the data so that GDAL can read them OK. The VRT files work. I can load the layers into QGIS and I can use ogrinfo to describe the data OK.

Many of my text data files convert to raster just fine. These are typically longer files with > 10,000 lines of data. However, my small files (< 5,000 lines) produce a raster with only NoData values.

I am using the linear algorithm. My points are evenly spaced at 1m and I've tried several radius values. The command that I'm using is:

C:/OSGeo4W64/bin/gdal_grid.exe -ot Float32 -of GTiff -txe 239982.0 240207.0 -tye 647659.0 648667.0 -outsize 225 1008 -a linear:radius=1 D:\Temp\19900928.vrt D:\Temp\19900928.tif

I've also tried the nearest neighbour algorithm and get some weird, partial values in the output GeoTiFF for these small files.

A sample source text file is available here:

https://gist.github.com/philipbaileynar/c9eb76880b8ce6fa8c786ca53d892b26

The corresponding VRT file is:

<?xml version="1.0" ?>
<OGRVRTDataSource>
    <OGRVRTLayer name="elevation_points">
        <SrcDataSource>CSV:D:\Temp\elevation_points.txt</SrcDataSource>
        <SrcLayer>elevation_points</SrcLayer>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>EPSG:2762</LayerSRS>
        <GeometryField encoding="PointFromColumns" srs="EPSG:2762" x="field_2" y="field_3" z="field_4"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

Can anyone help and figure out how to make GDAL grid produce a raster from these data please?

Best Answer

You can also try gdal_rasterize instead:

C:/OSGeo4W64/bin/gdal_rasterize.exe -ot Float32 -3d -tr 1 1 -of GTiff -te 239982.0 647659.0 240207.0 648667.0 -ts 225 1008 -a_nodata -9999 D:\Temp\19900928.vrt D:\Temp\199009.tif

The '-tr 1 1' will set the resolution at 1m which is what you want. Only problem with gdal_rasterize though is that if there's no points in the space, there won't be any raster pixels there. I.e. it won't do any extrapolation to fill in holes in your data, which may or may not be what you want.

enter image description here

Related Question