f



mapping dots to a map image

I have three files. One is a data file which contains three columns, a
datum, a X axis (latitude), and a Y axis (longitude). It essentially
represents the number of individuals meeting particular criteria that
reside in specific locations. The second is a GIF with a dot plot
created using GD::Graph, using the data in the first file. The third
is a B & W GIF which is a map of the United States.

I would like to overlay the dot plot with the map to give a graphical
representation of the number of people on a particular location. My
problem seems to be one of projection -- I can manipulate the latitude
and longitude to correlate to the X and Y position of the pixels on
the map for regions, but not for the entire map, i.e., if the dot plot
overlays Washington D.C. perfectly, San Francisco appears in Nevada,
and if I center the map on Chicago, Miami appears in the Gulf of
Mexico. So far, I've used several different maps, and none of them
consistently show the same locations (on the map) for the coordinates.

I'm stuck at adjusting the dot plot file and the map, and I'm thinking
that I probably need an 'intelligent' map that can place the dots
where they belong. Is there a Perl solution to this problem? Or maybe
I'm looking for the wrong solution.

Thanks, CC.
0
ccc31807
9/14/2010 6:49:17 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

2 Replies
571 Views

Similar Articles

[PageSpeed] 52

ccc31807 wrote:
) I have three files. One is a data file which contains three columns, a
) datum, a X axis (latitude), and a Y axis (longitude). It essentially
) represents the number of individuals meeting particular criteria that
) reside in specific locations. The second is a GIF with a dot plot
) created using GD::Graph, using the data in the first file. The third
) is a B & W GIF which is a map of the United States.
)
) I would like to overlay the dot plot with the map to give a graphical
) representation of the number of people on a particular location. My
) problem seems to be one of projection -- I can manipulate the latitude
) and longitude to correlate to the X and Y position of the pixels on
) the map for regions, but not for the entire map, i.e., if the dot plot
) overlays Washington D.C. perfectly, San Francisco appears in Nevada,
) and if I center the map on Chicago, Miami appears in the Gulf of
) Mexico. So far, I've used several different maps, and none of them
) consistently show the same locations (on the map) for the coordinates.
)
) I'm stuck at adjusting the dot plot file and the map, and I'm thinking
) that I probably need an 'intelligent' map that can place the dots
) where they belong. Is there a Perl solution to this problem? Or maybe
) I'm looking for the wrong solution.

You should be looking for a description of the projection that is used to
create the map you have, and more precisely how that would translate to a
mapping function between lat-long coordinates and xy coordinates on the
map.

There's probably, depending on the specific projection used, a more or less
simple mathematical formula to translate.  Simply convert that to a perl
function and you're basically done.

After googling for a tiny bit, it appears I was overly optimistic on the
simpleness of the function. The wikipedia entry on the mercator projection
(which was the first hit) gives
x = longitude and y = ln(tan(pi/4 + latitude/2))


Unfortunately, usanian maps of the usa tend to have more complicated
projections so as to maximize the apparent size of the usa in relation to
other places, so it's probably a more complicated formula for that map.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
0
Willem
9/14/2010 7:09:57 PM
On 2010-09-14, Willem <willem@turtle.stack.nl> wrote:
> ) I'm stuck at adjusting the dot plot file and the map, and I'm thinking
> ) that I probably need an 'intelligent' map that can place the dots
> ) where they belong. Is there a Perl solution to this problem? Or maybe
> ) I'm looking for the wrong solution.
>
> You should be looking for a description of the projection that is used to
> create the map you have, and more precisely how that would translate to a
> mapping function between lat-long coordinates and xy coordinates on the
> map.
>
> There's probably, depending on the specific projection used, a more or less
> simple mathematical formula to translate.  Simply convert that to a perl
> function and you're basically done.

Won't work with the most useful projections.  They have PARAMETERS
which are very rarely documented on the map.

I would recommend finding a Mercator map, and deal with it; it looks
horrible, but at least it has only scale as the parameter.  Then

 Heigth = f(Lattitude), Width = const * Longitude * const,

Oh, I see, it is documented below:

> x = longitude and y = ln(tan(pi/4 + latitude/2))

- up to two additive constants [shift], and one multiplicative
  [scale], which are easy to find if you know coordinates of two
  points on the map.

Hope this helps,
Ilya
0
Ilya
9/14/2010 11:37:35 PM
Reply: