Awesome, thanks! On Thu, Nov 14, 2019 at 9:39 AM Martin Chapman <mchap...@hyperacktive.com> wrote:
> Ahmet, > > > > You can use either the gdalwarp.exe or the underlying gdal warper C++ API > to create a new image using the polygon geometry as a cutline. See the > gdalwarp.exe or gdal warper C++ API documentation on how to do that. > > > > Basically, the cutline geometry will NULL out any pixels in the output > image that are not within the polygon geometry. If you use the > gdalwarp.exe utility it will output a new image to disk. If you use the > gdal warper C++ API then you can write the output image to disk or memory. > For more information on how this is done programmatically see the source > code for the gdalwarp.exe that is included with the gdal source code. > > > > NOTE: Your cutline geometry needs to be topologically correct in order to > produce good output. Topologically correct geometries do not contain > self-intersections, slivers, etc. An example of a self-intersecting > geometry is a bow-tie where two lines in the geometry cross each other. > Slivers are where two adjacent geometries share an edge but there is a gap > between the edges. Lots of shape files contain geometries that are not > topologically correct because ArcMap and other tools don’t enforce that. > The warp API can handle polygons and multi-polygons. If your output comes > out looking screwed up it is most likely because your cutline geometry is > not topologically correct OR you didn’t convert the cutline geometry from > coordinate space to pixel space before feeding it to the warper C++ API (in > the case you do it programmatically). The gdalwarp.exe can handle > geometries in coordinate space. If by chance your cutline geometry is not > topologically correct you may be able to fix it by doing a Buffer() > operation on it using the OGR API with a buffer distance of 0. GEOS (the > underlying engine for the OGR buffer operation) will create a new geometry > that is exactly the same as the input because the buffer distance is zero > but the GEOS API will attempt to correct the topology of the new geometry. > > > > Best regards, > > Martin Chapman > > > > > > > > *From:* gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] *On Behalf Of > *Ahmet > Temiz > *Sent:* Saturday, November 9, 2019 9:57 AM > *To:* gdal-dev > *Subject:* [gdal-dev] extracting a raster data within a polygon? > > > > Hi, > > how I can extract a raster data within a polygon (not a rectangle) using > C++? > > i.e. dem within provincial boundary > > Regards > > -- > > Ahmet Temiz > Jeoloji Müh. > Afet ve Acil Durum Yönetimi Başkanlığı > Bilgi İşlem Dairesi Başkanlığı-CBS Grubu > > > ________________________ > > Ahmet Temiz > Geological Eng. > Information Systems - GIS Group > Disaster and Emergency Management > of Presidency > -- Ahmet Temiz Jeoloji Müh. Afet ve Acil Durum Yönetimi Başkanlığı Bilgi İşlem Dairesi Başkanlığı-CBS Grubu ________________________ Ahmet Temiz Geological Eng. Information Systems - GIS Group Disaster and Emergency Management of Presidency
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev