I wish to use the Wikimapia map as background in GeoGraphics. According to the Wikimapia Docs, Wikimapia's URL is encoded as follows:

An example Wikimapia URL is http://wikimapia.org/#lat=53.9560855&lon=-1.9335937&z=3&l=0&m=a&v=2. The purpose of each of the variables is:

  • lat= The latitude of the centre cross in decimal degrees
  • lon= The longitude of the centre cross in decimal degrees
  • z= The zoom level. The closest available tends to be the range z=14 to z=18 but there are exceptions such as the oceans or major cities.

From the above I conclude that the StringTemplate for GeoServer should be encoded as "http://wikimapia.org/#lat=`2`&lon=`3`&z=`1`" but it does not work:

GeoGraphics[GeoMarker[], GeoRange -> Quantity[1, "Kilometers"], 
 GeoServer -> {"http://wikimapia.org/#lat=`2`&lon=`3`&z=`1`"}]

returns the GeoGraphics::data error.

What is the correct way to use Wikimapia as the source of map for GeoGraphics?

  • 4
    The link you provided is not to a "tile server" (it appears Wikimapia does not offer one). Such servers return images of map tiles corresponding to the parameters in a request, rather than a user interface like the link you gave. Here are some alternatives: wiki.openstreetmap.org/wiki/Tile_servers (url in narrow column toward right) – mfvonh Aug 4 '15 at 13:53
  • If I may, I found easier to download the tiles I needed and the rasterize them using the coordinates of the bounding box (with the right coordinates). Of course, you wouldn't be using GeoGraphics then. (Just additional information, not really an answer) – mgm Aug 4 '15 at 14:42
up vote 27 down vote accepted

In the comments mfvonh correctly points out that the Wikimapia's URL in my question is a user interface URL, not a tile server URL. The tile server link template is documented in a message which appears when one sends incorrect request to the tile server:

message

From the above it is clear that the StringTemplate should be as follows:

StringTemplate["http://i<*Mod[#2,4]+Mod[#3,4]*4*>.wikimapia.org/?x=`2`&y=`3`&zoom=`1`"]

The tile server also accepts lng parameter which specifies the language of the map (addition of &lng=0 selects English) and type parameter which specifies the type of the map: hybrid (semi-transparent) or map (the default for the tile server, doesn't have alpha-channel). The largest supported zoom level is 22, so we should add the "ZoomRange" -> {1, 22} option. Wikimapia as well as Google and OpenStreetMap uses the

EPSG:3857 - WGS 84/Pseudo-Mercator (Spherical Mercator)

projection which seems to be the default for GeoGraphics, so we may not specify it explicitly.

Testing:

GeoGraphics[GeoRange -> Entity["City", {"Paris", "IleDeFrance", "France"}], 
 GeoServer -> {StringTemplate[
    "http://i<*Mod[#2,4]+Mod[#3,4]*4*>.wikimapia.org/?x=`2`&y=`3`&zoom=`1`&lng=0"], 
    "ZoomRange" -> {1, 22}}]

geographics

Let us try to use the Wikimapia API for highlighting the basement of the Eiffel Tower:

data = Import[
   "http://api.wikimapia.org/?key=example&function=place.getbyid&id=55&format=json&pack=&\
language=en", "JSON"];
GeoGraphics[{EdgeForm[{DotDashed, Blue, Thick}], FaceForm[], 
  Polygon[("polygon" /. data)[[;; , ;; , 2]]]}, 
 GeoServer -> {StringTemplate[
    "http://i<*Mod[#2,4]+Mod[#3,4]*4*>.wikimapia.org/?x=`2`&y=`3`&zoom=`1`&lng=0"], 
    "ZoomRange" -> {1, 22}}, GeoRangePadding -> Scaled[0.5]]

geographics3

Compare with the default map:

GeoGraphics[{EdgeForm[{DotDashed, Blue, Thick}], FaceForm[], 
  Polygon[("polygon" /. data)[[;; , ;; , 2]]]}, GeoRangePadding -> Scaled[0.5]]

geographics4

Obtain satellite image of the Eiffel Tower from Google and highlight its basement (in this template the version number of Google maps v=196 may require updating to the current version number):

GeoGraphics[{EdgeForm[{Red, Thickness[.005]}], FaceForm[], 
  Polygon[("polygon" /. data)[[;; , ;; , 2]]]}, ImageSize -> 1000, 
 GeoServer -> {StringTemplate[
    "http://khms<*Mod[#2+#3,4]*>.googleapis.com/kh?x=`2`&y=`3`&z=`1`&v=196"], 
   "ZoomRange" -> {1, 21}}]

geographics5

Obtain satellite image from Google and overlay it with the semi-transparent map from Wikimapia:

satellite = 
  GeoGraphics[GeoCenter -> GeoPosition[{48.8635510693252, 2.24669540329895}], 
 GeoServer -> {StringTemplate[
    "http://khms<*Mod[#2+#3,4]*>.googleapis.com/kh?x=`2`&y=`3`&z=`1`&v=196"],  
    "ZoomRange" -> {1, 21}}, 
   GeoRange -> Quantity[2, "Kilometers"], AspectRatio -> 1];
overlay = GeoGraphics[GeoCenter -> GeoPosition[{48.8635510693252, 2.24669540329895}], 
   GeoServer -> {StringTemplate[
      "http://i<*Mod[#2,4]+Mod[#3,4]*4*>.wikimapia.org/?x=`2`&y=`3`&zoom=`1`&lng=0&type=hybrid"], 
    "ZoomRange" -> {1, 22}}, GeoRange -> Quantity[2, "Kilometers"]];
GraphicsRow[{satellite, overlay}, ImageSize -> 600]

graphics row

ImageCompose @@ Cases[{satellite, overlay}, _Image, -1]

image

  • 3
    Awesome stuff. I never used wikimapia. What are its main benefits? – Emy Aug 5 '15 at 21:59
  • 3
    @Emy Wikimapia is clearly superior to OpenStreetMap and Google when you need detailed map for little-inhabited or uninhabited areas. But the main (and AFAIK unique) feature of Wikimapia is a Wiki article for every object on the map. – Alexey Popkov Aug 6 '15 at 14:14
  • Nice. I looked at this yesterday and could get their api to work quite well, but couldn't find the tile hook. (+1). – kale Aug 8 '15 at 11:33
  • Unfortunately the access to googleapi does not work anymore: GeoGraphics[GeoCenter -> GeoPosition[{48.8635510693252, 2.24669540329895}], GeoServer -> {StringTemplate[ "khms<*Mod[#2+#3,4]*>.googleapis.com/kh?x=2&y=3&z=1&v=196"], "ZoomRange" -> {1, 21}}, GeoRange -> Quantity[2, "Kilometers"], AspectRatio -> 1] gives an error. What has to be changed to enable this again? – hippo3773 Jan 4 '17 at 13:07
  • @hippo3773 Seemingly you should update the version number of Google maps v=196 to current version number. But I do not know the current number, you can find it by monitoring URLs which GoogleEarth requests. – Alexey Popkov Jan 4 '17 at 13:30

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.