I have my dsm .tiff file, pixels are floating point 32bit values giving the terrain elevation in metres. I need to create a web map where user can draw a path and get elevation profile for that path. Raster has attribute 'GRAY_INDEX' where values are stored.

What are the options to achieve this and is it even possible?

I thought about Geoserver GetFeatureInfo, but I'm not sure how that would work as I can get values for only one point at a time. I thought when user draws a path, I make a number of GetFeatureInfo requests exactly as points in that path, but I assume that would lead to slow performance. Is there a better option?

  • There are already several elevation webservices: stackoverflow.com/questions/1759265 Do you really need to develop your own?
    – julien
    Commented Aug 19, 2014 at 8:43
  • For me, it's not just about elevation. I also use a GeoServer stack with plenty of raster data of varying formats, and I do a lot with these rasters. I've run into the similar problem lately where I need to extract raster values - again, not just for elevation - and WCS is a bit too heavy in many cases when integrating into my web map client. WMS GetFeatureInfo is almost-perfect for my use, but as mentioned in the above post, you can only extract one point at a time.
    – Patrick D
    Commented Aug 19, 2014 at 11:12
  • I needed my own elevation because that was the purpose of the app - compare elevation values from my raster with Bing or Google Elevation API. I handled it with GetFeatureInfo in the end, for every point of polyline. It works pretty fast so it didn't affect so much on performance. Commented Aug 19, 2014 at 14:36
  • Just out of curiosity, how many points did you create and/or at what interval along the line?
    – mr.adam
    Commented Aug 19, 2014 at 18:19
  • Is GeoServer a mandatory requirement for your web app? If it is then I think including a geoserver tag would help bring your question to the attention of its users. If not, I think you should edit your question to at least clarify whether you are open only to Open Source suggestions or willing to consider COTS too.
    – PolyGeo
    Commented Aug 19, 2014 at 23:20

1 Answer 1


If the raster is in PostGIS, using ST_Value this would be handy (from this similar question):

SELECT ST_Value(rast, geom) val
FROM yourrastertabe, yourpointtable
WHERE ST_Intersects(rast, geom)

This would require you convert the linestring to points, insert into an array or table, and then run the intersection. Stream the results to a file and then back to the requesting client?

Perhaps ST_Line_Interpolate_Point can be used to get points at intervals along the line. Its not perfect ( i would prefer creating points every x feet instead of % of line length) However - you could take it further and get the ST_length, and then figure out a ratio of feet to %. Then you could run line interpolate at each % that corresponds to the x feet you want.

  • Thanks for this solution, Postgis is great. As I used GetFeatureInfo from Geoserver and Leaflet map, I interpolated every 10% of line segments using very good Leaflet plugin GeomUtils.js. Commented Aug 20, 2014 at 14:59
  • cool :) thanks for feedback. Perhaps if there is heavy use PostGIS might be the way to go to reduce overhead? Otherwise, stick with what works
    – Barrett
    Commented Aug 20, 2014 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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