How can bays and straits be determined in a procedurally generated map? Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Huge procedurally generated 'wilderness' worldsProcedurally generated terrain map. Blend Transitions between terrain typesHow can I identify feature regions in a procedurally generated world?Algorithms for rainfall + river creation in procedurally generated terrainLegality, implementation, and viability of using the BSP map format in a procedurally generated XNA game?How can I generate random maps that feel like Age of Empires II random maps?Procedurally Generated Top View 2D RPG Map GenerationHow to display procedurally created rooms as a schematic map?Procedurally generated paths with intersectionsProcedurally-generated 2D curved roads on map

Given a circle and line equations what are all possible solutions for k where the line sits tangent to the circle?

List of Python versions

An adverb for when you're not exaggerating

How do pianists reach extremely loud dynamics?

How can I make names more distinctive without making them longer?

Why is "Consequences inflicted." not a sentence?

Do square wave exist?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

How does debian/ubuntu knows a package has a updated version

How to remove list items depending on predecessor in python

Gordon Ramsay Pudding Recipe

Where is the concept of Prapatti/Saranagati mentioned in the mukhya upanishads, as per the Sri Vaishnava interpretation?

Generate an RGB colour grid

Using et al. for a last / senior author rather than for a first author

Can a non-EU citizen with residency visa traveling with me come with me through the EU passport line, when entering Schengen area?

When were vectors invented?

Delete nth line from bottom

Why are the trig functions versine, haversine, exsecant, etc, seldom utilized in present society?

Seeking colloquialism for “just because”

Extract all GPU name, model and GPU ram

Fundamental Solution of the Pell Equation

Deactivate Gutenberg tips forever - not Gutenberg

How to draw a nice diagonal matrix?

How to find out what spells would be useless to a blind NPC spellcaster?



How can bays and straits be determined in a procedurally generated map?



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Huge procedurally generated 'wilderness' worldsProcedurally generated terrain map. Blend Transitions between terrain typesHow can I identify feature regions in a procedurally generated world?Algorithms for rainfall + river creation in procedurally generated terrainLegality, implementation, and viability of using the BSP map format in a procedurally generated XNA game?How can I generate random maps that feel like Age of Empires II random maps?Procedurally Generated Top View 2D RPG Map GenerationHow to display procedurally created rooms as a schematic map?Procedurally generated paths with intersectionsProcedurally-generated 2D curved roads on map



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








42












$begingroup$


I've got a procedurally generated map using Voronoi cells, with a defined sea level and a believable height map.



Current



So far, I've been successful in labelling certain geographic features: land, ocean, lakes, rivers, estuaries, confluences, mountains, and biomes. Biomes include tundra, boreal forest, grassland, and temperate forest. There are also a couple other biomes there but for my purposes they aren't important right now.



I'd like to label bays, and straits next, but I'm at a loss on how to do this properly. A bay is a recessed, coastal body of water that directly connects to the ocean.



A strait is a naturally formed, narrow waterway that connects two parts of the ocean. Basically, where two pieces of land almost touch and there's ocean on both sides. Also called a "channel".



For determining features, I can loop through any feature by type like this:



for each (var feature:Object in geography.getFeaturesByType(Geography.LAND))
// loop through lands
for each (var cell:Cell in feature.cells)
// loop through cells
for each (var neighbor:Cell in cell.neighbors)
// loop through a cell's neighbors
trace(neighbor.hasFeatureType(Geography.LAND));









share|improve this question











$endgroup$







  • 7




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    Apr 5 at 15:53






  • 1




    $begingroup$
    @Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
    $endgroup$
    – Philipp
    Apr 8 at 8:15










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    Apr 8 at 10:26

















42












$begingroup$


I've got a procedurally generated map using Voronoi cells, with a defined sea level and a believable height map.



Current



So far, I've been successful in labelling certain geographic features: land, ocean, lakes, rivers, estuaries, confluences, mountains, and biomes. Biomes include tundra, boreal forest, grassland, and temperate forest. There are also a couple other biomes there but for my purposes they aren't important right now.



