# How to fill holes/missing values in XYZ data / a DEM with QGIS?

I have equidistant XYZ point (text) data that I used to create a point grid. However, it's not perfect - there are some holes. I then created a DSM raster from it, which obviously has the holes too. The holes range from a single point to larger areas (~50 or more points missing).

How do I patch up those holes? I tried to interpolate the raster, but that reduces the quality, and doesn't fix the zero "holes" - they're just slightly raised afterwards. Ideally I'd like to just fill those zero values with Z values from their neighbouring squares.

Another issue is that the XYZ data set isn't rectangular but like in the third attached image (red path). If I use a fill method, how do I avoid filling up the whole surrounding area?

• If you're creating the raster directly from points, then anywhere you have no points you'd get null values or zeros. If you actually want to fill in the holes at time of creation you need to interpolate from the points to a raster (IDW tool for example). If you want to fill them in from the raster, there's a tool called Euclidean Allocation in ArcGIS, but I don't know if there's an equivalent in QGIS. There are some other raster processing methods as well, but again I'm not very familiar with the raster tools available in QGIS. May 27, 2015 at 17:31

I suggest to break the process in the following steps.

1. If the points are equally spaced (what's obviously the case) determine the spacing in x- and y-direction
2. Interpolate an initial raster. I would suggest using a simple Inverse distance weighted algorithm.

QGIS Processing Toolbox \ SAGA \ Grid - Gridding \ Inverse distance weighted

- Give the spacing as argument for parameter Cellsize, and
- specify the Output extent as the extent of your points minus one half the spacing for xmin/ymin and plus one half the spacing for xmax/ymax. You get the extent of your points from layer properties - metadata
- Let the other parameters unchanged
- This should result in a grid with each cell equal to the value of the point right in the middle of the cell, and the holes filled according IDW algorithm, and values in the surrounding area
1. To get rid of these surrounding cells you have to mask the grid.
- Construct the Concave Hull of the input points as the minimum bounding polygon using this plugin

http://plugins.qgis.org/plugins/concavehull/

or

QGIS Processing Toolbox \ QGIS geoalgorithms \ Vector geometry tools \ Concave Hull

1. Convert the concave hull to a grid

QGIS Processing Toolbox \ SAGA \ Grid - Gridding \ Shapes to grid

1. and finally mask the interpolated grid with the gridded hull

QGIS Processing Toolbox \ SAGA \ Grid - Tools\ Grid masking

You can use interpolation plugin in QGIS. It takes the points as input , interpolates and gives raster as output.