In my usecase I want to use OSM data for my routing server, but first, I'd like to add elevation data. And I'd prefer to do that in postgis as I'd need to do further analysis of the data using postgis.

So my question is which tools I should use for that task?

I guess I would use gdal to somehow import the elevation information from a raster-source? But how would a proper postgis sql command for that look?

EDIT: My raster file is a .vrt file that combines about 3TB of data. So loading the whole raster into a DB will now work. I'd need a solution to go through each geometry in my DB and convert it from 2D to 3D.

  • did you search on the internet for this? There are several posts about this subject. gis.stackexchange.com/questions/218207/… blog.mathieu-leplatre.info/…
    – tilt
    Commented Aug 8, 2017 at 16:15
  • Ok, I should add that my raster is HUGE... its a .vrt file with data >3TB. So loading the whole raster into a db will not work for me. I'd need to go through each geometry and convert it from 2D to 3D...
    – Georg
    Commented Aug 8, 2017 at 16:22
  • 1
    Did you consider adding your raster files out-db? In that case you can still access your rasters from within the database and make use of an index. When your individual raster files are really big, there would be a penalty on loading them every time though. Also see: gis.stackexchange.com/questions/30303/…
    – tilt
    Commented Aug 9, 2017 at 8:27
  • Ok, I didn't see that before. So out-db are raster-drivers for PostGis? Do I understand that correctly? So there should be a ST_GDAL_whatever command to load the raster and look up elevations in there? So I would basically write a little sql that would load every geometry, iterate those by each point, lookup the elevation and then write the geometry back as 3d?
    – Georg
    Commented Aug 9, 2017 at 8:49
  • Correct, but I would encourage you to read the postgis-raster docs. There's some studying involved ;-) postgis.net/docs/using_raster_dataman.html and postgis.net/docs/RT_reference.html
    – tilt
    Commented Aug 9, 2017 at 20:24


Your Answer

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