Is there an example of how we can extract the z value from a shp file given the x,y coordinate value (namely utm) using gdal/ogr c++ lib?

alternatively, would it be easier if we convert the shp file into raster layer format and read off value from there?

Would it be easier?

Is there some examples of how this could be done?

  • What type of geometry is your shapefile? – user2856 Jun 29 '14 at 22:01
  • Most of the feature are polygon type – user1538798 Jun 30 '14 at 12:39

Manage to solve my problem.

THis can be done by instantiating OGR and openup a shapefile database, layers etc

Afterwhich, create a OGRPoint object with the neccessary lat lon input OGRPoint* pt = new OGRPoint(lat, lon);

set a spatial filter based on this point object on the layer

next extract the feature based on the filter resu;lt

Finally extract the field that is associated with elevation (field no 16 in my case)

Voila...the elevation

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.