I'd like to label bays, and straits next, but I'm at a loss on how to do this properly. A bay is a recessed, coastal body of water that directly connects to the ocean.



A strait is a naturally formed, narrow waterway that connects two parts of the ocean. Basically, where two pieces of land almost touch and there's ocean on both sides. Also called a "channel".



For determining features, I can loop through any feature by type like this:



for each (var feature:Object in geography.getFeaturesByType(Geography.LAND))
// loop through lands
for each (var cell:Cell in feature.cells)
// loop through cells
for each (var neighbor:Cell in cell.neighbors)
// loop through a cell's neighbors
trace(neighbor.hasFeatureType(Geography.LAND));









share|improve this question











$endgroup$







  • 7




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    Apr 5 at 15:53






  • 1




    $begingroup$
    @Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
    $endgroup$
    – Philipp
    Apr 8 at 8:15










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    Apr 8 at 10:26













42












42








42


19



$begingroup$


I've got a procedurally generated map using Voronoi cells, with a defined sea level and a believable height map.



Current



So far, I've been successful in labelling certain geographic features: land, ocean, lakes, rivers, estuaries, confluences, mountains, and biomes. Biomes include tundra, boreal forest, grassland, and temperate forest. There are also a couple other biomes there but for my purposes they aren't important right now.



I'd like to label bays, and straits next, but I'm at a loss on how to do this properly. A bay is a recessed, coastal body of water that directly connects to the ocean.



A strait is a naturally formed, narrow waterway that connects two parts of the ocean. Basically, where two pieces of land almost touch and there's ocean on both sides. Also called a "channel".



For determining features, I can loop through any feature by type like this:



for each (var feature:Object in geography.getFeaturesByType(Geography.LAND))
// loop through lands
for each (var cell:Cell in feature.cells)
// loop through cells
for each (var neighbor:Cell in cell.neighbors)
// loop through a cell's neighbors
trace(neighbor.hasFeatureType(Geography.LAND));









share|improve this question











$endgroup$




I've got a procedurally generated map using Voronoi cells, with a defined sea level and a believable height map.



Current



So far, I've been successful in labelling certain geographic features: land, ocean, lakes, rivers, estuaries, confluences, mountains, and biomes. Biomes include tundra, boreal forest, grassland, and temperate forest. There are also a couple other biomes there but for my purposes they aren't important right now.



I'd like to label bays, and straits next, but I'm at a loss on how to do this properly. A bay is a recessed, coastal body of water that directly connects to the ocean.



A strait is a naturally formed, narrow waterway that connects two parts of the ocean. Basically, where two pieces of land almost touch and there's ocean on both sides. Also called a "channel".



For determining features, I can loop through any feature by type like this:



for each (var feature:Object in geography.getFeaturesByType(Geography.LAND))
// loop through lands
for each (var cell:Cell in feature.cells)
// loop through cells
for each (var neighbor:Cell in cell.neighbors)
// loop through a cell's neighbors
trace(neighbor.hasFeatureType(Geography.LAND));






procedural-generation maps graphics-programming simulations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 5 at 10:21







Olin Kirkland

















asked Apr 5 at 7:02









Olin KirklandOlin Kirkland

32238




32238







  • 7




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    Apr 5 at 15:53






  • 1




    $begingroup$
    @Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
    $endgroup$
    – Philipp
    Apr 8 at 8:15










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    Apr 8 at 10:26












  • 7




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    Apr 5 at 15:53






  • 1




    $begingroup$
    @Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
    $endgroup$
    – Philipp
    Apr 8 at 8:15










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    Apr 8 at 10:26







7




7




$begingroup$
I recommend a baysian classifier.
$endgroup$
– Acccumulation
Apr 5 at 15:53




$begingroup$
I recommend a baysian classifier.
$endgroup$
– Acccumulation
Apr 5 at 15:53




1




1




$begingroup$
@Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
$endgroup$
– Philipp
Apr 8 at 8:15




$begingroup$
@Acccumulation Is this a pun on "bay" or is this a serious suggestion? If the latter, you should write a proper answer about this.
$endgroup$
– Philipp
Apr 8 at 8:15












