MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: WorldGraphics Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33677] RE: [mg33659] WorldGraphics Question
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Sat, 6 Apr 2002 00:48:53 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: pr0phet73 [mailto:xxxpr0phet73xxx at att.net]
To: mathgroup at smc.vnet.net
> Sent: Friday, April 05, 2002 2:41 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg33677] [mg33659] WorldGraphics Question
> 
> 
> Folks-
> 
> I am trying to use Mathematica to write a small program that 
> will plot up
> the foci of a large number of earthquakes on a world map.  I have been
> working through the examples given in the Add-ons section of the help
> browser on WorldGraphics and have come upon the following problem:
> 
> When I plot up a map of Africa (as per the example in Add-ons):
> afmap = WorldPlot[Africa,
> 
> WorldBackground -> GrayLevel[0.7],
> 
> WorldGrid -> None,
> 
> WorldFrame -> Thickness[.012],
> 
> WorldProjection -> LambertCylindrical]
> 
> 
> I can add a line as in the example:
> 
> {capetown, cairo} = ToMinutes[
> 
> {{{-33, -56}, {18, 22}},
> 
> {{30, 3}, {31, 15}}}]
> 
> 
> 
> Show[{afmap,
> 
> WorldGraphics[
> 
> {Dashing[{0.05, 0.03}],
> 
> Line[{capetown, cairo}]}]}]
> 
> 
> But if I try to plot circles at the points of the two cities:
> 
> Show[{afmap,
> 
> WorldGraphics[
> 
> {Circle[cairo, 500], Circle[capetown, 500]}]}]
> 
> 
> The circles are clearly not located where they should be.  
> Any ideas as to
> what I am missing here?
> 
> 
> --
> M. G. BARTLETT
> Note: Remove x's from email address when replying
> 
> 
> 
> 
> 
> 

M.G.,

the problem with Circle, Disk, etc. is, that the Mathematica graphics
machine converts them directly to Postscript primitives (in sake of beauty
and performance). Such the package WorldPlot cannot transform these
primitives accordingly.

Depending on what you want to achieve, I suggest two different solutions:

(1) If you want to "engrave" the circles on the surface of the earth, and
want to have it transformed according to the current projection, then
generate an corresponding Line or Polygon object:

In[9]:=
orbis[centrum : {latitude_, longitude_}, range_, plotpoints_:50] := 
  Line@Table[
      centrum + range {Sin[a], Cos[a]}, {a, 0, 2\[Pi], N[2
\[Pi]/plotpoints]}]

(* Warning: this is only for illustration purposes and **not** the correct
formula, just a simple approximation for small radii and while keeping far
off the poles. If needed, you certainly can develop a correct form using
spherical trigonometry or better (geoid). I'm just too lazy *)

In[10]:= 
Show[{afmap, 
    WorldGraphics[{{orbis[cairo, 500], orbis[capetown, 500]}, {Hue[0], 
          PointSize[.025], Point[cairo], Point[capetown]}}]}]

You now see your circles centered correctly and distorted according to the
current projection. Compare also with 

In[19]:=
afmap2 = WorldPlot[Africa, WorldProjection -> Mollweide]



(2) Possibly you want your circles (or disks) overlayed onto the map drawn;
such they are always perfect circles not respecting the projection. Then
proceed as such:


In[21]:= Cases[Graphics[
      WorldGraphics[{Point[cairo], Point[capetown]}, WorldGrid -> None, 
        WorldFrame -> None, WorldProjection -> LambertCylindrical]], 
    Point[at_] :> Circle[at, 500], Infinity]

Out[21]= {Circle[{1875, 2704.08}, 500], Circle[{1102, -3014.43}, 500]}

(* See the transformed coordinates! *)

In[22]:= Show[Graphics[afmap], Graphics[%]]


For the Mollweide projection (and perhaps others, I didn't try), we have to
be a bit more clever:

In[38]:=
Show[Graphics[afmap2], 
  Graphics[{Hue[0], Thickness[.01], 
      Cases[Graphics[
          WorldGraphics[{Line[{cairo, cairo + {0, 500}}], 
              Line[{capetown, capetown + {0, 500}}]}, WorldGrid -> None, 
            WorldFrame -> None, WorldProjection -> Mollweide]], 
        Line[{p1_, p2_}] :> Circle[p1, Sqrt[(p2 - p1).(p2 - p1)]], 
        Infinity]}]]


This is because here the projection function scales differently, so we also
have to get the radii from the projection.


--
Hartmut Wolf



  • Prev by Date: Re: binomial distribution
  • Next by Date: RE: Beginner question on local vars./scoping
  • Previous by thread: WorldGraphics Question
  • Next by thread: Fun .sig