[gdal-dev] Crop tiff raster file with warp C++ API

Chang Liao changliao.climate at gmail.com
Wed Aug 19 15:40:38 PDT 2020


Hi,

I need to crop a DEM raster file with a shapefile. This shapefile has many
polygons. I need to calculate several variables after the crop operation.
I do not need to write the warped result out to my disk and I intend to use
either VRT or MEM once the test is passed.

The shapefile has the same map projection with the raster.
I already obtained the vertex coordinates of each polygon and I passed as a
polygon using the cutline argument, but the operation has no effect so far.
In this way, I am constructing the geometry manually but I am not sure what
I have missed, maybe the spatial reference?

I assume I can also define the geometry through:
poGeometry = poFeature->GetGeometryRef(); but I need a filter to remove
unwanted features. These geometries are actually already in the shapefile.

The current output are exactly the same as the input raster file, so I
suspect the cutline, or hCutline option is not effective.

Some details are also discussed here:
https://gis.stackexchange.com/questions/371915/crop-raster-file-with-gdal-warp-c-api

Please provide some suggestions.

Thank you!

Best Regards!


*Chang Liao, PhD*
*Earth Scientist, Atmospheric Sciences & Global Change Division*
*Pacific Northwest National Laboratory, WA, USA.*
*Email: changliao.climate at gmail.com <changliao.climate at gmail.com>  or
 chang.liao at pnnl.gov <chang.liao at pnnl.gov>*
*Personal Website: http://www.changliao.us <http://www.changliao.us/>*
*Lab Website: www.pnnl.gov
<https://www.pnnl.gov/science/staff/staff_info.asp?staff_num=9326>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200819/5efaabea/attachment.html>


More information about the gdal-dev mailing list