$begingroup$
I'm like 99% sure he's making a joke.
$endgroup$
– Olin Kirkland
Apr 8 at 10:26




$begingroup$
I'm like 99% sure he's making a joke.
$endgroup$
– Olin Kirkland
Apr 8 at 10:26










3 Answers
3






active

oldest

votes


















29












$begingroup$

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance between the spots you can identify narrow deep bays, wide shallow bays, etc.



In this picture, the red and purple dots show the two candidate points and the green line is the coastline between the points. The sinuosity is the ratio of those two lengths:



Example of a Bay



Alternatively, you can select two points on the coast and create a polygon by connecting the two points and the coastline between the two points (i.e., connect the green line above from red dot to purple dot). Measure the area of this polygon. A bay will have a larger area than a non-bay.



In my experience, a combination of these two measures was best for reliably identifying what people see as bays.



Note that this will also detect points. To find only bays, you need to check that the "inside" of the bay contains water and not land. A quick and easy way to do this is to check the midpoint of the line between the two points to see if it is water. (This can be fooled but is generally sufficient.)



A related problem is to identify the "mouth" of the bay -- i.e., the best choice for the two points that mark the opening to the bay. Typically you'll have a bunch of candidates for the "mouth". In the example map above, you could put the mouth of that bay further in or further out. Generally speaking it probably doesn't matter too much, but one heuristic that works reasonably well is to minimize the straight-line distance across the mouth.



I haven't done straits yet, but my intuition is to check points along the coastline to find the closest point on any other coastline; if that is under some set limit it is a strait.






share|improve this answer









$endgroup$








  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    Apr 6 at 6:21


















49












$begingroup$

Here's a rough idea using image processing transformations to isolate the features of interest:




  1. Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;)



    Ocean Mask




  2. Apply a local smoothing to the edge of this mask, keeping the connectedness/topology the same, but smoothing out small noisy coastline features that can be distracting. This lets us focus on big bays over tiny inlets. You can use the width of your filter kernal / number of iterations to finely control the scale of features you preserve.



    Here I applied a median filter a few times. Cellular automata are another popular way to erode smooth shapes from a noisy input.



    Smoothed Coastline




  3. Turn the mask into a distance field, where each cell stores its distance from the smoothed coastline.



    Distance Field



Now we see some promising feature highlights. In a signed distance field, both bays and straits show up as sharp ridges, with distance falling off to the sides. We can use an edge detection filter to pop out these ridges:



Ridges Highlighted



You can then distinguish between bays and straits by following the ridge to determine its connectivity. A bay is a ridge that runs toward the coast, getting shallower and shallower (in distance from land) until it ends in a point. A strait is a ridge that connects a high-distance region to another high-distance region, going through a lower-distance region along the way.



Or, another way is to assign each island an ID (connected component search), then when you're making your distance field, propagate "closest island ID" alongside the distance frontier. A bay or inlet is then a ridge in water adjacent to the same landmass on both sides, while a channel is a ridge that separates water adjacent to two different landmasses.



You can set minimum & maximum distance-to-shore or length-of-ridge constraints to control which features to label, if you need to exclude excessively narrow/wide straits for instance.






share|improve this answer











$endgroup$








  • 9




    $begingroup$
    This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
    $endgroup$
    – Quentin
    Apr 5 at 13:56






  • 7




    $begingroup$
    The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
    $endgroup$
    – Monty Harder
    Apr 5 at 14:42










  • $begingroup$
    The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
    $endgroup$
    – MSalters
    Apr 8 at 11:26


















6












$begingroup$

Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions:



Bay



  • Any ocean cell that only connects to a single other ocean cell

  • OR: Any ocean cell that connects to more land than ocean cells, with all ocean cells next to each other

  • OR: Same as above, but with a criterion based on border length (e.g. twice as much land as water border)

Strait



  • Any ocean cell that connects to exactly two ocean cells which are not next to each other

  • OR: Any ocean cell that connects to two land cells that don't belong to the same landmass (you need to find out which land cells are connected first, and assign IDs to each landmass)

  • OR: March around the border, and count land/water and water/land transitions. You need at least two of each.

  • Depending on your method and what you want to do with the categories, you might want to eliminate straits that only lead to a bay, or label them as bay instead.





