I'm trying to obtain the coordinates of the border of the continents. I need this information to be ordered such that when I do, for example,


It does not yield a messed up image, as happens for disordered points. Initially I was trying by highlighting points on images of maps, and the detecting the points. This approach was really problematic. However, I find that Mathematica has a built in functionality which gives me just what I need, but for countries. That is for example,

CountryData["Iran", "FullCoordinates"][[1]]

I'm exploring if this can be done for continents as entities, and I have found that the information for a continent as a polygon can be obtained as,

africa = Entity["GeographicRegion", "Africa"]["Polygon"]

Is there any way by which I can obtain a list of points corresponding to the coordinates of this continent?


Although ListLinePlot can plot coordinates for geographic data, I recommend that you avoid this method and use GeoGraphics instead. Some of the advantages are:

  • selecting map features, e.g, islands
  • using map projections (with the GeoProjection option)
  • locating points on the map (using GeoMarker)

But first, to answer your question about coordinates, you can get them for the outline of a continent, Africa for example, from its polygon:

continentPoly = Entity["GeographicRegion", "Africa"]["Polygon"];
data = continentPoly[[1, 1, 1]];(*a long list of coordinate pairs*)

There's other useful information available from GeoBounds and GeoBoundingBox.

GeoBounds[Entity["GeographicRegion", "Africa"]]
(* {{-34.8341, 37.5423}, {-25.36, 57.8092}} *)

(* {GeoPosition[{-34.8341, -25.36}], GeoPosition[{37.5423, 57.8092}]} *)

Using GeoGraphics

Let's look at some of the advantages of using GeoGraphics. If you use ListLinePlot, you lose ease-of-use capabilities. For example, here's a map of the continent of Africa including the island of Madagascar.

GeoGraphics[{EdgeForm[Black], FaceForm[None],
    Polygon[GeoPosition[continentPoly[[1, 1, {1,2}]]]]},
  GeoBackground -> None, GeoProjection -> "Mercator"]

Africa map

It's simple to choose the orthographic projection instead of Mercator:

GeoGraphics[{EdgeForm[Black], FaceForm[None],
    Polygon[GeoPosition[continentPoly[[1, 1, {1, 2}]]]]},
  GeoBackground -> None, GeoProjection -> "Orthographic"]

orthographic projection

When you want to highlight a point on the map, GeoMarker does the work for you.

GeoGraphics[{EdgeForm[Black], FaceForm[Red],
    Polygon[GeoPosition[continentPoly[[1, 1, {1, 2}]]]],
  GeoMarker[Entity["City", {"Pretoria", "Gauteng", "SouthAfrica"}]]},
  GeoBackground -> None, GeoProjection -> "Mercator"]

map with a location

Here's a map of several locations with the orthographic projection.

GeoGraphics[{EdgeForm[Black], FaceForm[Orange],
  GeoMarker[Entity["City", {"Pretoria", "Gauteng", "SouthAfrica"}]],
  GeoMarker[Entity["GeographicRegion", "Africa"]["HighestFeature"], "Color" -> Green],
  GeoMarker[Entity["GeographicRegion", "Africa"]["CenterCoordinates"], "Color" -> Blue]},
  GeoBackground -> None, GeoProjection -> "Orthographic"]

several map locations

All of these features would be tricky or difficult to implement with ListLinePlot.

An additional feature unique to GeoGraphics

Another advantage with GeoGraphics is that you can use Get Coordinates to read positions directly from the graphic in a notebook (see the left-hand image). If you click on a point (the small red point on the right-hand image), you can copy and paste the point's geo-position on the map.

get coordinates from notebook graphic

{GeoPosition[{18.293290236969238`, -1.4117877048275167`}, "ITRF00"]}

I'm assuming you want points from the Mercator projection because you're trying to plot in 2D with ListLinePlot? Otherwise you'd be asking for the polygon wrapped on the sphere.

(* get the GeoPosition points from the polygon *)

(* convert to Mercator projection and plot *)
, AspectRatio->1]

Bear in mind Africa has loads of islands, so if you just want the main continent border then you need to select the first set of points:

  , AspectRatio->1, PlotRange->All

enter image description here

  • $\begingroup$ The first plot seems to fit a Mercator projection, but the shape of the second plot is "off" somehow. Is longitude stretched, or latitude compressed? Aspect ratio 1.2 seems to help. $\endgroup$
    – creidhne
    Nov 10 '20 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.