Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the raster which contains 4 bands (RGBA), which ilustrates the pupulation (traffic) density. I want to convert it to the simple gridded ascii, however I'm getting in the trouble when I try the export it to the different formats. I suppose it comes from multi-band property of this map, therefore:

Is there any way I can convert from RGBA to single value representing the data I need ?

E.g. when I want to convert using RGB2PCT:

ERROR 1: TIFFOpen:traffic_przyciety2: Permission denied Traceback (most recent call last): File "C:\PROGRA~2\Quantum GIS Lisboa\bin\", line 136, in tif_ds.GetRasterBand(1).SetRasterColorTable( ct ) AttributeError: 'NoneType' object has no attribute 'GetRasterBand'

BTW: AttributeError: 'NoneType' error is dropped in other functions as well when I want to do something on this map

Info about the map:

Band 1 Block=903x1 Type=Byte, ColorInterp=Undefined Min=0.000 Max=255.000 Minimum=0.000, Maximum=255.000, Mean=254.667, StdDev=9.206 Band 2 Block=903x1 Type=Byte, ColorInterp=Undefined
Min=0.000 Max=124.000 Minimum=0.000, Maximum=124.000, Mean=119.886, StdDev=7.547 Band 3 Block=903x1 Type=Byte, ColorInterp=Undefined
Min=0.000 Max=0.000 Minimum=0.000, Maximum=0.000, Mean=0.000, StdDev=0.000 Band 4 Block=903x1 Type=Byte, ColorInterp=Undefined
Min=0.000 Max=255.000 Minimum=0.000, Maximum=255.000, Mean=217.937, StdDev=67.026'

Alternatively, do you know if there's any standard interpretation of the geodata maps ? E.g. if the resulting pixel value may be obtained by specific operation on the bands ?

Thanks for the answers

BR Krzysztof

share|improve this question

If the output file format is not geotiff, creates an intermediate geotiff to write the results into before converting that to the final output format. The comments in the code state:

# Create the working file.  We have to use TIFF since there are few formats
# that allow setting the color table after creation.

From lines 127-129 of

126  if format == 'GTiff':
127      tif_filename = dst_filename
128  else:
129      tif_filename = 'temp.tif'

Note that no directory is specified for 'temp.tif'...

I think what is happening is that you are trying to output directly to an ascii raster, so tries to create an intermediate GeoTiff in the current working directory which in this case would probably be the directory that the script file lives in "C:\PROGRA~2\Quantum GIS Lisboa\bin\". And I assume you don't have permission to write into that directory which is why you get the Permission denied error.

I'd say this is a bug in It should probably write to a temp directory instead of the current directory.

The simplest workaround would be to set the output format to geotiff and write to a path that you have permissions for, then convert to an ascii grid as a second step.

Edit: bug report and patch submitted to GDAL trac.

share|improve this answer
thanks it worked in this way. However I'm not sure what the colortable represents now... i would need to seek for the scale of this image.. or is there any global mapping convention color<=> number ? I've seen this in e.g. DEM map – wastek May 8 '13 at 10:13

It depends what do you want to do with your outout data. Is your data on 1 of the layers of the raster or you have to convert 3 or 4 bands into 1? Either way you can make use of raster calculator. If you want mean of 3 or 4 bands in your output raster just add them up and divide by number of lyers: (r@1 + r@2 + r@3)/3, else you just select band of interest and export it to new file. Thats in theory, as I did not test it on QGIS.

share|improve this answer
I assumed that every band represents the RGBA channel respectively. In my case the third channel is empty. Thank for the good hint, but I don't know if the average from all the channels would represent the "traffic map" final value:/ I'm still beginner in the GIS, so I thought I missed some information which shall be attached to this map, or the information is there already but I cannot interpret it correctly – wastek May 8 '13 at 12:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.