share|improve this answer











$endgroup$








  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    Apr 5 at 15:20







  • 1




    $begingroup$
    If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
    $endgroup$
    – DMGregory
    Apr 5 at 17:02










  • $begingroup$
    Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
    $endgroup$
    – TheLuckless
    Apr 5 at 17:23











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "53"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgamedev.stackexchange.com%2fquestions%2f169723%2fhow-can-bays-and-straits-be-determined-in-a-procedurally-generated-map%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









29












$begingroup$

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance between the spots you can identify narrow deep bays, wide shallow bays, etc.



In this picture, the red and purple dots show the two candidate points and the green line is the coastline between the points. The sinuosity is the ratio of those two lengths:



Example of a Bay



Alternatively, you can select two points on the coast and create a polygon by connecting the two points and the coastline between the two points (i.e., connect the green line above from red dot to purple dot). Measure the area of this polygon. A bay will have a larger area than a non-bay.



In my experience, a combination of these two measures was best for reliably identifying what people see as bays.



Note that this will also detect points. To find only bays, you need to check that the "inside" of the bay contains water and not land. A quick and easy way to do this is to check the midpoint of the line between the two points to see if it is water. (This can be fooled but is generally sufficient.)



A related problem is to identify the "mouth" of the bay -- i.e., the best choice for the two points that mark the opening to the bay. Typically you'll have a bunch of candidates for the "mouth". In the example map above, you could put the mouth of that bay further in or further out. Generally speaking it probably doesn't matter too much, but one heuristic that works reasonably well is to minimize the straight-line distance across the mouth.



I haven't done straits yet, but my intuition is to check points along the coastline to find the closest point on any other coastline; if that is under some set limit it is a strait.






share|improve this answer









$endgroup$








  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    Apr 6 at 6:21















29












$begingroup$

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance between the spots you can identify narrow deep bays, wide shallow bays, etc.



In this picture, the red and purple dots show the two candidate points and the green line is the coastline between the points. The sinuosity is the ratio of those two lengths:



Example of a Bay



Alternatively, you can select two points on the coast and create a polygon by connecting the two points and the coastline between the two points (i.e., connect the green line above from red dot to purple dot). Measure the area of this polygon. A bay will have a larger area than a non-bay.



In my experience, a combination of these two measures was best for reliably identifying what people see as bays.



Note that this will also detect points. To find only bays, you need to check that the "inside" of the bay contains water and not land. A quick and easy way to do this is to check the midpoint of the line between the two points to see if it is water. (This can be fooled but is generally sufficient.)



A related problem is to identify the "mouth" of the bay -- i.e., the best choice for the two points that mark the opening to the bay. Typically you'll have a bunch of candidates for the "mouth". In the example map above, you could put the mouth of that bay further in or further out. Generally speaking it probably doesn't matter too much, but one heuristic that works reasonably well is to minimize the straight-line distance across the mouth.



I haven't done straits yet, but my intuition is to check points along the coastline to find the closest point on any other coastline; if that is under some set limit it is a strait.






share|improve this answer









$endgroup$








  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    Apr 6 at 6:21













29












29








29





$begingroup$

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance between the spots you can identify narrow deep bays, wide shallow bays, etc.



In this picture, the red and purple dots show the two candidate points and the green line is the coastline between the points. The sinuosity is the ratio of those two lengths:



Example of a Bay



Alternatively, you can select two points on the coast and create a polygon by connecting the two points and the coastline between the two points (i.e., connect the green line above from red dot to purple dot). Measure the area of this polygon. A bay will have a larger area than a non-bay.



In my experience, a combination of these two measures was best for reliably identifying what people see as bays.



Note that this will also detect points. To find only bays, you need to check that the "inside" of the bay contains water and not land. A quick and easy way to do this is to check the midpoint of the line between the two points to see if it is water. (This can be fooled but is generally sufficient.)



