3

I have a polyline shapefile that represent a road an a raster grid with slope values. Is it possible to interpolate the shape file and the grid to have the average slope of the road? I know that I can interpolate grid with points and polygons. But with lines?

  • How is "average slope" defined? It might just be the height difference from start to finish divided total distance, in which case you only need to sample the height at two points. Otherwise there's some calculus involved which you can probably estimate with finite steps... – Spacedman Nov 20 '14 at 16:07
6

This is a bit of a late answer, but I thought it was worth contributing.

As a polyline is just a series of points you should be able to obtain the Mean value you want by converting the Polyline nodes into points by going Vector > Geometry Tools > Extract Nodes...

You can then extract the underlying Raster values for each of these points by using the Point Sampling Tool plugin. This plugin will create a new Points shapefile with the underlying raster grid cell's value within its Attribute table. See here: http://infogeoblog.wordpress.com/2013/06/23/raster-data-extraction/

Note that the Point Sampling Plugin can be quite fussy with the CRS and can result in a NULL output. I managed to get it to work by ensuring that the layers and project CRS were all the same.

If you want a higher sample rate, then I suppose you could densify the number of nodes by using Vector > Geometry Tools > Densify Geometries... prior to extracting them.

You can then use Vector > Analysis Tools > Basic Statistics... to attain the Mean Slope value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.