In my python code I run the following command:
command = 'gdalwarp rgb.tif rgb_output_cut.tif -cutline extent.kml -dstnodata 0 -q'
os.system(command)
This cuts rgb.tif based on the extents specified in extent.kml and outputs a file called rgb_output_cut.tif. I would like to run this command without gdalwarp but instead with Python bindings. Is anyone familiar with this? Also, for the purposes of my task, having -dstnodata 0 is optional, it is just nice to have.
I found similar examples, however, they are just using gdalwarp for reprojection. For my case I'd like to cut out an extent.
Here, in my extent.kml file it is just a series of LinearRing Polygons, for example:
<Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<Polygon><altitudeMode>clampToGround</altitudeMode><outerBoundaryIs><LinearRing><altitudeMode>clampToGround</altitudeMode><coordinates>-104.959386510378,39.7075208980859 -104.959394642483,39.7020277743643 -104.968738431214,39.7020465443243 -104.968779091739,39.7075083857725 -104.959386510378,39.7075208980859</coordinates></LinearRing></outerBoundaryIs></Polygon>
Not, I must use gdal version 1.10.1.
extent.kmlfile is just a series of LinearRing Polygons, I updated my post with an example. – jlcv Nov 16 '17 at 05:11