The task is to draw a line parallel to the coast 150 nautical miles to the sea, highlighting the ocean between the coast and the line drawn.

An expected result is an image (most aesthetically pleasing) together with the Mathematica code. There is no restriction and no initial condition given. You are free to use any valid world map.

The only highlighted zones must be part of seas or oceans. The highlighting must be consistent, for example, the entire Black sea should be highlighted as there is no point distancing more than 150 nautical miles to the nearest coast.

  • $\begingroup$ Yes. I was wondering if there is some more or less easy Mathematica code to visualize this task. $\endgroup$ – Aurelius Jun 30 '20 at 8:59
  • 3
    $\begingroup$ This is not a question - it's just a task. I'll vote to re-open when this becomes a real question with some code attempt and a rough image of the desired result. $\endgroup$ – flinty Jun 30 '20 at 22:28
  • 2
    $\begingroup$ @flinty I think the question is clear as I edited with all necessary details and some users already understood what is needed and found it interesting. I don't understand why my question is not "real" and why I NEED to provide some code attempt as that's is exactly what my question is about. For a rough image I can do it in Photoshop. This question is specific how to do it with Mathematica. ANY reasonable world map output would be an answer. $\endgroup$ – Aurelius Jun 30 '20 at 23:02
  • 2
    $\begingroup$ @flinty While we encourage users to show what they have tried the lack of an attempt is by itself not a reason for closing a question. Showing work is not possible for all types of questions. The primary reason to ask someone to show their work is when you suspect OP has been able to do part of the problem themselves (perhaps OP has even suggested as much in the question) and knowing where OP got stuck would help write a better answer. $\endgroup$ – C. E. Jul 1 '20 at 8:41
  • 2
    $\begingroup$ @C.E. I mostly side with flinty here. There is no example provided. So any attempt at this means one must bring up some geographic location map and work on it, with the possibility of being told "Nope, sorry, wrong format" or some such. Without a concrete example this is more of a challenge than it ought to be. (I do understand that it is sometimes not realistic to expect explicit code in the question.) $\endgroup$ – Daniel Lichtblau Jul 1 '20 at 13:42

Here is a starting point, but it does not work that well and there may be insurmountable problems with my approach.

coastlineResize[pol_, dist_] := Module[{
   coastlinepoints = GeoPosition /@ pol[[1, 1, 1]]},
     Map[GeoDestination[#, {dist, 
         GeoDirection[RegionCentroid@pol, #]}] &, coastlinepoints]}]]

And we can use it like so:

coastlineResize[Entity["Country", "Nauru"]["Polygon"], 
 Quantity[1, "NauticalMiles"]]

enter image description here

This looks approximately correct to me. The key part of the code is the following:

Map[GeoDestination[#, {dist, 
         GeoDirection[RegionCentroid@pol, #]}] &, coastlinepoints]

We are mapping over each of the coastline points, and moving each point, using GeoDestination by dist in the direction from the centre of the polygon (RegionCentroid@pol).

You'll notice I picked Nauru - that's because this is both very small and also the most circular island. There's an inherent issue with this method that going from the centre of the polygon does not work very well - instead, you should try and go from a right angle away from every pair of points. Also, finding the coastline of a polygon is actually somewhat difficult, so there is room for improvement there.

  • 2
    $\begingroup$ Thank you! This looks great, you helped a lot, I will try to go from here. $\endgroup$ – Aurelius Jul 1 '20 at 23:25

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.