A related problem is to identify the "mouth" of the bay -- i.e., the best choice for the two points that mark the opening to the bay. Typically you'll have a bunch of candidates for the "mouth". In the example map above, you could put the mouth of that bay further in or further out. Generally speaking it probably doesn't matter too much, but one heuristic that works reasonably well is to minimize the straight-line distance across the mouth.



I haven't done straits yet, but my intuition is to check points along the coastline to find the closest point on any other coastline; if that is under some set limit it is a strait.






share|improve this answer









$endgroup$



The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance between the spots you can identify narrow deep bays, wide shallow bays, etc.



In this picture, the red and purple dots show the two candidate points and the green line is the coastline between the points. The sinuosity is the ratio of those two lengths:



Example of a Bay



Alternatively, you can select two points on the coast and create a polygon by connecting the two points and the coastline between the two points (i.e., connect the green line above from red dot to purple dot). Measure the area of this polygon. A bay will have a larger area than a non-bay.



In my experience, a combination of these two measures was best for reliably identifying what people see as bays.



Note that this will also detect points. To find only bays, you need to check that the "inside" of the bay contains water and not land. A quick and easy way to do this is to check the midpoint of the line between the two points to see if it is water. (This can be fooled but is generally sufficient.)



A related problem is to identify the "mouth" of the bay -- i.e., the best choice for the two points that mark the opening to the bay. Typically you'll have a bunch of candidates for the "mouth". In the example map above, you could put the mouth of that bay further in or further out. Generally speaking it probably doesn't matter too much, but one heuristic that works reasonably well is to minimize the straight-line distance across the mouth.



I haven't done straits yet, but my intuition is to check points along the coastline to find the closest point on any other coastline; if that is under some set limit it is a strait.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 5 at 17:34









Dr. PainDr. Pain

40633




40633







  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    Apr 6 at 6:21












  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    Apr 6 at 6:21







3




3




$begingroup$
I should have known Dragons Abound would have the answers I need.
$endgroup$
– Olin Kirkland
Apr 6 at 6:21




$begingroup$
I should have known Dragons Abound would have the answers I need.
$endgroup$
– Olin Kirkland
Apr 6 at 6:21













49












$begingroup$

Here's a rough idea using image processing transformations to isolate the features of interest:




  1. Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;)



    Ocean Mask




  2. Apply a local smoothing to the edge of this mask, keeping the connectedness/topology the same, but smoothing out small noisy coastline features that can be distracting. This lets us focus on big bays over tiny inlets. You can use the width of your filter kernal / number of iterations to finely control the scale of features you preserve.



    Here I applied a median filter a few times. Cellular automata are another popular way to erode smooth shapes from a noisy input.



    Smoothed Coastline




  3. Turn the mask into a distance field, where each cell stores its distance from the smoothed coastline.



    Distance Field



Now we see some promising feature highlights. In a signed distance field, both bays and straits show up as sharp ridges, with distance falling off to the sides. We can use an edge detection filter to pop out these ridges:



Ridges Highlighted



You can then distinguish between bays and straits by following the ridge to determine its connectivity. A bay is a ridge that runs toward the coast, getting shallower and shallower (in distance from land) until it ends in a point. A strait is a ridge that connects a high-distance region to another high-distance region, going through a lower-distance region along the way.



Or, another way is to assign each island an ID (connected component search), then when you're making your distance field, propagate "closest island ID" alongside the distance frontier. A bay or inlet is then a ridge in water adjacent to the same landmass on both sides, while a channel is a ridge that separates water adjacent to two different landmasses.



You can set minimum & maximum distance-to-shore or length-of-ridge constraints to control which features to label, if you need to exclude excessively narrow/wide straits for instance.






share|improve this answer











$endgroup$








  • 9




    $begingroup$
    This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
    $endgroup$
    – Quentin
    Apr 5 at 13:56






  • 7




    $begingroup$
    The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
    $endgroup$
    – Monty Harder
    Apr 5 at 14:42










  • $begingroup$
    The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
    $endgroup$
    – MSalters
    Apr 8 at 11:26















49












$begingroup$

