Skip to main content

geography - How to use WikiMapia as GeoServer?


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?



Answer



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


Comments

Popular posts from this blog

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

mathematical optimization - Minimizing using indices, error: Part::pkspec1: The expression cannot be used as a part specification

I want to use Minimize where the variables to minimize are indices pointing into an array. Here a MWE that hopefully shows what my problem is. vars = u@# & /@ Range[3]; cons = Flatten@ { Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; Minimize[{Total@((vec1[[#]] - vec2[[u[#]]])^2 & /@ Range[1, 3]), cons}, vars, Integers] The error I get: Part::pkspec1: The expression u[1] cannot be used as a part specification. >> Answer Ok, it seems that one can get around Mathematica trying to evaluate vec2[[u[1]]] too early by using the function Indexed[vec2,u[1]] . The working MWE would then look like the following: vars = u@# & /@ Range[3]; cons = Flatten@{ Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; NMinimize[ {Total@((vec1[[#]] - Indexed[vec2, u[#]])^2 & /@ R...

What is and isn't a valid variable specification for Manipulate?

I have an expression whose terms have arguments (representing subscripts), like this: myExpr = A[0] + V[1,T] I would like to put it inside a Manipulate to see its value as I move around the parameters. (The goal is eventually to plot it wrt one of the variables inside.) However, Mathematica complains when I set V[1,T] as a manipulated variable: Manipulate[Evaluate[myExpr], {A[0], 0, 1}, {V[1, T], 0, 1}] (*Manipulate::vsform: Manipulate argument {V[1,T],0,1} does not have the correct form for a variable specification. >> *) As a workaround, if I get rid of the symbol T inside the argument, it works fine: Manipulate[ Evaluate[myExpr /. T -> 15], {A[0], 0, 1}, {V[1, 15], 0, 1}] Why this behavior? Can anyone point me to the documentation that says what counts as a valid variable? And is there a way to get Manpiulate to accept an expression with a symbolic argument as a variable? Investigations I've done so far: I tried using variableQ from this answer , but it says V[1...