Average raster value within search area from points

3069
10
Jump to solution
12-05-2020 02:47 PM
PetronilaMandeno
Occasional Contributor II

Hello, I searched for this, but I just can't find a solution.

Here's the problem: I have roads as a vector line file (geodatabase). I have a hazard layer as a raster file (values are from 0 to 10). I would like to assign a hazard rating (1 to 10) to each road. However, hazard changes dramatically from one place along the line to another. So, I know I need to segment the lines. I'll probably do them in 200-foot intervals. With that in mind, I created points along the roads every 100 feet.

My idea was to extract the values from the raster layer to the 100-ft interval points, then do a spatial join to the 200ft-segmented roads.

However, where the roads are, in the hazard layer, there is no hazard (0) because its a road in the raster too.

Is there a way to extract the average of all the cells in a 200ft centered radius around each of the points? And can I somehow ignore 0 values?

I suspect I need to do this in python, but hoping there's a tool I'm not aware of.

Thanks in advance...

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

That's close to what I would suggest. If you happen to have Spatial Analyst or Image Analyst licenses, what you really ought to use is Zonal Statistics, which will summarize the hazard raster within the buffer features, but if that's not an option, your method is almost right.

In your spatial join, choosing nearest means that only the single nearest feature will be joined to your input feature. You probably want to be using the within a distance option, so that data from all points within a defined distance can be aggregated.

- Josh Carlson
Kendall County GIS

View solution in original post

10 Replies
PetronilaMandeno
Occasional Contributor II

Follow up: here's what I ended up doing:

  1. Buffered my roads by 200 feet
  2. With that buffered layer, extracted by mask from the hazard raster
  3. Convert those to points (deleting any that were less than 1 or null)
  4. Then I split my roads into 200 foot sections (its just a manageable distance to use)
  5. Lastly, I did a spatial join, joining the point data to the lines and used the nearest option (instead of intersect) and computed the average only.

This will work for now, but I don't know what 'nearest' means. Does it just use the ones it encounters first all along the line or does it use a set distance? Would be cool to be able to set a distance.

If anyone else has a more elegant way of doing this, please let me know! 

jcarlson
MVP Esteemed Contributor

That's close to what I would suggest. If you happen to have Spatial Analyst or Image Analyst licenses, what you really ought to use is Zonal Statistics, which will summarize the hazard raster within the buffer features, but if that's not an option, your method is almost right.

In your spatial join, choosing nearest means that only the single nearest feature will be joined to your input feature. You probably want to be using the within a distance option, so that data from all points within a defined distance can be aggregated.

- Josh Carlson
Kendall County GIS
DavidPike
MVP Frequent Contributor

I'd definitely recommend @jcarlson s method.

PetronilaMandeno
Occasional Contributor II

Hello Josh, thank you for your ideas! I do have Spatial Analyst and I thought of using Zonal Statistics, but I don't know how to efficiently create a bunch of zones along the line. Any thoughts on that?

Regarding the distance for the spatial join, there isn't an option to do that. I *wish* there was an option, but the only options I get when I do the spatial join is intersect or nearest points. (I don't want the intersect because the hazard layer has the road represented in it and it's just 0 - I want the hazard rating around the line).

Thanks again for your idea. I will research more to see if I can come up with a way to use the zonal stats.

0 Kudos
DavidPike
MVP Frequent Contributor

The zones would be the buffers from your road segments.  If i'm guessing right - you're probably trying to use the spatial join via a table-of-contents menu, please please dont use this tool, use the geoprocessing too Spatial Join Spatial Join—Help | ArcGIS for Desktop . That has much more options.

PetronilaMandeno
Occasional Contributor II

Hmm, well, I buffered the roads before I segmented them, but I guess I could buffer the segments... I'll have to try that.

And yes, I did use the spatial join via the TOC. I didn't know the geoprocessing tool had more options! I'll try that too.

By the way, after the join, it does give a count of how many features it averaged. The values in the count field range from 1 to over 200 points (presumably) were used to get the average (not going to use now because I think I really want the most frequent hazard within 200 feet of the line segment). But I can't find anywhere in the documentation where it explains what 'nearest' means. So I'll definitely check out the geoprocessing tool instead so I can be more specific. Thanks again!

0 Kudos
DanPatterson
MVP Esteemed Contributor

zonal statistics does have "majority" aka mode

Zonal Statistics (Spatial Analyst)—ArcGIS Pro | Documentation


... sort of retired...
DanPatterson
MVP Esteemed Contributor

As a caution... there is no such thing as an "average hazard" or "average hazard class"

Classes are at best categorical data and have no statistical parameters other than counts.

Ranks are a slight step above in that the classes have ordination, but the spacing between the ranks need not imply equality, hence there is no average or other such descriptors.

So unless your hazard data are described on an interval/ratio scale, you would be advised to use zonal statistics to describe the "most frequent" hazard and fight the urge to describe an "average hazard"

For example

Hazard

4 unstable slopes

5  flooding risk  
 
for categorical classes what would you call an average of 4.5? (flooding risk on unstable slopes)

Hazard classification for flood recurrence interval

1  1 year 

 2   5 year 

3  10 year flood 

4  100 year flood  

5   1000 year flood
what would you call an average of 4.5? since the scale isn't linear.
Just address the measurement scale before addressing what information you really need.


... sort of retired...
PetronilaMandeno
Occasional Contributor II

Hello Dan - thanks for thinking through this. You are right. I don't need an average. The most frequent hazard rating would be closer to what I need. Thanks!

0 Kudos