<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div style="font-family:Arial;">In that case you need to create it manually. There's an example here, using Python, but the API is pretty similar: <a href="https://pcjericks.github.io/py-gdalogr-cookbook/geometry.html#create-a-polygon">https://pcjericks.github.io/py-gdalogr-cookbook/geometry.html#create-a-polygon</a>. Remember to close it by duplicating the first vertex.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">To get the footprint itself, you'll need to look at the GeoTransform of the raster and its dimensions. <a href="https://gdal.org/tutorials/geotransforms_tut.html">https://gdal.org/tutorials/geotransforms_tut.html</a> has more details. Basically, one corner of the footprint is in GT(0) and GT(3), and to get the other four you'll need to translate that point by the spacing in each direction multiplied by the number of pixels. Most images won't be using the rotation parameters.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Laurentiu<br></div><div style="font-family:Arial;"><br></div><div>On Fri, Oct 14, 2022, at 11:03, Johannes Paul wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="auto"><div><div>Hello,<br></div><div dir="auto">Yes i would need a polygon with the raster footprint.<br></div><div dir="auto">Thanks<br></div><div><br></div><div><br></div><div class="qt-gmail_quote"><div dir="ltr" class="qt-gmail_attr">Le ven. 14 oct. 2022 à 10:01, Laurențiu Nicola via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> a écrit :<br></div><blockquote class="qt-gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div><u></u><br></div><div><div style="font-family:Arial;">Hi Mats,<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Vector and raster datasets are pretty much different things in GDAL. And generally it would be a good idea to check whether e.g. <span style=""><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">GetLayer</span></span> actually returns a pointer or <span style=""><span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">nullptr</span></span>.<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">What exactly do you mean by "associated OGRPolygon"? Do you want a polygon with the same footprint as the raster?<br></div><div style="font-family:Arial;"><br></div><div style="font-family:Arial;">Laurentiu<br></div><div style="font-family:Arial;"><br></div><div>On Fri, Oct 14, 2022, at 10:51, Johannes Paul wrote:<br></div><blockquote type="cite" id="qt-m_5770578418631564431qt"><div dir="auto"><div>Hello,<br></div><div dir="auto">Is there a way to get the OGRGeometry object out of a GDALDataset object in c++?<br></div><div dir="auto">My GDALDataset is a raster and i would like to get the associated OGRPolygon out of it.<br></div><div dir="auto">I've used:<br></div><div dir="auto">srcDataset->GetLayer(0)->GetNextFeature()->GetGeometryRef()->toPolygon()<br></div><div dir="auto">However i keep getting segmentation faults error.<br></div><div dir="auto">Any help would be appreciated.<br></div><div dir="auto">Thanks<br></div></div><div>_______________________________________________<br></div><div>gdal-dev mailing list<br></div><div><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank" rel="noreferrer">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></div><div><br></div></blockquote><div style="font-family:Arial;"><br></div></div><div>_______________________________________________<br></div><div> gdal-dev mailing list<br></div><div> <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a><br></div><div> <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></div></blockquote></div></div></div></blockquote><div style="font-family:Arial;"><br></div></body></html>