Opened 14 years ago

Closed 13 years ago

#3066 closed enhancement (fixed)

GdalTools: clipping based on a shapefile mask

Reported by: brushtyler Owned by: brushtyler
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: GDALTools Version:
Keywords: gdaltools, clip, rasterize, shapefile mask Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

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.

Change History (8)

comment:1 by lutra, 13 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

comment:2 by lutra, 13 years ago

PS Thanks to Pedro Venâncio for the suggestion

in reply to:  1 comment:3 by brushtyler, 13 years ago

Replying to 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.

comment:4 by borysiasty, 13 years ago

Component: Python plugins and bindingsGDALTools

comment:5 by brushtyler, 13 years ago

Status: newassigned

Added -cutline option to gdalwarp tool (r15476)

comment:6 by billywill, 13 years ago

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

comment:7 by brushtyler, 13 years ago

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

comment:8 by brushtyler, 13 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r15712.

Note: See TracTickets for help on using tickets.