22
$\begingroup$

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?

$\endgroup$
2
  • 4
    $\begingroup$ 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) $\endgroup$
    – mfvonh
    Aug 4, 2015 at 13:53
  • $\begingroup$ 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) $\endgroup$
    – mgm
    Aug 4, 2015 at 14:42

1 Answer 1

27
$\begingroup$

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

$\endgroup$
6
  • 3
    $\begingroup$ Awesome stuff. I never used wikimapia. What are its main benefits? $\endgroup$
    – Emy
    Aug 5, 2015 at 21:59
  • 3
    $\begingroup$ @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. $\endgroup$ Aug 6, 2015 at 14:14
  • $\begingroup$ Nice. I looked at this yesterday and could get their api to work quite well, but couldn't find the tile hook. (+1). $\endgroup$
    – kale
    Aug 8, 2015 at 11:33
  • $\begingroup$ 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? $\endgroup$
    – hippo3773
    Jan 4, 2017 at 13:07
  • 2
    $\begingroup$ Yes - thanks! I found another syntax which works perfectly and which does not require the version number of Google maps: GeoServer -> "http://mt0.google.com/vt/lyrs=s,h&x=2&y=3&z=1" $\endgroup$
    – hippo3773
    Jan 5, 2017 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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