7

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?

Joseph
  • 75,746
  • 7
  • 171
  • 282
againstflow
  • 5,034
  • 18
  • 56
  • 87
  • There are already several elevation webservices: http://stackoverflow.com/questions/1759265 Do you really need to develop your own? – julien Aug 19 '14 at 08: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 Aug 19 '14 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. – againstflow Aug 19 '14 at 14:36
  • Just out of curiosity, how many points did you create and/or at what interval along the line? – mr.adam Aug 19 '14 at 18:19
  • Is GeoServer a mandatory requirement for your web app? If it is then I think including a [tag: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 Aug 19 '14 at 23:20
  • If it calls GetFeatureInfo less than 100 times, time is still under 5 seconds and that's ok for me. – againstflow Aug 20 '14 at 13:37

1 Answers1

4

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.

Barrett
  • 3,069
  • 1
  • 17
  • 31
  • 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. – againstflow Aug 20 '14 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 Aug 20 '14 at 15:11