How would I fix my DEM because it has holes?
I need to maybe extrapolate from surrounding terrain.
Here is the picture
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
There is a elevation void raster function in arcmap. This function uses the Plane Fitting/IDW void fill method. First a basic method is used, where the average of the eight neighboring values are calculated to fill small voids, then the plane fitting method is applied. If the error of the plane fitting method is too large, an inverse distance weighted (IDW) algorithm is applied.
It's a raster function and needs to be applied as part of a function chain. (C/O Luke)
The first answer on this GeoNet post makes sense to me. It reads:
I use the following method to fill gaps in DEM. I uses a moving window that searches the DEM for Null data values and fills them with an average of the surrounding pixels.
new_DEM_name = con(isnull(old_DEM_name), focalmean(old_DEM_name, rectangle,4,4), old_DEM_name)
change "new_DEM_name" to anything that you want. "old_DEM_name" is the name of your DEM that has gaps in the data. You can adjust the size of the window by change 4,4 to 6,6 or anything you want.
answer credits : jmeisel
The previous answer could be applied also using the raster calculator, by writing something like:
Con(IsNull("your_raster_with_voids"), FocalStatistics("your_raster_with_voids", NbrRectangle(4,4,"CELL"), "MEAN"),"your_raster_with_voids")
You could change NbrRectangle and MEAN to find different solutions. I tried to use NbrCircle and MINIMUM instead, but I never got satisfying results.
Usually, voids in a DEM come from a water body. If not, try to find another DEM to find missing values.
so the best way to fill it is to use the minimum value of the observed height values, because with the mean value you would have water level above the elevation of some banks. There are several ways to do it, here is an easy way step by step. Special care is needed if there is a dam that is not visible at the resolution of your DEM. In this case, you should rather define the elevation manually.
1) identify pixels with no values and assign them a value of 1
holes = Con(isnull("mydem"), 1, 0)
2) create a buffer around the patches of 1 to get all the pixels around each "hole"
holes_buf = Expand(holes)
3) assign an unique value to each patch
groups = RegionGroup("holes_buf")
4) run the zonal statistics for each patch
zonStat = ZonalStatistics (groups, "VALUE", "mydem", "MINIMUM")
5) replace hole values by zonal stat values. Additionnal contraint could be added based on the "group" values in order to avoid filling the "true" NoData outside of the area were the DEM has been produced.
Con(isnull("mydem"), "zonStat", "mydem")