0
$\begingroup$

This question already has an answer here:

I am trying to plot a list of {latitude,longitude,f(latitude,longitude)} values over a mercator projection. I tried a generic periodic function in spherical coordinates, but the output looks wrong. I was expecting a set of stripes equally separeted along the longitude. This is my code:

Inc = Pi/2;
f[θ_, Φ_] = Cos[6*Φ];
x = (Pi/2 - θ)*180/Pi;
y = (Pi - Φ)*180/Pi;
M = Table[{x, y, N[f[θ, Φ]]}, {θ, 0, π, 
    Inc/2}, {Φ, 0, 2 π, Inc}];
plot = ListContourPlot[M, 
   DataRange -> {{-90, 90}, {-180, 180}, Automatic}, Frame -> False, 
   InterpolationOrder -> 2, ImageSize -> 300, Contours -> 10, 
   ContourStyle -> None];
GeoGraphics[{GeoStyling[{"GeoImage", plot}, 
   GeoRange -> {{-90, 90}, {-180, 180}}], Opacity[0.8], 
  GeoBoundsRegion["World"]}, GeoRange -> "World", 
 GeoProjection -> "Mercator", 
 GeoBackground -> {"Coastlines", "Land" -> White, "Ocean" -> White, 
   "Border" -> Black}]

And this is the result:

enter image description here

Can you help me? :)

Edit: Over here they used a different kind of function. I can't make my code work with that.

$\endgroup$

marked as duplicate by Vitaliy Kaurov, MarcoB, Henrik Schumacher, Coolwater, José Antonio Díaz Navas May 2 '18 at 8:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ related: GeoListPlot and ListContourPlot $\endgroup$ – kglr May 1 '18 at 22:33
  • $\begingroup$ I tried ListContourPlot with reversed coordinates but I still can't make it work. $\endgroup$ – Rodrigo May 1 '18 at 22:59
  • $\begingroup$ I used that question as a starting point for my code, but I can't make a generic function work with that code. $\endgroup$ – Rodrigo May 2 '18 at 0:05

Browse other questions tagged or ask your own question.