[R-sig-eco] Generate Geotiff with colors

Marc Girondot marc_grt at yahoo.fr
Sat Feb 1 12:02:16 CET 2014


I solve the problem with the option rgb=TRUE and all is ok:
library("dismo")
e <-  extent( 3.25 , 3.35 , 6.38 , 6.48 )
r1 <- gmap(e, lonlat=TRUE, rgb=TRUE)
writeRaster(r1, filename="maps/raster1.tif", format="GTiff", 
overwrite=TRUE)
plotRGB(r1)

(I discover also the discussion list r-sig-geo which was more 
appropriate for this question)

Marc

Le 01/02/2014 06:20, Marc Girondot a écrit :
> Dear colleagues,
>
> I try to generate a geotiff in R. It works except that the tif file 
> has no color when I open it in QGis.
>
> Here is the R code:
> library("dismo", "rgdal", "raster")
> # define a Nigeria region
> e <-  extent( 3.25 , 3.35 , 6.38 , 6.48 )
> # get the image from GoogleMap server
> r1 <- gmap(e, lonlat=TRUE)
> # plot the map, colors are present
> plot(r1) # first problem... why the black lines around the image. They 
> are not present if I use lonlat=FALSE
> # save it in geotiff
> writeRaster(r1, filename="maps/raster1.tif", format="GTiff", 
> overwrite=TRUE)
>
> And when I open it in Qgis, it has no color...
>
> Any ideas ?



More information about the R-sig-ecology mailing list