Here's a rough idea using image processing transformations to isolate the features of interest:




  1. Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;)



    Ocean Mask




  2. Apply a local smoothing to the edge of this mask, keeping the connectedness/topology the same, but smoothing out small noisy coastline features that can be distracting. This lets us focus on big bays over tiny inlets. You can use the width of your filter kernal / number of iterations to finely control the scale of features you preserve.



    Here I applied a median filter a few times. Cellular automata are another popular way to erode smooth shapes from a noisy input.



    Smoothed Coastline




  3. Turn the mask into a distance field, where each cell stores its distance from the smoothed coastline.



    Distance Field



Now we see some promising feature highlights. In a signed distance field, both bays and straits show up as sharp ridges, with distance falling off to the sides. We can use an edge detection filter to pop out these ridges:



Ridges Highlighted



You can then distinguish between bays and straits by following the ridge to determine its connectivity. A bay is a ridge that runs toward the coast, getting shallower and shallower (in distance from land) until it ends in a point. A strait is a ridge that connects a high-distance region to another high-distance region, going through a lower-distance region along the way.



Or, another way is to assign each island an ID (connected component search), then when you're making your distance field, propagate "closest island ID" alongside the distance frontier. A bay or inlet is then a ridge in water adjacent to the same landmass on both sides, while a channel is a ridge that separates water adjacent to two different landmasses.



You can set minimum & maximum distance-to-shore or length-of-ridge constraints to control which features to label, if you need to exclude excessively narrow/wide straits for instance.






share|improve this answer











$endgroup$








  • 9




    $begingroup$
    This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
    $endgroup$
    – Quentin
    Apr 5 at 13:56






  • 7




    $begingroup$
    The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
    $endgroup$
    – Monty Harder
    Apr 5 at 14:42










  • $begingroup$
    The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
    $endgroup$
    – MSalters
    Apr 8 at 11:26













49












49








49





$begingroup$

Here's a rough idea using image processing transformations to isolate the features of interest:




  1. Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;)



    Ocean Mask




  2. Apply a local smoothing to the edge of this mask, keeping the connectedness/topology the same, but smoothing out small noisy coastline features that can be distracting. This lets us focus on big bays over tiny inlets. You can use the width of your filter kernal / number of iterations to finely control the scale of features you preserve.



    Here I applied a median filter a few times. Cellular automata are another popular way to erode smooth shapes from a noisy input.



    Smoothed Coastline




  3. Turn the mask into a distance field, where each cell stores its distance from the smoothed coastline.



    Distance Field



Now we see some promising feature highlights. In a signed distance field, both bays and straits show up as sharp ridges, with distance falling off to the sides. We can use an edge detection filter to pop out these ridges:



Ridges Highlighted



You can then distinguish between bays and straits by following the ridge to determine its connectivity. A bay is a ridge that runs toward the coast, getting shallower and shallower (in distance from land) until it ends in a point. A strait is a ridge that connects a high-distance region to another high-distance region, going through a lower-distance region along the way.



Or, another way is to assign each island an ID (connected component search), then when you're making your distance field, propagate "closest island ID" alongside the distance frontier. A bay or inlet is then a ridge in water adjacent to the same landmass on both sides, while a channel is a ridge that separates water adjacent to two different landmasses.



You can set minimum & maximum distance-to-shore or length-of-ridge constraints to control which features to label, if you need to exclude excessively narrow/wide straits for instance.






share|improve this answer











$endgroup$



Here's a rough idea using image processing transformations to isolate the features of interest:




  1. Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;)



    Ocean Mask




  2. Apply a local smoothing to the edge of this mask, keeping the connectedness/topology the same, but smoothing out small noisy coastline features that can be distracting. This lets us focus on big bays over tiny inlets. You can use the width of your filter kernal / number of iterations to finely control the scale of features you preserve.



    Here I applied a median filter a few times. Cellular automata are another popular way to erode smooth shapes from a noisy input.



    Smoothed Coastline




  3. Turn the mask into a distance field, where each cell stores its distance from the smoothed coastline.



    Distance Field



Now we see some promising feature highlights. In a signed distance field, both bays and straits show up as sharp ridges, with distance falling off to the sides. We can use an edge detection filter to pop out these ridges:



