gis_server-package: Locally storing and rendering OSM maps.

Description Usage Arguments Examples

Description

The get_background function loads and plots pre-rendered map background.

Usage

1
2
get_background(xy, map_data = "extdata", mapdb_name = "MapID.db", proj,
  init_proj, options_list = NULL)

Arguments

xy

a data frame of network graph's coordinates, with columns labelled 'Longitude' and 'Latitude'.

map_data

a path to the directory including maps.

mapdb_name

a character string with the name of the map database.

proj

a string specifying the geographic projection of the network graph, e.g. "+init=epsg:4326".

init_proj

a string specifying the geographic projection of the map database (by default "+init=epsg:4326").

options_list

a set of mainly graphical parameters used by the rendering engine:

mscale

specifies the scale of the map, e.g. 5000 stands for 1:5000 map,

url

an url to a map view on osm.org can be provided to define the bounding box if no coordinates are provided,

wld

this option specifies whether a so called world file should be printed; a world file explicitly specifies the extent of a generated raster object; this option defaults to FALSE, as normally the coordinates are stored in the map database,

dpi

a parameter specifying the optical resolution of the output map; default value is 200,

paper

an optional parameter specifying paper size of the output map, e.g 'a+4'; usually this option is not used, as the map size is the product of scale, resolution and spatial extent,

margin

a parameter specifying the margin around the extent of the input object expressed as percent of the difference between xmax and xmin and ymax and ymin,

size

target map dimensions in mm (W x H, one 0 allowed),

xmstyle

mandatory argument, the full path to the xml style file for mapnik,

output

mandatory argument, specifies the name and most importantly the extension of the file; default output format has been set to JPEG.

tiles

Write n x n tiles, then join using imagemagick montage command; this argument is used if the size of the map exceeds maximal mapnik output size; default value is FALSE; CAUTION: .pdf files can be output directly, but are not valid for tiling, for a city the size of e.g. Szczecin (Poland) the highest available map scale is ca. 1:7000.

just_tiles

Do not join tiles, instead write ozi/wld file for each; used only in conjunction with 'tiles', defaults to FALSE.

force_rend

If there is no map fulfilling the desired criteria and the parameter is set to FALSE, there will be no attempt at rendering. If the parameter is set as TRUE, a map with specified criteria will be rendered.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
###########################################################

# Loading the package
library(gisserver)

# Generating artificial points

Longitude <- runif(100, min =  20.9,  max = 21.05)
Latitude <- runif(100, min = 52.2, max = 52.25)
xy <- as.data.frame(cbind(Longitude, Latitude))

# Setting the projection of the graph coordinates (proj) and the projection of the underlying map (init_proj)

proj = "+init=epsg:4326" 
init_proj = "+init=epsg:4326" # default OSM coordinate reference system

options_list  <- list(mscale = 29000,
                      url = NULL,
                      wld = FALSE,
                      dpi = 200,
                      paper = NULL,
                      margin = 0.01,
                      size = NULL,
                      xmstyle = "C:/GIS_data/osm_mapnik/gis.xml",
                      output  = "map.png",
                      tiles = FALSE,
                      just_tiles = FALSE,
					           force_rend = TRUE)

# Fetching the map background

get_background(xy = xy,
              map_data = "extdata",
              mapdb_name = "MapID.db",
              proj = proj,
              init_proj = init_proj,
              options_list = options_list)

# Plotting the points on the background

points(xy, col = 'red', lwd = 3)

###########################################################

PawelMG/gis_server documentation built on May 9, 2019, 2:24 p.m.