2

I've created a new raster in GRASS, starting from a dem and using the commands r.relief and r.shade.

Now I would like to export this new raster as a georeferenced image and import it in Adobe Illustrator (using MAPublisher plugin).

I'm trying to do it using the command r.out.gdal and exporting it as GTiff with its colour table using UInt16 data type, with no success...

Have you got any suggestion?

1

I don't think that Adobe Illustrator can read UInt16 data, so you have to rescale your raster first with r.rescale to 0-255 values and then export it with r.out.gdal with option type=Byte to Byte datatype.

  • You're absolutely right, webrian, but I absolutely need a better colour depth for my purposes... are there alternative formats that I could georeference in order to mantain a better colour depth? – Bryan Ciceri Apr 29 '15 at 16:17
  • It's not about the raster format, it is about the raster value datatype (being UInt16) which is most certainly not supported in Adobe Illustrator. That means you loose anyway color depth when importing the raster into Illustrator. – webrian Apr 30 '15 at 3:01
  • I've done some tests and it seems like Adobe Illustrator can't open an indexed UInt16 datatype raster (GTiff exported with GDAL colour table) but can open a greyscale UInt16 datatype one (GTiff exported without GDAL colour table)... that's why I was wondering if I could export the raster in another format using e.g. an 8 bit colour depth which is better than the byte datatype I would have to use to low the colour depth exporting the raster in GTiff format... – Bryan Ciceri Apr 30 '15 at 9:38
  • But byte is 8 bit (per channel), so you get 256 different values per channel – webrian Apr 30 '15 at 10:08
  • Thanks for the explanation, idk why I wasn't considering the channels so I was thinking I would have exported an image in 256 colours... :) – Bryan Ciceri Apr 30 '15 at 11:59
2

All GRASS color tables formats (v.6.4) are in this link:

https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/lib/gis/colors/

If you have GRASS 6.4 in Linux, they are in /usr/lib/grass64/etc/colors.

For example, if you used the elevation table, this is the format:

0%     0 191 191
20%    0 255   0
40%  255 255   0
60%  255 127   0
80%  191 127  63
100% 200 200 200

Copy the above information as elevation.text and use the gdaldem command for producing your colored raster. The sintaxis of gdaldem color-relief would be (assuming your exported uncolored raster as input_raster.tif):

gdaldem color-relief input_raster.tif elevation.txt output_raster.tif

I ran the command in GRASS console. This is the result in my system when I loaded the output_raster.tif in QGIS. It can be observed that is a rgb image (corroborated with Value Tool Plugin).

enter image description here

You can do the same (but it is more difficult because there is not ColorRampItem definitions for the renderer) by using the Python Console of QGIS; as is exposed here: QGis Save Raster as Rendered Image

1

Using the GRASS r.out.gdal module, you specify createopt="TFW=YES" to get a *.tfw world file. When exporting with type=UInt16 you should also get the proper colors saved into the geotiff. (I don't know specifically if Adobe iluustrator will read those tif color ramp headers)

  • Thanks Micha. That's exactly what I tried to do but Adobe Illustrator can't open the generated file. Instead it can open the tif if it doesn't contain the GDAL colour table... – Bryan Ciceri Apr 24 '15 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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