How to Interpolate Over 2 Million Points Quickly and Without Freezing - Tutorial

Interpolating large volumes of spatial data through the QGIS graphical interface is often a headache: the process takes too long or, even worse, the program freezes while consuming all system resources. In this tutorial, we will show you how to interpolate nearly 2 million points in less than two minutes using the OSGeo4W Shell and GDAL commands with the IDW method. By creating a virtual layer file (.vrt), you will learn a highly efficient, reliable, and lightweight workflow that enables you to work with millions of data points without being constrained by the limits of the GUI.

Tutorial

Code

For the virtual layer:

<OGRVRTDataSource>
    <OGRVRTLayer name="points">
        <SrcDataSource relativeToVRT="1">CSV:2022-08-19-UTM-25cm.xyz</SrcDataSource>
        <SrcLayer>2022-08-19-UTM-25cm</SrcLayer>
        <OpenOptions>
            <OOI key="SEPARATOR">TAB</OOI>
            <OOI key="HEADERS">NO</OOI>
        </OpenOptions>
        <GeometryType>wkbPoint</GeometryType>
        <GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

GDAL command:

gdal_grid -a invdistnn:power=2.0:max_points=12:radius=20:nodata=-9999 -txe 697086.0 697829.0 -tye 4345594.0 4346001.0 -tr 1.0 1.0 -zfield "field_3" -of GTiff --config GDAL_NUM_THREADS ALL_CPUS points.vrt output_1m_grid.tif

Input data

Download the data from this link.

Comment

Saul Montoya

Saul Montoya es Ingeniero Civil graduado de la Pontificia Universidad Católica del Perú en Lima con estudios de postgrado en Manejo e Ingeniería de Recursos Hídricos (Programa WAREM) de la Universidad de Stuttgart con mención en Ingeniería de Aguas Subterráneas y Hidroinformática.

 

Suscribe to our online newsletter

Subscribe for free newsletter, receive news, interesting facts and dates of our courses in water resources.