<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi, </div><div dir="ltr"><br></div><div dir="ltr">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.<br>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.<br><br>The shapefile has the same map projection with the raster.<br>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?<br><br>I assume I can also define the geometry through:<br>poGeometry = poFeature->GetGeometryRef(); but I need a filter to remove unwanted features. These geometries are actually already in the shapefile.<br><br>The current output are exactly the same as the input raster file, so I suspect the cutline, or hCutline option is not effective.<br><br>Some details are also discussed here:<div><a href="https://gis.stackexchange.com/questions/371915/crop-raster-file-with-gdal-warp-c-api">https://gis.stackexchange.com/questions/371915/crop-raster-file-with-gdal-warp-c-api</a></div><div><br></div><div>Please provide some suggestions.</div><div><br></div><div>Thank you!<br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr"><font style="color:rgb(80,0,80)" face="times new roman, serif">Best Regards!</font><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)"><font face="times new roman, serif" color="#3d85c6"><b><br></b></font></span><div dir="ltr" style="font-size:12.8px"><span><font face="times new roman, serif"><b><font color="#674ea7">Chang Liao, PhD</font><br></b></font></span></div><span style="font-size:12.8px"><div><font face="times new roman, serif" color="#3d85c6"><b>Earth Scientist, Atmospheric Sciences & Global Change Division</b></font></div><div dir="ltr"><font face="times new roman, serif" color="#45818e"><b>Pacific Northwest National Laboratory, WA, USA.</b></font></div><div dir="ltr"><b style="font-family:"times new roman",serif;font-size:12.8px"><font color="#6aa84f">Email: <a href="mailto:changliao.climate@gmail.com" target="_blank"><u>changliao.climate</u> at gmail.com</a>  or  <a href="mailto:chang.liao@pnnl.gov" target="_blank">chang.liao at pnnl.gov</a></font></b><br></div><div dir="ltr"><font face="times new roman, serif" color="#f1c232"><b>Personal Website: <a href="http://www.changliao.us/" target="_blank">http://www.changliao.us</a></b></font></div><div dir="ltr"><b style="font-size:12.8px;font-family:"times new roman",serif"><font color="#cc0000">Lab Website: <a href="https://www.pnnl.gov/science/staff/staff_info.asp?staff_num=9326" target="_blank">www.pnnl.gov</a></font></b><br></div></span></div><div dir="ltr"><div style="color:rgb(80,0,80)"><font face="times new roman, serif" color="#3d85c6"><b><br></b></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>