Functionality to handle and project lat-long coordinates, easily download background maps and add a correct scale bar to 'OpenStreetMap' plots in any map projection. There are some other spatially related miscellaneous functions as well.

This package relies on OpenStreetMap to do the actual work. Thus you must have Java installed in the in same bit-version as R (eg 64bit). The Java binary file must be on the search path, which will normally happen automatically.

Code to install from CRAN: CRAN_Status_Badge downloads

install.packages("rJava"); library("rJava") # ensure that the java exucutable can be found

# The CRAN version is currently (sept 2016) outdated because of intense development.
# I'm working on updating it...
# To update to the most recent development version:

Basic usage:

d <- read.table(sep=",", header=TRUE, text=
"lat, long # could e.g. be copied from googleMaps, rightclick on What's here?
55.685143, 12.580008
52.514464, 13.350137
50.106452, 14.419989
48.847003, 2.337213
51.505364, -0.164752")
png("ExampleMap.png", width=4, height=3, units="in", res=150)
par(mar=c(0,0,0,0) )

map <- pointsMap(lat, long, data=d, type="maptoolkit-topo", utm=TRUE, scale=FALSE)
scaleBar(map, abslen=500, y=0.8, cex=0.8)
lines(projectPoints(d$lat, d$long), col="blue", lwd=3)



If direct installation doesn't work, your R version might be too old. In that case, an update is really recommendable: r-project.org. If you can't update R, try installing from source (github) via instGit as mentioned above. If that's not possible either, here's a manual workaround: click on Clone/Download - Download ZIP (at the top or here), unzip the file to some place, then

dd <- dir("OSMscale-master/R", full=T)
dummy <- sapply(dd, source)

This creates all R functions as objects in your globalenv workspace (and overwrites existing objects of the same name!).