GDALWarp Clip – How to Use Negative Buffer in GDAL

bufferclipgdalgdalwarp

Is there any simple way to change this command:

gdalwarp -tr 10 10 -cutline "shape.shp" -crop_to_cutline -of GTiff "S1A_IW_GRDH_1SDV_20200719T161950_20200719T162015_033526_03E28C_C720.SAFE.tif" "S1A_IW_GRDH_1SDV_20200719T161950_20200719T162015_033526_03E28C_C720.SAFE.tif"

to the one that would clip to cutline, but with negative buffer in meters (if not, at least in pixels?)

Input data is WGS84 UTM zone 34N.

Best Answer

you may want to just issue the buffer command in Spatialite SQL. Easiest to do it in two steps:

  1. Create buffer, check it's what you want
  2. Amend your command to use the new shapefile.

Or you can put the SQL directly in gdalwarp using the -csql options. Harder to debug!

ogr2ogr -f "ESRI Shapefile" -dialect SQLite \
        -sql \
 "select ST_Buffer(ST_Transform(geometry, 32634), -10) from shp_in" shp_out.shp shp_in.shp

(all in one line without the \, I'm not sure this will work as typed!)

Related Question