Resampling a raster - better method needed than nearest

4037
8
11-06-2018 02:34 AM
Nicole_Ueberschär
Esri Regular Contributor

Hello helpful people!

I have a raster with population data that has a resolution of 30.8 x 30.8 meters. Each grid cell has a number of population living in this grid cell, there are grid cells in between which don't have any population and there are areas with higher population. Values range from 0 to about 50. 

To make analysis of the numbers easier I want to resample the grid to a resolution of 100m (-> 1 ha per grid cell). With the resample tool I get pixels of 100m resolution but the way the value of these new pixels is calculated does not meet my needs. With the nearest methodology it takes over the value of the underlying pixels but when I now multiply this value with the factor of the change of the resolution and do a zonal statistics the totals don't match the original population (the differences range between -18 and +13%). And visually I can also see big differences.

The alternative way which seems mathematically better would be to resample first down to 1m, recalculate the values and then do an Aggregate with the SUM method. Buuuuuut resampling down to 1m resolution takes forever. (Tried in ArcGIS 10.6 and ArcPro 2.2)

I found a "Resample function" Resample function—Help | ArcGIS Desktop where I would think the Average method could give better results but I couldn't find out yet if this can be applied to a raster like mine and how I would use it. 

Any other suggestion how to get a better result?

0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

There are better methods, but perhaps not easily implemented unless you are willing to work outside the box

/blogs/dan_patterson/2018/10/08/generalization-tools-for-rasters 

in the def aggreg_(a, win=(3,3), agg_type='mode') portion of the script, you can changed the agg_type to 'median', 'mean' or any statistic.

The function are 'nan' functions, which account for nodata values during the aggregation process.

Nicole_Ueberschär
Esri Regular Contributor

Thanks Dan, unfortunately the solution should come from out of the box so our clients can rerun the models without worrying about additional tools. 

The aggregate is also not really the problem in this workflow but rather the way the values are taken over by the resample tool...

0 Kudos
DanPatterson_Retired
MVP Emeritus

perhaps an ArcGIS Ideas‌ (or use your inner connections) to implement some of these ideas   (ps.  the approach proposed handles your resample issue)

XanderBakker
Esri Esteemed Contributor

I think the Aggregate—Help | ArcGIS Desktop tool will get you what you want (using the aggregation type SUM).

Nicole_Ueberschär
Esri Regular Contributor

The problem with the aggregate tool is that I can only scale up by an integer number. So if I multiply my 30.8 m resolution by 3 I come of course closer to a hectar but statistically not close enough for the purpose of having a good value for calculations and understanding of the data. 

0 Kudos
XanderBakker
Esri Esteemed Contributor

The only alternative that I can think of if precision is very important is vectorizing the data and create a fishnet of 100 x 100 and do a Union or Intersect, correct the resulting numbers per polygon by the area (fraction of 30.8 x 30.8) and summarize by the fishnet id and round the resulting numbers. The feasibility depends on the size (rows x columns) of the input data that you have.


The other path is to look at how the 30.8 x 30.8 data was created and go back to the source and see if you can change the process to create the correct cellsize from the beginning.

0 Kudos
curtvprice
MVP Esteemed Contributor

I think the best method to do this is to convert the data to a value of pop density per sq km (I am assuming the xy coord system is meters).

The expression below converts population (persons in cell) to pop density (persons per square km) in each cell.

popden = popcells / ((30.8 * 30.8) * 1e-6)‍‍

Then, no matter the cell size, when you run zonal statistics with MEAN you get an average population density. Multiply the zonal mean by square kilometers in the zone (you can calculate this value with Zonal Geometry) to get the number of people in the zone.

You could get an 100m grid with number persons by setting the cell size to 10, aggregate popden by MEAN with a factor of 10, and multiplying (with raster calculator) by 100 x 100 * 1e-6 sq km / cell, but I don't see the purpose, as popden can be aggregated at any cell resolution (including the original one) without any issues.

Nicole_Ueberschär
Esri Regular Contributor

That's an interesting idea, thank you!

0 Kudos