Hello everyone, I have no idea how to plotting points over a map using R, in which the colors of the points stand for the points' value. I'd like to get a map as shown in attachment picture which was plotted using matlab. Does anyone know how to do it using R? Thank you very much for your help in advance. Kind regards,Dli -------------- next part -------------- A non-text attachment was scrubbed... Name: 1.png Type: image/png Size: 93672 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20140131/29d99f8c/attachment.png>
library(RgoogleMaps); # download a static map from the Google server library(geomapdata); # Topographic and Geologic Mapping lbrary(PBSmapping); # Draw Maps and Implement Other GIS Procedures STEP1: my_map = GetMap(center=my_center, zoom =my_zoom , destfile=my_out_file ,maptype = "mapmaker-hybrid", size=c(640,640)); ?GetMap for more info STEP2: You can add text ========================= tmp = TextOnStaticMap(my_map,lat = my_markers_1[,"lat"], lon = my_markers_1[,"lon"], labels=as.character(site_names), col="red", cex=1.1, add=F) # STEP 3: you can add points tmp = PlotOnStaticMap(my_map,lat = my_markers[,"lat"], lon = my_markers[,"lon"], cex=2.,pch=10,col=c("black"), add=T) add=T is importent # STEP 4: You can add lines tmp = PlotOnStaticMap(my_map,lat = my_markers_2[,"lat"], lon my_markers_2[,"lon"], col=c("blueviolet"), add=T, FUN = lines, lwd = 3); I hope will help ! Mohammed On Fri, 2014-01-31 at 09:58 +0000, ??? wrote:> Hello everyone, > I have no idea how to plotting points over a map using R, in which the colors of the points stand for the points' value. I'd like to get a map as shown in attachment picture which was plotted using matlab. Does anyone know how to do it using R? Thank you very much for your help in advance. > Kind regards,Dli > ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 01/31/2014 08:58 PM, ??? wrote:> Hello everyone, > I have no idea how to plotting points over a map using R, in which the colors of the points stand for the points' value. I'd like to get a map as shown in attachment picture which was plotted using matlab. Does anyone know how to do it using R? Thank you very much for your help in advance. > Kind regards,DliHi Dli, Your question involves two things, the placement of the points and their color. The coordinate system of maps is almost always geographic, in decimal degrees. The x values are the longitudes measured from the prime meridian that passes through Greenwich, England. The y values are the latitudes that are measured from the equator. To get the colors for the points, if you have some value like average temperature for the points, you can convert the numbers into colors using functions like color.scale in the plotrix package. The resulting vector or matrix of colors can then be passed to the "points" function. Jim