Skip to main content
added 79 characters in body
Source Link
j08lue
  • 289
  • 1
  • 3
  • 9

It is -dstnodata you needare asking for, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be a specified value (or one for each band), the nodata values from the input data set, or, if none of the two is available, some default value (in order of priority), which however is not set as nodata value on the output dataset. I don't know how GDAL determines thethat default nodata value, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

It is -dstnodata you need, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be a specified value (or one for each band), the nodata values from the input data set, or some default value (in order of priority). I don't know how GDAL determines the default nodata value, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

It is -dstnodata you are asking for, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be a specified value (or one for each band), the nodata values from the input data set, or, if none of the two is available, some default value, which however is not set as nodata value on the output dataset. I don't know how GDAL determines that default value, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

no bug anyways
Source Link
j08lue
  • 289
  • 1
  • 3
  • 9

It is -dstnodata you need, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be the provideda specified value (or one for each band), the nodata values from the input data set, or some default value (in order of priority). I don't know how GDAL determines the default nodata valuesvalue, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

It is -dstnodata you need, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be the provided value (or one for each band), the nodata values from the input data set, or some default value. I don't know how GDAL determines the default nodata values, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

It is -dstnodata you need, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be a specified value (or one for each band), the nodata values from the input data set, or some default value (in order of priority). I don't know how GDAL determines the default nodata value, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

no bug anyways
Source Link
j08lue
  • 289
  • 1
  • 3
  • 9

I would call this aIt is bug in gdalwarp that it does-dstnodata you need, not set-dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the areasarea outside the -cutline polygon to srcnodata-dstnodata, which can be the provided value (or one for each band), the nodata values from the input data set, or some default value. I don't know how GDAL determines the default nodata values, but so something as random asfor Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

I would call this a bug in gdalwarp that it does not set the areas outside the -cutline polygon to srcnodata, but so something as random as zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

It is -dstnodata you need, not -dstalpha:

gdalwarp -cutline -dstnodata -9999 INPUT.shp INPUT.tif OUTPUT.tif

gdalwarp sets the area outside the -cutline polygon to -dstnodata, which can be the provided value (or one for each band), the nodata values from the input data set, or some default value. I don't know how GDAL determines the default nodata values, but for Byte data, it is zero.

An alternative solution that was proposed here "is to use gdal_translate with -projwin to extract to shape envelope and then gdal_rasterize with -i to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.

But all of these are using GDAL command line tools.

Source Link
j08lue
  • 289
  • 1
  • 3
  • 9
Loading