Message Boards Message Boards

Generate Map from list of Name, Latitude, Longitude?

Posted 8 years ago

I'm really having fun playing with Mathematica's GeoListPlot however I'd like to see if there's a way to display a name next to the plot points.

I have a spreadsheet I can save as a CSV like the following:

Name, Lat, Long
Fred, 40, -80
Sally, 3, -40

I see that I can do the following:

GeoListPlot[{GeoPosition[{40, -80}]}, GeoLabels -> True]

But I can't get "Fred" up next to his location. Just display the points.

Once I figure out how to get the name displayed at the location, I'll try loading the who list in and do the GeoListPlot on the whole thing.

Any ideas? (THANKS!)

POSTED BY: Daren Eilert
7 Replies

Perhaps GeoDistance (or related functions) is what you need.

POSTED BY: Gianluca Gorni

You can use GeoPath do draw a line:

GeoGraphics[
 Apply[{Point[GeoPosition[{#3, #4}]], 
    Text[#1, GeoPosition[{#3, #4}], {-1, -1}], 
    Point[GeoPosition[{#5, #6}]], 
    Text[#2, GeoPosition[{#5, #6}], {-1, -1}], 
    GeoPath[{{#3, #4}, {#5, #6}}]} &, Rest@data, 1]]
POSTED BY: Gianluca Gorni
Posted 8 years ago

Totally sweet! I love the Geo functions!

Next objective would be to compute the A+B+C path totals for each path.

POSTED BY: Daren Eilert
Posted 8 years ago

Wow cool - didn't know about GeoGraphics. I may have had a point or two off on my data. I'll fix here:

data = {{"aname", "bname", "alat", "along", "blat", "blong"}, {"Fred",
     "Linda", 41.749942`, -74.0797377`, 42.0752`, 
    -73.585556`}, {"Linda", "Joanne", 42.0752`, -73.585556`, 
    42.6743`, -73.77783`}, {"Rich", "Sue", 41.6946`, -73.9799`, 
    41.9959`, -73.8769`}, {"Sue", "Al", 41.9959`, -73.8769`, 
    42.2519`, -73.786`}};
GeoGraphics[
 Apply[{Point[GeoPosition[{#3, #4}]], 
    Text[#1, GeoPosition[{#3, #4}], {-1, -1}]} &, Rest@data, 1]]

So you're plotting the third and forth points in the data and using that text. How would I plot the first site (#3/#4) and the second site(#5&#6) and draw a line between them - AND label each site. Can I just break this code into multiple lines and recursively go through the data?

POSTED BY: Daren Eilert

I would try GeoGraphics:

data = {{"aname", "bname", "alat", "along", "blat", "blong"}, {"Fred",
     "Linda", 41.749942`, -74.0797377`, 42.0752`, 
    33.585556`}, {"Linda", "Joanne", 42.0752`, 33.585556`, 
    42.6743`, -73.77783`}, {"Rich", "Sue", 41.6946`, -73.9799`, 
    41.9959`, -73.8769`}, {"Sue", "Al", 41.9959`, -73.8769`, 
    42.2519`, -73.786`}};
GeoGraphics[
 Apply[{Point[GeoPosition[{#3, #4}]], 
    Text[#1, GeoPosition[{#3, #4}], {-1, -1}]} &, Rest@data, 1]]
POSTED BY: Gianluca Gorni
Posted 8 years ago

Sure,

Here's an attached set. I'm really trying to plot (and join) multiple cities together - but leverage their names as well. Point A to Point B.

Attachments:
POSTED BY: Daren Eilert

Can you edit your post and attach the .CSV file?

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract