0

A duplicate question, but in MMA12, it have some bugs.

latlong = {{32.6123, -117.041}, {40.6973, -111.9}, {34.0276, \
-118.046}, {40.8231, -111.986}, {34.0446, -117.94}, {33.7389, \
-118.024}, {34.122, -118.088}, {37.3881, -122.252}, {44.9325, \
-122.966}, {32.6029, -117.154}, {44.7165, -123.062}, {37.8475, \
-122.47}, {32.6833, -117.098}, {44.4881, -122.797}, {37.5687, \
-122.254}, {45.1645, -122.788}, {47.6077, -122.692}, {44.5727, \
-122.65}, {42.3155, -82.9408}, {42.6438, -73.6451}, {48.0426, \
-122.092}, {48.5371, -122.09}, {45.4599, -122.618}, {48.4816, \
-122.659}, {42.3398, -70.9843}};
Map[GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &, {latlong}, {2}]
mercPoints = toMercator /@ latLngs;
(*Plot*)
Show[CountryData["UnitedStates", {"Shape", "Mercator"}], 
 Frame -> True, Epilog -> {PointSize[0.01], Red, Point[mercPoints]}]

We can get Mercator points,

Show[CountryData["UnitedStates",{"Shape", "Mercator"}],
  Frame-> True, Epilog ->{PointSize[0.01], Red,
  Point[mercPoints]}]

But above code can't run, MMA 12 says Show: Symbol is not a type of graphics.

ListPlot[mercPoints] can works, so the point is well.

Any comments very be much appreciate!

lumw
  • 593
  • 2
  • 8
  • Please define mercPoints. – Syed Nov 26 '21 at 05:47
  • Sorry, I forget copy this definition, now I have revised. – lumw Nov 26 '21 at 05:51
  • mercPoints = toMercator /@ latLngs; ?? Please make this a self-contained copy-paste-able example, i.e., a minimal working example that replicates your problem. – Syed Nov 26 '21 at 06:08
  • I find problem maybe cause by CountryData["UnitedStates", {"Shape", "Mercator"}], now i'am reading the document of CountryData – lumw Nov 26 '21 at 06:14

1 Answers1

2

Use GeoGraphics to do it the easy way:

$Version
GeoGraphics[
 GeoMarker[latlong, Graphics[{Red, PointSize[0.2], Point[{0, 0}]}]],
 GeoBackground -> "CountryBorders",
 GeoProjection -> "Mercator", Frame -> True]

(* "12.1.0 for Linux x86 (64-bit) (March 14, 2020)" *)

enter image description here

And if you want to calculate the grid coordinates, use

mercPoints = 
  GeoGridPosition[GeoPosition[#], "Mercator"][[1]] &   /@ latlong;

Show[{CountryData["UnitedStates", {"Shape", "Mercator"}], Graphics[{Red, PointSize[0.0125], Point[mercPoints]}]}, Frame -> True]

enter image description here

The first (easy) method is basically the same as this answer with a different background. The second (calculation) method is an update of this one.

LouisB
  • 12,528
  • 1
  • 21
  • 31