Feature request #3066

GdalTools: clipping based on a shapefile mask

Added by Giuseppe Sucameli about 14 years ago. Updated over 13 years ago.

Status:Closed
Priority:Low
Assignee:Giuseppe Sucameli
Category:GDAL Tools
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13126

Description

It will be useful to add the possibility of clipping based on a shapefile mask. This can be done with the gdal_rasterize and the option burn, eg:

gdal_rasterize -i -burn 255 -b 1 -b 2 -b 3 -l [SHAPELAYER] [SHAPEFILE] [RASTER]

this results ion setting all three bands at 255 for the area outside the shapefile in input.

Thanks Stefano Salvador for the suggestion.

Associated revisions

Revision 2f16afb9
Added by Giuseppe Sucameli over 13 years ago

added -cutline option to gdaltools warp tool, to fix #3066

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15476 c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision 36fc12ad
Added by Giuseppe Sucameli over 13 years ago

added -cutline option to gdaltools warp tool, to fix #3066

git-svn-id: http://svn.osgeo.org/qgis/trunk@15476 c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision d3b47862
Added by Giuseppe Sucameli over 13 years ago

add cutline option to clipper to fix #3066

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15712 c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision adbcbcbb
Added by Giuseppe Sucameli over 13 years ago

add cutline option to clipper to fix #3066

git-svn-id: http://svn.osgeo.org/qgis/trunk@15712 c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Giovanni Manghi almost 14 years ago

apparently there is also a way to do it with gdalwarp, and adding at the same time the alpha channel to the output raster, ex:

gdalwarp -of GTiff -r lanczos -dstalpha -cutline shapefile.shp raster_input.tif raster_output.tif

would be nice too to add this options too in gdalwarp

#2 Updated by Giovanni Manghi almost 14 years ago

PS
Thanks to Pedro Venâncio for the suggestion

#3 Updated by Giuseppe Sucameli almost 14 years ago

Replying to [comment:1 lutra]:

apparently there is also a way to do it with gdalwarp, and adding at the same time the alpha channel to the output raster, ex:

> gdalwarp -of GTiff -r lanczos -dstalpha -cutline shapefile.shp raster_input.tif raster_output.tif

I know the -cutline option since the Hackfest when Tim told me about it.
Thanks for reporting it, I forgot to add these information to this ticket.

would be nice too to add this options too in gdalwarp

So,
1. improving the clipper (clipping based on a shapefile mask)
2. add the -cutline option in the gdalwarp tool too.

#4 Updated by Giuseppe Sucameli over 13 years ago

  • Status changed from Open to In Progress

Added -cutline option to gdalwarp tool (36fc12ad (SVN r15477))

#5 Updated by Bill Williamson over 13 years ago

Works for me in Win7 in trunk
use cutline in gdalwarp.
Why is ticket still open?

#6 Updated by Giuseppe Sucameli over 13 years ago

I want to add it to the Clipper tool, so it can be used to clip whatever kind of layer.

#7 Updated by Giuseppe Sucameli over 13 years ago

  • Resolution set to fixed
  • Status changed from In Progress to Closed

Fixed in adbcbcbb (SVN r15713).

Also available in: Atom PDF