Learn R Programming

intro

OSMscale is an R package to easily handle and project lat-long coordinates, 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.

OSMscale is available on CRAN:

It relies on OpenStreetMap to do the actual work, thus rjava must be available, see installation tips.

usage

# installation:
install.packages("OSMscale") 
library(OSMscale)

# table with lat-long coordinates:
d <- read.table(sep=",", header=TRUE, text=
"lat, long
55.685143, 12.580008
52.514464, 13.350137
50.106452, 14.419989
48.847003, 2.337213
51.505364, -0.164752")
pointsMap(lat, long, data=d)

# projections:
png("ExampleMap.png", width=4, height=3, units="in", res=150)
map <- pointsMap(lat, long, data=d, type="nps", proj=putm(d$long), scale=FALSE)
scaleBar(map, abslen=500, y=0.8, cex=0.8)
lines(projectPoints(d$lat, d$long), col="blue", lwd=3)
points(projectPoints(52.386609, 4.877008, to=putm(zone=32)), cex=3, lwd=2, col="purple")
dev.off()

Copy Link

Version

Install

install.packages('OSMscale')

Monthly Downloads

824

Version

0.5.23

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Berry Boessenkool

Last Published

September 30th, 2025

Functions in OSMscale (0.5.23)

biketrack

GPS recorded bike track
checkLL

lat-long coordinate check
earthDist

distance between lat-long coordinates
maxEarthDist

maximum distance between set of points
triangleArea

Area of a triangle
proj

CRS of various PROJ.4 projections
mapComp

Compare map tiles
projectPoints

Project lat-lon points
OSMscale-package

Add a Scalebar to OpenStreetMap Plots
randomPoints

Distanced random points
degree

decimal degree coordinate conversion
equidistPoints

Evenly spaced points along path
pointsMap

Get map for lat-long points
scaleBar

scalebar for OSM plots