Ridges Highlighted



You can then distinguish between bays and straits by following the ridge to determine its connectivity. A bay is a ridge that runs toward the coast, getting shallower and shallower (in distance from land) until it ends in a point. A strait is a ridge that connects a high-distance region to another high-distance region, going through a lower-distance region along the way.



Or, another way is to assign each island an ID (connected component search), then when you're making your distance field, propagate "closest island ID" alongside the distance frontier. A bay or inlet is then a ridge in water adjacent to the same landmass on both sides, while a channel is a ridge that separates water adjacent to two different landmasses.



You can set minimum & maximum distance-to-shore or length-of-ridge constraints to control which features to label, if you need to exclude excessively narrow/wide straits for instance.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 5 at 17:37









Alexandre Vaillancourt

12.8k114149




12.8k114149










answered Apr 5 at 11:41









DMGregoryDMGregory

65k16115181




65k16115181







  • 9




    $begingroup$
    This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
    $endgroup$
    – Quentin
    Apr 5 at 13:56






  • 7




    $begingroup$
    The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
    $endgroup$
    – Monty Harder
    Apr 5 at 14:42










  • $begingroup$
    The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
    $endgroup$
    – MSalters
    Apr 8 at 11:26












  • 9




    $begingroup$
    This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
    $endgroup$
    – Quentin
    Apr 5 at 13:56






  • 7




    $begingroup$
    The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
    $endgroup$
    – Monty Harder
    Apr 5 at 14:42










  • $begingroup$
    The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
    $endgroup$
    – MSalters
    Apr 8 at 11:26







9




9




$begingroup$
This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
$endgroup$
– Quentin
Apr 5 at 13:56




$begingroup$
This looks really cool, and could probably be sped up considerably by directly using the cell structure to apply the various steps rather than the graphical representation!
$endgroup$
– Quentin
Apr 5 at 13:56




7




7




$begingroup$
The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
$endgroup$
– Monty Harder
Apr 5 at 14:42




