[gdal-dev] Alpha band masking

Even Rouault even.rouault at spatialys.com
Tue Nov 17 01:04:35 PST 2015


Le mardi 17 novembre 2015 04:08:41, MUTLU OZDOGAN a écrit :
> Dear Even,
> 
> The result of the gdalinfo -mm command is this:
> 
> Driver: GTiff/GeoTIFF
> Files: pr026029_5m.tif
>        pr026029_5m.tfw
> Size is 35921, 41035
> Coordinate System is:
> PROJCS["NAD83(HARN) / Wisconsin Transverse Mercator",
>     GEOGCS["NAD83(HARN)",
>         DATUM["NAD83_High_Accuracy_Reference_Network",
>             SPHEROID["GRS 1980",6378137,298.2572221010002,
>                 AUTHORITY["EPSG","7019"]],
>             AUTHORITY["EPSG","6152"]],
>         PRIMEM["Greenwich",0],
>         UNIT["degree",0.0174532925199433]],
>     PROJECTION["Transverse_Mercator"],
>     PARAMETER["latitude_of_origin",0],
>     PARAMETER["central_meridian",-90],
>     PARAMETER["scale_factor",0.9996],
>     PARAMETER["false_easting",520000],
>     PARAMETER["false_northing",-4480000],
>     UNIT["metre",1,
>         AUTHORITY["EPSG","9001"]]]
> Origin = (296789.742753763101064,562520.115095380693674)
> Pixel Size = (5.000000000000000,-5.000000000000000)
> Metadata:
>   AREA_OR_POINT=Area
> Image Structure Metadata:
>   INTERLEAVE=PIXEL
> Corner Coordinates:
> Upper Left  (  296789.743,  562520.115) ( 92d51'25.45"W, 45d30' 1.70"N)
> Lower Left  (  296789.743,  357345.115) ( 92d46' 5.00"W, 43d39'20.14"N)
> Upper Right (  476394.743,  562520.115) ( 90d33'30.53"W, 45d32' 5.47"N)
> Lower Right (  476394.743,  357345.115) ( 90d32'27.79"W, 43d41'16.23"N)
> Center      (  386592.243,  459932.615) ( 91d40'51.66"W, 44d36' 1.34"N)
> Band 1 Block=35921x1 Type=Byte, ColorInterp=Red
>     Computed Min/Max=0.000,255.000
>   Mask Flags: PER_DATASET ALPHA
> Band 2 Block=35921x1 Type=Byte, ColorInterp=Green
>     Computed Min/Max=0.000,255.000
>   Mask Flags: PER_DATASET ALPHA
> Band 3 Block=35921x1 Type=Byte, ColorInterp=Blue
>     Computed Min/Max=0.000,255.000
>   Mask Flags: PER_DATASET ALPHA
> Band 4 Block=35921x1 Type=Byte, ColorInterp=Alpha
>     Computed Min/Max=0.000,255.000
> 
> the exact commands I used are:
> 
> gdal_translate  pr026029_5m.tif tmp.tif -co alpha=no

--> Did you remove tmp.tif.aux.xml as I mentionned before ?

Note: given the use of gdalwarp you make, you could also just use 
gdal_translate -projwin instead (caution: the order of arguments is not the 
same since -projwin expect upper_left_x upper_left_y lower_right_x 
lower_right_y)

> 
> then
> 
> gdalwarp -te 422861.999 225313.018 489606.999 308903.018 -tr 5 5 tmp.tif
> out.tif
> 
> The results of the out.tif is the problematic output as all the bands are
> zeros as in:
> 
> Driver: GTiff/GeoTIFF
> Files: out.tif
> Size is 13349, 16718
> Coordinate System is:
> PROJCS["NAD83(HARN) / Wisconsin Transverse Mercator",
>     GEOGCS["NAD83(HARN)",
>         DATUM["NAD83_High_Accuracy_Reference_Network",
>             SPHEROID["GRS 1980",6378137,298.2572221010002,
>                 AUTHORITY["EPSG","7019"]],
>             AUTHORITY["EPSG","6152"]],
>         PRIMEM["Greenwich",0],
>         UNIT["degree",0.0174532925199433]],
>     PROJECTION["Transverse_Mercator"],
>     PARAMETER["latitude_of_origin",0],
>     PARAMETER["central_meridian",-90],
>     PARAMETER["scale_factor",0.9996],
>     PARAMETER["false_easting",520000],
>     PARAMETER["false_northing",-4480000],
>     UNIT["metre",1,
>         AUTHORITY["EPSG","9001"]]]
> Origin = (422861.999000000010710,308903.017999999981839)
> Pixel Size = (5.000000000000000,-5.000000000000000)
> Metadata:
>   AREA_OR_POINT=Area
> Image Structure Metadata:
>   INTERLEAVE=PIXEL
> Corner Coordinates:
> Upper Left  (  422861.999,  308903.018) ( 91d11'47.57"W, 43d14'48.02"N)
> Lower Left  (  422861.999,  225313.018) ( 91d10'55.54"W, 42d29'38.70"N)
> Upper Right (  489606.999,  308903.018) ( 90d22'27.90"W, 43d15' 8.35"N)
> Lower Right (  489606.999,  225313.018) ( 90d22'11.62"W, 42d29'58.50"N)
> Center      (  456234.499,  267108.018) ( 90d46'50.60"W, 42d52'26.06"N)
> Band 1 Block=13349x1 Type=Byte, ColorInterp=Red
>     Computed Min/Max=0.000,0.000
>   Mask Flags: PER_DATASET ALPHA
> Band 2 Block=13349x1 Type=Byte, ColorInterp=Green
>     Computed Min/Max=0.000,0.000
>   Mask Flags: PER_DATASET ALPHA
> Band 3 Block=13349x1 Type=Byte, ColorInterp=Blue
>     Computed Min/Max=0.000,0.000
>   Mask Flags: PER_DATASET ALPHA
> Band 4 Block=13349x1 Type=Byte, ColorInterp=Alpha
>     Computed Min/Max=0.000,0.000
> 
> Thank you so much.
> 
> Mutlu..
> 
> 
> 
> On Nov 16, 2015, at 3:21 AM, Even Rouault
> <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>> wrote:
> 
> Le samedi 14 novembre 2015 22:26:48, Mutlu Ozdogan a écrit :
> Dear Evan
> Thank you so much for the input. I actually tried exactly those steps and
> unfortunately I still get 0s in the output file. Thank you again
> 
> Could you post the result of "gdalinfo -mm your_input_file.tif" and the
> exact GDAL commands you use ?
> 
> Mutlu
> 
> Sent from my iPhone
> 
> On Nov 14, 2015, at 1:00 PM, Even Rouault
> <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>> wrote:
> 
> Le samedi 14 novembre 2015 19:49:02,
> ozdogan at wisc.edu<mailto:ozdogan at wisc.edu> a écrit : Dear All
> I have a 4-band air photo image in which the 4th band is the NIR band
> but it has also been designated as an alpha band. It is the geotiff
> format. For some reason whenever I reproject this file (using gdalwarp)
> or resize it (using gdal_translate) all four bands of the resulting
> files have zero values. It is as if the alpha band is being used to
> mask all band values. Any help reprojecting or windowing this large
> file without making while retaining all 4 band values would be much
> appreciated. Thank you
> 
> Mutlu,
> 
> The issue is probably indeed the NIR band being recognized as an alpha
> band. You can remove the alpha interpretation with :
> 
> gdal_translate in.tif tmp.tif -co alpha=no
> rm tmp.tif.aux.xml (or del tmp.tif.aux.xml on Windows)
> 
> The removal of tmp.tif.aux.xml is important otherwise the alpha
> interpretation would be kept in this XML file
> 
> And then you can gdalwarp this tmp.file with the arguments you need :
> 
> gdalwarp tmp.tif ...
> 
> Even
> 
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
> 
> 
> --
> Mutlu Ozdogan, Ph.D.
> Associate Professor
> Department of Forest and Wildlife Ecology &
> Nelson Institute for Environmental Studies
> t: (608) 262-0873
> e: ozdogan at wisc.edu<mailto:ozdogan at wisc.edu>

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list