Extracting z values from shapefile using OGR API?

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?

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

Watch the video: Reclassify u0026 Convert Raster to Shapefile Polygon u0026 Calculate Area Using ArcGIS (October 2021).