[R-sig-Geo] Quantile map with plotGoogleMaps (legend problem)

Marc Marí Dell'Olmo marceivissa at gmail.com
Wed Mar 12 14:28:37 CET 2014


Dear Milan,

I have solved the problem. I think that the problem occurs when the
png file is being saved.

I installed R in another computer and executing my syntax I obtained this error:

> library(RColorBrewer)
> library(rgdal)
>
> carto<-readShapeSpatial("C:/Users/mmari/Documents/ESTUDIS/Atles Interactiu/duda/carto.shp")
> proj4string(carto) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
> plotGoogleMaps(carto, zcol="RMEs", filename="C:/Users/mmari/Documents/ESTUDIS/Atles Interactiu/duda/map.html",mapTypeId='ROADMAP', colPalette= brewer.pal(7,"Reds"),strokeColor="white", openMap=T)
Error en png(filename = paste(legendName, ".png", sep = ""), height = h,  :
  unable to start png() device
Además: Mensajes de aviso perdidos
1: In png(filename = paste(legendName, ".png", sep = ""), height = h,  :
  unable to open file 'Legend17c025a8181c.png' for writing
2: In png(filename = paste(legendName, ".png", sep = ""), height = h,  :
  opening device failed

I have solved the problem by simply adding a working directory and not
including any path into the syntax. i.e.

library(plotGoogleMaps)
library(RColorBrewer)
library(rgdal)

setwd("C:/Users/mmari/Documents/ESTUDIS/Atles Interactiu/duda")

carto<-readShapeSpatial("carto.shp")
proj4string(carto) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
plotGoogleMaps(carto, zcol="RMEs",
filename="map.html",mapTypeId='ROADMAP', colPalette=
brewer.pal(7,"Reds"),strokeColor="white", openMap=T)

Thus, the png file has been saved in the working directory with the htm file.

Thank you and congratulations on the great library that you've performed!!



2014-03-07 14:59 GMT+01:00 Marc Marí Dell'Olmo <marceivissa at gmail.com>:
> Dear Milan,
>
> yes, with your reproducible example I can see the legend. But, with my
> data I can't see it...
>
> It is very strange. I will try it at home, because I'm using the job
> computer and maybe not having administrator rights could be a
> problem... I don't know...
>
> Thank you!
>
>
> 2014-03-07 14:46 GMT+01:00 Milan Kilibarda <milan.kili11 at gmail.com>:
>> Hi Mark,
>>
>> I reproduce your example without any problem, and it works in Chrome,
>> Mozilla and IE.
>>
>> Here is your example:
>>
>> https://dl.dropboxusercontent.com/u/20743714/duda.zip
>>
>> Here is reproducible example:
>>
>> library(plotGoogleMaps)
>> nc <- readShapeSpatial(
>> system.file("shapes/sids.shp",package="maptools")[1],
>>                                     proj4string=CRS("+proj=longlat
>> +datum=NAD27"))
>> library(RColorBrewer)
>>
>> m<-plotGoogleMaps(nc,zcol="NWBIR74",filename='MyMap6.htm',
>> mapTypeId='TERRAIN',colPalette= brewer.pal(7,"Reds"),
>> strokeColor="white")
>>
>> Check your version of R and packages.
>>
>> sessionInfo()
>> R version 3.0.2 (2013-09-25)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
>> Kingdom.1252
>> [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
>> [5] LC_TIME=English_United Kingdom.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] RColorBrewer_1.0-5 plotGoogleMaps_2.0 lattice_0.20-24    maptools_0.8-29
>> rgdal_0.8-16
>> [6] sp_1.0-14
>>
>> loaded via a namespace (and not attached):
>> [1] foreign_0.8-59 grid_3.0.2     tools_3.0.2
>>
>> Best,
>>
>> Milan
>>
>>
>>
>>
>> On Fri, Mar 7, 2014 at 2:24 PM, Marc Marí Dell'Olmo <marceivissa at gmail.com>
>> wrote:
>>>
>>> Dear all,
>>>
>>> I'm trying to do a quantile map (specifically septile map) with
>>> plotGoogleMaps. I obtain the map, but this map don't display the
>>> legend with the septiles intervals. Moreover, I can display the map
>>> with firefox, but I have problems with explorer...
>>>
>>> This is the sintax that I have used:
>>> carto<-readShapeSpatial("C:/duda/carto.shp")
>>> proj4string(carto) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
>>> plotGoogleMaps(carto, zcol="RMEs", filename="C:/duda/map.html",
>>> mapTypeId='ROADMAP', colPalette= brewer.pal(7,"Reds"),
>>> strokeColor="white", openMap=T)
>>>
>>>
>>> With the following link you can download the data to execute this
>>> syntax and the file "map.html" with the map:
>>>
>>> https://dl.dropboxusercontent.com/u/14934021/duda.zip
>>>
>>>
>>> Thank you very much!
>>>
>>>
>>> Marc
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>>
>>
>> --
>> Dr. Milan Kilibarda
>>
>> University of Belgrade,
>> Faculty of Civil Engineering,
>> Department of Geodesy and Geoinformatics,
>> Address: Bulevar kralja Aleksandra 73  11000 Belgrade, Serbia,
>> Mail:  kili at grf.bg.ac.rs
>>
>> tel:+381 11 3218516



More information about the R-sig-Geo mailing list