# How to plot coordinates with different colors on a map?

How can I plot different sets of coordinates with different colors? For example, the two maps below would be merged into one map, with two colors.
I'm using the commands below to create the maps below - the coordinates are comma-separated and stored in input files.

latlong = Import["cluster0.txt", "CSV"];

Graphics[{Gray,  Polygon[Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, CountryData["United States", "Coordinates"], {2}]], Red,  PointSize[.01], Point /@ Map[ GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, {latlong}, {2}]}]

latlong2 = Import["cluster2.txt", "CSV"];

Graphics[{Gray,  Polygon[Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, CountryData["United States", "Coordinates"], {2}]], Green,  PointSize[.01], Point /@ Map[ GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, {latlong2}, {2}]}]


(Update:) I am using Mathematica version 8 so I would prefer solutions that work with this version.

• Please show the code you have so far. Commented Mar 31, 2016 at 20:14
• Do you have geo coordinates for points? Commented Mar 31, 2016 at 20:24
• I have edited my question with the commands that I used. I have a lot of coordinates and they are stored in input files. Commented Mar 31, 2016 at 20:50
• So you just add Green, PointSize[.01], Point /@... to your first Graphics call, see my answer below. Commented Mar 31, 2016 at 20:53

continentalcities = CityData[{Large, "UnitedStates"}] /. {_, "Alaska" | "Hawaii", _} :>
Sequence[];
coords = Map[GeoGridPosition[GeoPosition[#],
"Mercator"][[1]]&, {CityData[#, "Coordinates"] & /@ continentalcities}, {2}];
ColorData["GeologicAges", "ColorList"][[;; 51]]];
coordsandcolors = Transpose[{coords[[1]], continentalcities,
continentalcities[[All, 2]] /. statestocolors}];

Graphics[{Gray, Polygon[Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &,
CountryData["UnitedStates", "Coordinates"], {2}]],
PointSize[.01], {#3, Tooltip[Point[#1], #2]} & @@@ coordsandcolors}]


For your datasets latlong and latlong2, as noted by @BlacKow already, you can use

Graphics[{Gray, Polygon[Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &,
CountryData["United States", "Coordinates"], {2}]], PointSize[.01],
Green, Point /@ Map[GeoGridPosition[GeoPosition[#],
"Mercator"][[1]] &, {latlong2}, {2}],
Red, Point /@ Map[GeoGridPosition[GeoPosition[#],
"Mercator"][[1]] &, {latlong}, {2}]}]

• It worked fantastic!!! Commented Mar 31, 2016 at 21:06
• @kglr nice sample data :) Commented Mar 31, 2016 at 21:16
• Now it's even better! Is it Friday already? Commented Mar 31, 2016 at 21:25
• thank you @BlacKow. Scrolled the page too fast to notice that you already answered Thiago's specific question:)
– kglr
Commented Mar 31, 2016 at 21:25
set1 = {{38.9, -77.03}, {38.9, -87.03}};
set2 =  {{36.9, -77.03}, {33.9, -87.03}};

Graphics[#, AspectRatio -> 0.65] &@{Gray,CountryData["USA", "Polygon"], Pink, PointSize[0.01],
Point[GeoPosition[set1]], Green, Point[GeoPosition[set2]]}


I'm not sure about aspect ratio... I cannot check MMA 8.0, but this should work for you

Graphics[{Gray,
Polygon[Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &,
CountryData["United States", "Coordinates"], {2}]], Green,
PointSize[.01],
Point /@ Map[
GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, {set2}, {2}],
Pink, Point /@
Map[GeoGridPosition[GeoPosition[#],
"Mercator"][[1]] &, {set1}, {2}]}]


Or the following will probably work too:

Graphics[#, AspectRatio -> 0.65] &@{Gray,
CountryData["USA", "Polygon"], Pink, PointSize[0.01],
Point[GeoPosition /@ set1], Green, Point[GeoPosition /@ set2]}

• I'm using Mathematica 8 and your command is returning this error: Coordinate GeoPosition[{{38.9, -77.03}, {38.9, -87.03}}] should be a pair of numbers, or a Scaled or Offset form. Commented Mar 31, 2016 at 20:59
• I updated the answer. Commented Mar 31, 2016 at 21:03
• Your 2nd command works fine on Mathematica 8, but the last code snippet doesn't work. Thank you. Commented Apr 1, 2016 at 12:50