MathGroup Archive 2000

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

Search the Archive

Re: Transforming coordinates in ListContourPlot?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21698] Re: [mg21656] Transforming coordinates in ListContourPlot?
  • From: Hartmut Wolf <hwolf at debis.com>
  • Date: Sat, 22 Jan 2000 02:53:06 -0500 (EST)
  • Organization: debis Systemhaus
  • References: <200001210900.EAA06473@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Sigurd Tjelmeland schrieb:
> 
> ListContourPlot takes a rectangular array of
> values as input. I have a rectangular array
> of (fish) densities in minutes latitude and
> minutes longitude, but want to make contour
> plots in the Mercator projection. Can this be
> done???
> 


Dear Sigurd,

as you are lucky to have your original date in Minutes, let's assume
they are something like this

lcp2 = ListContourPlot[
    Table[(x + 1500)^2 + (y - 2250)^2 + 
           10^6*Random[Real, {-0.2, 0.2}], 
           {y, 900, 3600, 100}, {x, -3000, -600, 100}], 
    Contours -> 6, ContourShading -> False, 
    ContourStyle -> Hue[0.65, 1., 0.6], 
    MeshRange -> {{-3000, -600}, {900, 3600}}]

-ContourGraphics-

Then convert this object to a normal graphics object (the contours are
now given by ordinary Line primitives and the option MeshRange makes
that the {x,y} coordinates are retained in there original scale (i.e.
Minutes) *that is essential*):

lcpg2 = Graphics[lcp2]

-Graphics-

Now we do something special, we reverse the x-y pairs, why? ...

lcpg3 = lcpg2 /. Line[pts_] :> Line[Reverse /@ pts]

...to comply with the standards of the WorldPlot package

<< Miscellaneous`WorldPlot`

We can plot the North Atlantic in Mercator projection (or others as we
like):

na = WorldPlot[{World, GrayLevel[0.5] &}, 
       WorldRange -> {{-10, 80}, {-90, 30}}, 
       WorldProjection -> Mercator]

-WorldGraphics-

And we combine the manipulated -Graphics- (from the contour plot) with
the -WorldGraphics- 

comb = MapAt[Join[lcpg3[[1]], #] &, na, {1}]

-WorldGraphics-

and show:

Show[comb]

-WorldGraphics-

Now you see your contour lines (in blue here) superimposed to the map of
the North Atlantic and if you look close you can see that the
coordinates are correctly transformed according to the Mercator
projection (and no fish in the Sahara).

(* If you want to retain contour shading, then you have to also tranform
the polygons 

lcpg = Graphics[ListContourPlot[
     Table[(x + 1500)^2 + (y - 2250)^2 + 
        10^6*Random[Real, {-0.2, 0.2}], 
       {y, 900, 3600, 100}, {x, -3000, -600, 100}], 
     Contours -> 6, 
     ColorFunction -> (Hue[0.65, 1. - #1, 1.] & ), 
     MeshRange -> {{-3000, -600}, {900, 3600}}, 
     DisplayFunction -> Identity]] 
     /. {Line[pts_] :> Line[Reverse /@ pts], 
         Polygon[pts_] :> Polygon[Reverse /@ pts]}

and then, as not to let the Latitudes and Longitudes be extinct by the
shaded contours, superimpose then again with the Atlantic, but that only
works if everything is converted to ordinary graphics before

combg = Graphics[MapAt[Join[lcpg[[1]], #] &, na, {1}]]
nag = Graphics[na]
Show[combg, nag]  *)


Kind regards, Hartmut


  • Prev by Date: Re: Corrupted notebook
  • Next by Date: RE: Help! Mathematica on my 500MHz outperforms my GHz machine!
  • Previous by thread: Transforming coordinates in ListContourPlot?
  • Next by thread: Re: Transforming coordinates in ListContourPlot?