$begingroup$
The second approach (assigning each distinct landmass an ID and distinguishing based on whether it's the same landmass on both sides of the body of water) seems like the easiest thing to do..
$endgroup$
– Monty Harder
Apr 5 at 14:42












$begingroup$
The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
$endgroup$
– MSalters
Apr 8 at 11:26




$begingroup$
The "landmass ID" is a good idea anyway, as you'll also need it in the map labeling to generate island names.
$endgroup$
– MSalters
Apr 8 at 11:26











6












$begingroup$

Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions:



Bay



  • Any ocean cell that only connects to a single other ocean cell

  • OR: Any ocean cell that connects to more land than ocean cells, with all ocean cells next to each other

  • OR: Same as above, but with a criterion based on border length (e.g. twice as much land as water border)

Strait



  • Any ocean cell that connects to exactly two ocean cells which are not next to each other

  • OR: Any ocean cell that connects to two land cells that don't belong to the same landmass (you need to find out which land cells are connected first, and assign IDs to each landmass)

  • OR: March around the border, and count land/water and water/land transitions. You need at least two of each.

  • Depending on your method and what you want to do with the categories, you might want to eliminate straits that only lead to a bay, or label them as bay instead.





share|improve this answer











$endgroup$








  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    Apr 5 at 15:20







  • 1




    $begingroup$
    If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
    $endgroup$
    – DMGregory
    Apr 5 at 17:02










  • $begingroup$
    Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
    $endgroup$
    – TheLuckless
    Apr 5 at 17:23















6












$begingroup$

Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions:



Bay



  • Any ocean cell that only connects to a single other ocean cell

  • OR: Any ocean cell that connects to more land than ocean cells, with all ocean cells next to each other

  • OR: Same as above, but with a criterion based on border length (e.g. twice as much land as water border)

Strait



  • Any ocean cell that connects to exactly two ocean cells which are not next to each other

  • OR: Any ocean cell that connects to two land cells that don't belong to the same landmass (you need to find out which land cells are connected first, and assign IDs to each landmass)

  • OR: March around the border, and count land/water and water/land transitions. You need at least two of each.

  • Depending on your method and what you want to do with the categories, you might want to eliminate straits that only lead to a bay, or label them as bay instead.





share|improve this answer











$endgroup$








  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    Apr 5 at 15:20







  • 1




    $begingroup$
    If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
    $endgroup$
    – DMGregory
    Apr 5 at 17:02










  • $begingroup$
    Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
    $endgroup$
    – TheLuckless
    Apr 5 at 17:23













6












6








6





$begingroup$

Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions:



Bay



  • Any ocean cell that only connects to a single other ocean cell

  • OR: Any ocean cell that connects to more land than ocean cells, with all ocean cells next to each other

  • OR: Same as above, but with a criterion based on border length (e.g. twice as much land as water border)

Strait



  • Any ocean cell that connects to exactly two ocean cells which are not next to each other

  • OR: Any ocean cell that connects to two land cells that don't belong to the same landmass (you need to find out which land cells are connected first, and assign IDs to each landmass)

  • OR: March around the border, and count land/water and water/land transitions. You need at least two of each.

  • Depending on your method and what you want to do with the categories, you might want to eliminate straits that only lead to a bay, or label them as bay instead.





share|improve this answer











$endgroup$



Basically, you need to think about what you mean, precisely, by a bay or strait, and why you want to differentiate them (is it for AI calculations, or to label landmarks, or something else?). Play around with a few definitions to find the one that looks best to you. Then, formulate conditions to check on your Voronoi cells. A few suggestions:



Bay



  • Any ocean cell that only connects to a single other ocean cell

  • OR: Any ocean cell that connects to more land than ocean cells, with all ocean cells next to each other

  • OR: Same as above, but with a criterion based on border length (e.g. twice as much land as water border)

Strait



  • Any ocean cell that connects to exactly two ocean cells which are not next to each other

  • OR: Any ocean cell that connects to two land cells that don't belong to the same landmass (you need to find out which land cells are connected first, and assign IDs to each landmass)

  • OR: March around the border, and count land/water and water/land transitions. You need at least two of each.

  • Depending on your method and what you want to do with the categories, you might want to eliminate straits that only lead to a bay, or label them as bay instead.






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 5 at 15:04

























answered Apr 5 at 14:51









AutolykosAutolykos

1612




1612







  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    Apr 5 at 15:20







  • 1




    $begingroup$
    If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
    $endgroup$
    – DMGregory
    Apr 5 at 17:02










  • $begingroup$
    Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
    $endgroup$
    – TheLuckless
    Apr 5 at 17:23












  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    Apr 5 at 15:20







  • 1




    $begingroup$
    If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
    $endgroup$
    – DMGregory
    Apr 5 at 17:02










  • $begingroup$
    Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
    $endgroup$
    – TheLuckless
    Apr 5 at 17:23







2




2




$begingroup$
When a strait leads to a bay, then these two together might be labeled as a fjord.
$endgroup$
– Philipp
Apr 5 at 15:20





$begingroup$
When a strait leads to a bay, then these two together might be labeled as a fjord.
$endgroup$
– Philipp
Apr 5 at 15:20





1




1




$begingroup$
If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
$endgroup$
– DMGregory
Apr 5 at 17:02




$begingroup$
If the cells are small relative to the size of a bay/strait, then you might need to propagate this to look at cells beyond the immediately adjacent neighbours.
$endgroup$
– DMGregory
Apr 5 at 17:02












$begingroup$
Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
$endgroup$
– TheLuckless
Apr 5 at 17:23




$begingroup$
Yes, scaling is a bit of an issue, and will impact how you define things and declare 'cells'. Consider a map of Canada, and compare the following: Hudson Bay, James Bay, Gulf of St Lawrence, and Bay of Fundy. How do you reliably apply these rules to get the desired related names? - Is there a "straight" between Newfoundland and Nova Scotia?
$endgroup$
– TheLuckless
Apr 5 at 17:23

















draft saved

draft discarded
















































Thanks for contributing an answer to Game Development Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgamedev.stackexchange.com%2fquestions%2f169723%2fhow-can-bays-and-straits-be-determined-in-a-procedurally-generated-map%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?