[GRASS-user] display image (photo / jpeg) with PNG driver (i.e. add logo to map).

Hi all,

I would like to add a logo to a map that I am printing with the PNG driver.
It is a .jpg, although I could switch it to another image type if that was
helpful. Is there any way to do that? I know I could add it in photoshop
after the fact, but it would be simpler if I could print it right onto the
map in one go.

Best,
Tim
--
View this message in context: http://n2.nabble.com/display-image-photo-jpeg-with-PNG-driver-i-e-add-logo-to-map-tp3565214p3565214.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Tim Holland wrote:

I would like to add a logo to a map that I am printing with the PNG driver.
It is a .jpg, although I could switch it to another image type if that was
helpful. Is there any way to do that?

Import it as 3 raster maps (red, green, and blue channels) with
r.in.gdal, move the maps to the correct size and location with
r.region, then display them with d.rgb.

This may produce resampling artifacts. Display modules such as d.rgb
will have the input maps resampled to the current region, and will
then resample them to the display resolution.

Setting the current region bounds and resolution to match the display
pixel grid will eliminate one resampling step. Using "r.region -c ..."
to match the raster to the current region will eliminate the other.

Alternatively, if you have the PNG driver generate PPM output (e.g.
GRASS_PNGFILE=map.ppm), you can use g.pnmcomp to composite multiple
PPM/PGM images (all images need to have the same dimensions, and each
PPM file needs a corresponding PGM file containing the alpha channel).

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote:

Tim Holland wrote:

I would like to add a logo to a map that I am printing with the PNG
driver.
It is a .jpg, although I could switch it to another image type if that
was
helpful. Is there any way to do that?

Import it as 3 raster maps (red, green, and blue channels) with
r.in.gdal, move the maps to the correct size and location with
r.region, then display them with d.rgb.

Thank you for the instructions. I am getting an error message with
r.in.gdal, though:

WARNING: G_set_window(): Illegal latitude for North

At present, the file I have is not georeferenced at all - it is just a
normal jpeg. To experiment I tried changing it to a tiff and importing, but
same problem. Do I need to somehow define the region of the image before
importing?

Also, I was not sure how to import as separate r,g,b maps. Is that just a
matter of having band=1, band=2, band=3 in three iterations of r.in.gdal? I
tried to experiment with that a bit, but was still having the 'illegal north
latitude' problem so didn't get anywhere.

Thanks again for the help.

Tim

--
View this message in context: http://n2.nabble.com/display-image-photo-jpeg-with-PNG-driver-i-e-add-logo-to-map-tp3565214p3570947.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Tim Holland wrote:

I am getting an error message with r.in.gdal, though:
>WARNING: G_set_window(): Illegal latitude for North

in gr6.5 and 7 there is a new flag -l to get around that.
"Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)"

if earlier ver, use gdal_translate to convert to geotiff and
assign dummy lat/lon coords to it. then fix it with r.region
once it is inside.

At present, the file I have is not georeferenced at all -
it is just a normal jpeg.

usually a simple-xy location is for that, but then you have
to rectify it into a geo-location.

Also, I was not sure how to import as separate r,g,b maps.

often r.in.gdal does this for you.

Hamish

hamish-2 wrote:

Tim Holland wrote:

I am getting an error message with r.in.gdal, though:
>WARNING: G_set_window(): Illegal latitude for North

if earlier ver, use gdal_translate to convert to geotiff and
assign dummy lat/lon coords to it. then fix it with r.region
once it is inside.

Thanks for the help, Hamish. I think I am getting closer, but still running
into a bit of a hurdle.

What I have done is the following:

gdal_translate -of GTiff -a_ullr 101 16 103 14 -expand rgb

/usr/Documents/logo.tif logo.tif

This proceeds, and generates the logo.tif group (you are right - it does
import with separate bands: logo.red, logo.green, logo.blue). However, it
gives the error message

Error : band 1 has no color table

When I do r.in.gdal,

r.in.gdal -o input=/usr/logo.tif output=logo

it does import the file successfully (as opposed to before giving that
"illegal north latitude" error), so that is a step forward. But (as error
above would suggest), all the bands are either <null> or 0's.

Any ideas?

Thanks again,
Tim

--
View this message in context: http://n2.nabble.com/display-image-photo-jpeg-with-PNG-driver-i-e-add-logo-to-map-tp3565214p3571467.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Tim Holland wrote:

What I have done is the following:

gdal_translate -of GTiff -a_ullr 101 16 103 14 -expand rgb

/usr/Documents/logo.tif logo.tif

This proceeds, and generates the logo.tif group (you are right - it does
import with separate bands: logo.red, logo.green, logo.blue).

Correction:

Sorry, I just realized I wrote something misleading in the above.
gdal_translate does not generate the image group - it generates a single
file 'logo.tif' in the root directory. The individual rasters for the three
bands (logo.red, .green, .blue) are generated by r.in.gdal.

Tim
--
View this message in context: http://n2.nabble.com/display-image-photo-jpeg-with-PNG-driver-i-e-add-logo-to-map-tp3565214p3571476.html
Sent from the Grass - Users mailing list archive at Nabble.com.