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





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







39












$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
    20 hours ago










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    18 hours ago


















39












$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
    20 hours ago










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    18 hours ago














39












39








39


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

30738




30738








  • 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
    20 hours ago










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    18 hours ago














  • 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
    20 hours ago










  • $begingroup$
    I'm like 99% sure he's making a joke.
    $endgroup$
    – Olin Kirkland
    18 hours ago








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
20 hours ago




$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
20 hours ago












$begingroup$
I'm like 99% sure he's making a joke.
$endgroup$
– Olin Kirkland
18 hours ago




$begingroup$
I'm like 99% sure he's making a joke.
$endgroup$
– Olin Kirkland
18 hours ago










3 Answers
3






active

oldest

votes


















27












$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








New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$









  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    2 days ago



















48












$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
    17 hours ago



















5












$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










New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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 () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

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









27












$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








New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$









  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    2 days ago
















27












$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








New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$









  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    2 days ago














27












27








27





$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








New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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








New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Apr 5 at 17:34









Dr. PainDr. Pain

38623




38623




New contributor




Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dr. Pain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    2 days ago














  • 3




    $begingroup$
    I should have known Dragons Abound would have the answers I need.
    $endgroup$
    – Olin Kirkland
    2 days ago








3




3




$begingroup$
I should have known Dragons Abound would have the answers I need.
$endgroup$
– Olin Kirkland
2 days ago




$begingroup$
I should have known Dragons Abound would have the answers I need.
$endgroup$
– Olin Kirkland
2 days ago













48












$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
    17 hours ago
















48












$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
    17 hours ago














48












48








48





$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

64.7k16115180




64.7k16115180








  • 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
    17 hours ago














  • 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
    17 hours ago








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
17 hours ago




$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
17 hours ago











5












$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










New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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
















5












$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










New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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














5












5








5





$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










New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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










New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited Apr 5 at 15:04





















New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Apr 5 at 14:51









AutolykosAutolykos

1512




1512




New contributor




Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Autolykos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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

He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

Bunad

Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum