Extract mean raster values to line

4312
3
Jump to solution
12-06-2020 05:11 AM
PatrickGreber
New Contributor II

Hello all!

I'm currently working on a samll GIS-Project but I got stuck on a problem. Is there a possibility to extract the mean value of raster cells, that were crossed by a line and then ad this mean value to the line? I have one dataset with lines (vector) and another raster dataset with different values. I would like to add a column to the line dataset with the mean values of the crossed rasters by that specific line.

Thank you for your help and support!

0 Kudos
2 Solutions

Accepted Solutions
DavidPike
MVP Frequent Contributor

I think Add Surface Information will do this (with the right parameters set) Add Surface Information—Help | ArcGIS for Desktop , Add Surface Information (3D Analyst)—ArcGIS Pro | Documentation

If you don't have 3d analyst, I'd first try and find someone who does! but there'd be some kind-of process of 'Extract by Mask' to get only the raster cells coincident with the polylines, then theres many options i guess, I would:

convert the cells to polygons, then do a spatial join with a merge rule of 'SUM' for the grid_code field (or whatever it's called - I cant remember)

 

Edit - 'Mean' option, not 'SUM'

View solution in original post

DavidPike
MVP Frequent Contributor

Ah, I'm not sure on that one.  You could do the raster to polygon method then a spatial join, use the join_count to count the number of raster cells the line passes through, then the sum would be the mean * that count (I think).  There may be other options but I'm not sure.  I think that workflow is valid, but a raster to polygon can be very intensive depending on the extent and cell-size of your area (definitely extract by mask before you do the raster to polygon).

View solution in original post

3 Replies
DavidPike
MVP Frequent Contributor

I think Add Surface Information will do this (with the right parameters set) Add Surface Information—Help | ArcGIS for Desktop , Add Surface Information (3D Analyst)—ArcGIS Pro | Documentation

If you don't have 3d analyst, I'd first try and find someone who does! but there'd be some kind-of process of 'Extract by Mask' to get only the raster cells coincident with the polylines, then theres many options i guess, I would:

convert the cells to polygons, then do a spatial join with a merge rule of 'SUM' for the grid_code field (or whatever it's called - I cant remember)

 

Edit - 'Mean' option, not 'SUM'

PatrickGreber
New Contributor II

Hi David,

Thank again for your help, it worked perfectly with "add surface information"! I was looking at a lot of workarounds and glad that your solution did not require this=)!

Would there be a way to calculate the SUM too, or would this require other solutions?

Thank you soo much!

0 Kudos
DavidPike
MVP Frequent Contributor

Ah, I'm not sure on that one.  You could do the raster to polygon method then a spatial join, use the join_count to count the number of raster cells the line passes through, then the sum would be the mean * that count (I think).  There may be other options but I'm not sure.  I think that workflow is valid, but a raster to polygon can be very intensive depending on the extent and cell-size of your area (definitely extract by mask before you do the raster to polygon).