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...
Solved! Go to Solution.
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.
Follow up: here's what I ended up doing:
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!
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.
I'd definitely recommend @jcarlson s method.
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.
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.
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!
zonal statistics does have "majority" aka mode
Zonal Statistics (Spatial Analyst)—ArcGIS Pro | Documentation
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.
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!