A new version of the OpenStreetMap package has been released to CRAN. OpenStreetMap 0.3.3 contains several minor improvements. I’ve removed the CloudMade tile set types, as they seem to have gone out of business. MapQuest has also been removed as they have moved to a new API. The mapbox type has been updated to use their new API.
The most important update is the ability to use custom tile servers. Suppose you have a server using the tile map service specification with access urls looking something like
http://api.someplace.com/{z}/{x}/{y}.png*
where {z} is the map’s integer zoom level, {x} is the tile’s integer x position and {y} is the tile’s integer y position. You may pass this url into openmap’s type argument to obtain a map using this tileset.
For example, if you need to access MapQuest’s tilesets, which now require a developer API key, you can use the new custom tileserver facility to access them. Below is an example with my (free) API key.
ul <- c(40.9,-74.5) lr <- c(40.1,-73.2) par(mfrow=c(2,3)) url <- "https://a.tiles.mapbox.com/v4/mapquest.streets-mb/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg" map <- openmap(ul,lr,minNumTiles=4, type=url) plot(map) url <- "https://a.tiles.mapbox.com/v4/mapquest.satellitenolabels/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg" map <- openmap(ul,lr,minNumTiles=4, type=url) plot(map) url <- "https://a.tiles.mapbox.com/v4/mapquest.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg" map <- openmap(ul,lr,minNumTiles=4, type=url) plot(map) url <- "https://a.tiles.mapbox.com/v4/mapquest.dark/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg" map <- openmap(ul,lr,minNumTiles=4, type=url) plot(map) url <- "https://a.tiles.mapbox.com/v4/mapquest.light/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg" map <- openmap(ul,lr,minNumTiles=4, type=url) plot(map)
5 replies on “New Version of the OpenStreetMap R Pacakge”
Thanks for the update!
Question: what is the “access_token” composed of, or how do you create it ?
I got my own API key from mapquest, which consists of a “consumer key” and “consumer secret”.
So I gave it a try with filling in my “consumer key” for the access token, but I get a null pointer exception.
(the same code DOES work with your access_token).
Ciao,
W.
I believe that it is created by leaflet, but I’m not 100% sure. I found it by creating a little page (http://blog.fellstat.com/wp-content/uploads/2016/09/tmp.html) using my consumer key and looking at the urls that were getting accessed (See for instance: chrome developer tools).
You can try the same thing replacing my key by yours in tmp.html.
Thanks for your quick reply.
I followed your instructions and put my own key in a tmp.html file, and viewed this in a browser, keeping an eye on network traffic.
To my surprise it shows the same access token, as the one you use…
See snap: http://wmo.co/scrap/mq_token.png
So: are you sure that access token is linked to your mapquest API key?
Maybe it belongs to leaflet????
I don’t know. Perhaps mapquest has a global access token? I assume that you checked that the end of the token was also the same (I can’t tell by the screen grab). Here is some info on access tokens https://www.mapbox.com/help/define-access-token/
Yep, the token was the same from the first to the last letter.