Open Source Routing Machine, or OSRM, is a routing software based on OpenStreetMap (OSM) data. OSRM can be used to find the fastest route between points, to compute time or distance matrices between set of points or to solve the traveling salesman problem.As maintainer of the osrm R package I often find myself advising users to use their own instance of OSRM to enable them to send a large number of requests and not overload the demo server. In these cases I simply point to the Docker installation instructions in the project’s README file. These instructions may not be detailed enough to build an OSRM instance on a large area. OSRM needs a lot of RAM to prepare the road network for requests and using only these instructions will probably result in message like this one:
[warn] Please provide more memory or consider using a larger swapfile
This problem is addressed in this issue on the OSRM GitHub repository. The suggested solution is to rent a temporary server. This is not the only solution, a modern computer with a rather classical hardware configuration can actually do the job.
In this post I’ll explain how to build a European-wide OSRM instance on a desktop computer. These explanations are, to a certain extent, also valid when using a remote server.
mapsf helps to design various cartographic representations such as proportional symbols, choropleth or typology maps. It also offers several functions to display layout elements that improve the graphic presentation of maps (e.g. scale bar, north arrow, title, labels). mapsf maps sf objects on base graphics.
The potential package provides functions to compute potential models as defined by John Q. Stewart. Several options are available to customize the models, for example it is possible to refine the distance friction functions or to use custom distance matrices. Some functions use parallelization to improve their efficiency.
The aim of potential is to replace potential-related functions of the SpatialPosition package. SpatialPosition was built to compute 3 spatial position models (Stewart potentials, Reilly catchment areas, Huff catchment areas) in a time where sf was not published yet (May 2015). potential functions use a simplified interface and are more efficient than their counterpart in SpatialPostion. My recommendation to SpatialPositon users is thus to switch to potential for the computation of potentials.
A didactic vignette describing the methodology and functions is provided as well as a website.
To create maps from tiles, maptiles downloads, composes and displays tiles from a large number of providers (e.g. OpenStreetMap, Stamen, Esri, CARTO, or Thunderforest).
Installation
You can install the released version of maptiles from CRAN with:
install.packages("maptiles")
You can install the development version of maptiles from GitHub with:
maptiles gives access to a lot of tiles servers, but it is possible to add others. The following example demonstrates the setting of a map tiles server and how to cache the original tiles for future use:
The following figure shows mini maps for most of the tiles providers available:
Attribution of map tiles
All maps available through maptiles are offered freely by various providers. The only counterpart from the user is to properly display an attribution text on the maps. get_credit() displays a short credit text to add on each map using the downloaded tiles.
Background
Most of maptilescode comes from getTiles() and tilesLayer() functions in cartography. It appears useful to me to have a package focused on the download and display of map tiles only. On the technical side, it uses terra instead of raster for managing raster data.
Alternatives
There are many alternative packages that pursue the same objective as maptiles. Some focus on a specific map tiles provider (e.g. mapbox, google, OpenStreetMap) or on a specific graphics device (ggplot2). The goal of maptiles is to be flexible enough to allow the use of different providers and to have a minimal number of robust and modern dependencies. However, depending on the use case, one of following packages may better suit your needs:
Not to be confused with tilemaps, that “implements an algorithm for generating maps, known as tile maps, in which each region is represented by a single tile of the same shape and size.”
In cartography several functions have a pos or legend.pos argument. These arguments can take the following values: “topleft”, “top”, “topright”, “right”, “bottomright”, “bottom”, “bottomleft”, “bottomleftextra”, “left” or a vector of two coordinates in map units (c(x, y)).
The osrm package is an interface between R and the OSRM API. OSRM is a routing service based on OpenStreetMap data. This package allows computing shortest paths, travel time and travel distance matrices between points.
The popcircle package has been released on GitHub. This one-function package computes circles with areas scaled to a variable and displays them using a compact layout (higher values in the center, lower values at the periphery). Original polygons are scaled to fit inside these circles (size are roughly proportional, not strictly).
The circles creation relies on packcircles, spatial data manipulation relies on sf.
The tanaka package has been released on CRAN. This package is a simplified implementation of the Tanaka method. Also called “relief contours method”, “illuminated contour method” or “shaded contour lines method”, the Tanaka method enhances the representation of topography on a map using shaded contour lines. North-west white contours represent illuminated topography and south-east black contours represent shaded topography.
The contour lines creation relies on isoband, spatial data manipulation and display rely on sf.
This post shows how to build a colored pencil map with R.
The cartography package (in its development version) has gained a getPencilLayer() function that transforms a POLYGON or MULTIPOLYGON layer into a MULTILINESTRING layer mimicking a pencil drawing pattern.
This post exposes some cartographic explorations of the OpenStreetMap (OSM) database with R.
These explorations begin with the downloading and the cleaning of OSM data. Then I propose a set of map visualizations of the spatial distributions of bars and restaurants in Paris. Of course, these examples could be adapted to other spatial contexts and thematics (e.g. pharmacies in Roma, bike parkings in Dublin…).
A new version of the cartography package (v2.0.1) has arrived on CRAN.
cartography allows various cartographic representations such as proportional symbols, chroropleth, typology, flows or discontinuities maps. It also offers several features enhancing the graphic presentation of maps like cartographic palettes, layout elements (scale, north arrow, title…), labels, legends or access to some cartographic APIs.
Up to version 1.4.2 cartography was mainly based on sp and rgeos for its spatial data management and geoprocessing operations. These dependencies have been as much as possible replaced by sf functions since version 2.0.0.
Most functions are kept unchanged except for the addition of an x argument used to take sf objects as inputs.
See the NEWS file for the full list of changes and see sf README in case of installation problems with sf. Continuer la lecture de New version of the cartography package→