r - PlotGoogleMaps -Need help in bubbleGoogleMaps -


i learning r , love far. impressed 1 of example provided in "plotgooglemaps" package. possible apply below example? please help.

the example see in package

    # data preparation     library(plotgooglemaps)     data(meuse)     coordinates(meuse)<-~x+y     proj4string(meuse) <- crs('+init=epsg:28992')      m<-bubblegooglemaps(meuse,zcol='zinc')      m<-bubblegooglemaps(meuse,zcol='cadmium',layername='bubble plot - meuse',                         colpalette=terrain.colors(5),strokecolor=&rdquo;) 

i apply above example map below data. in example sale = zinc (in above example). , want display other attributes while highlighting bubble.

  library(plotgooglemaps)     bubblechart = read.table(text="itemcode,sale,name,longt,latit                         101,1112,a,-89.6171,35.24992                    105,1540,b,-90.0154,35.10510                    106,2200,c,-89.5213,34.93277                    111,1599,d,-86.8642,36.34807                    113,4500,e,-86.6125,36.19958                    114,3569,f,-90.4611,30.02196",                    header=true,sep=",") 

please help...

bubblegooglemaps() requires transform bubblechart data in spatialpointsdataframe. need specify coordinates , reference system in longitude , latitude measured. there related gis stackexchange question: converting geographic coordinate system in r. see wikipedia page of world geodetic system (used gps).

inspect existing spatialpointsdataframe

library(plotgooglemaps) data(meuse) # meuse data frame class(meuse) # specify coordinates , projection system coordinates(meuse)<-~x+y proj4string(meuse) <- crs('+init=epsg:28992') # meuse has become "spatialpointsdataframe" class(meuse) # contains several objects class(meuse@data) class(meuse@coords) summary(meuse@coords) class(meuse@bbox) class(meuse@proj4string) help(spatialpointsdataframe) # convert meuse data frame  meusedtf <- as.data.frame(meuse) 

create own spatialpointsdataframe

# set coordinates , reference system coordinates(bubblechart) <- ~longt +latit proj4string(bubblechart) <- crs("+init=epsg:4326") # wgs 84 

generate maps

m <- bubblegooglemaps(bubblechart, zcol='sale', max.radius = 20000) 

enter image description here

change max.radius parameter change bubble size. , change key.entries parameter set different boundaries on sales values.

you can display sales bubbles r plot with:

plot(bubblechart) points(bubblechart@coords, pch=21, cex=(bubblechart$sale)/1000, col="black", bg="blue") bubble(bubblechart, "sale", maxsize = 2.5, main = "sales in us", key.entries = 2^(-1:4)) 

these r plots nicer if add map of states in background identify areas.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -