pointsMap: Get map for lat-long points

View source: R/pointsMap.R

pointsMapR Documentation

Get map for lat-long points

Description

Download and plot map with the extend of a dataset with lat-long coordinates.

Usage

pointsMap(
  lat,
  long,
  data,
  ext = 0.07,
  fx = 0.05,
  fy = fx,
  type = "osm",
  zoom = NULL,
  minNumTiles = 9L,
  mergeTiles = TRUE,
  map = NULL,
  proj = NA,
  plot = TRUE,
  mar = c(0, 0, 0, 0),
  add = FALSE,
  scale = TRUE,
  quiet = FALSE,
  pch = 3,
  col = "red",
  cex = 1,
  bg = NA,
  pargs = NULL,
  titleargs = NULL,
  ...
)

Arguments

lat, long

Latitude (North/South) and longitude (East/West) coordinates in decimal degrees

data

Optional: data.frame with the columns lat and long

ext

Extension added in each direction if a single coordinate is given. DEFAULT: 0.07

fx, fy

Extend factors (additional map space around actual points) passed to custom version of extendrange. DEFAULT: 0.05

type

Tile server in OpenStreetMap::openmap. For an overview, see https://blog.fellstat.com/?p=356 and mapComp. DEFAULT: "osm"

zoom, minNumTiles, mergeTiles

Arguments passed to openmap

map

Optional map object. If given, it is not downloaded again. Useful to project maps in a second step. DEFAULT: NULL

proj

If you want to reproject the map (Consumes some extra time), the proj4 character string or CRS object to project to, e.g. putm(long=long). DEFAULT: NA (no conversion)

plot

Logical: Should map be plotted and points added? Plotting happens with OpenStreetMap::plot.OpenStreetMap(map, removeMargin=FALSE). DEFAULT: TRUE

mar

Margins to be set first (and left unchanged). DEFAULT: c(0,0,0,0)

add

Logical: add points to existing map? DEFAULT: FALSE

scale

Logical: should scaleBar be added? DEFAULT: TRUE

quiet

Logical: suppress progress messages and non-df warning in getColumn? DEFAULT: FALSE

pch, col, cex, bg

Arguments passed to points, see pargs for more. DEFAULT: pch=3, col="red", cex=1, bg=NA

pargs

List of arguments passed to points like lwd, type, cex, ...

titleargs

List of arguments passed to title (if not NULL). DEFAULT: NULL

...

Further arguments passed to scaleBar like abslen, ndiv, ...

Value

Map returned by OpenStreetMap::openmap

Author(s)

Berry Boessenkool, berry-b@gmx.de, Jun 2016

See Also

projectPoints, OpenStreetMap::openmap

Examples

if(interactive()){
d <- read.table(sep=",", header=TRUE, text=
"lat, long # could e.g. be copied from googleMaps, rightclick on What's here?
43.221028, -123.382998
43.215348, -123.353804
43.227785, -123.368694
43.232649, -123.355895")

map <- pointsMap(lat, long, data=d)
axis(1, line=-2); axis(2, line=-2) # in whatever unit
map_utm <- pointsMap(lat, long, d, map=map, proj=putm(d$long))
axis(1, line=-2); axis(2, line=-2) # now in meters
projectPoints(d$lat, d$long)
scaleBar(map_utm, x=0.2, y=0.8, unit="mi", type="line", col="red", length=0.25)
pointsMap(lat, long, d[1:2,], map=map_utm, add=TRUE, col="red", pch=3, pargs=list(lwd=3))

d <- data.frame(long=c(12.95, 12.98, 13.22, 13.11), lat=c(52.40,52.52, 52.36, 52.45))
map <- pointsMap(lat,long,d, type="bing") # aerial map
}


OSMscale documentation built on Oct. 13, 2023, 5:10 p.m.