<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><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 class="font" style="font-family:menlo, consolas, monospace, sans-serif;">GetLayer</span> actually returns a pointer or <span class="font" style="font-family:menlo, consolas, monospace, sans-serif;">nullptr</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" style=""><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">gdal-dev@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></div><div><br></div></blockquote><div style="font-family:Arial;"><br></div></body></html>