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

An academic/student plagiarism

How to say job offer in Mandarin/Cantonese?

What's the point of deactivating Num Lock on login screens?

LaTeX closing $ signs makes cursor jump

Minkowski space

What would happen to a modern skyscraper if it rains micro blackholes?

Font hinting is lost in Chrome-like browsers (for some languages )

How is it possible to have an ability score that is less than 3?

If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?

How to format long polynomial?

Problem of parity - Can we draw a closed path made up of 20 line segments...

Modeling an IPv4 Address

Why not use SQL instead of GraphQL?

Risk of getting Chronic Wasting Disease (CWD) in the United States?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

What are the differences between the usage of 'it' and 'they'?

Theorem, big Paralist and Amsart

Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.

What's the output of a record cartridge playing an out-of-speed record

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

How old can references or sources in a thesis be?

Do VLANs within a subnet need to have their own subnet for router on a stick?

Writing rule stating superpower from different root cause is bad writing

How much RAM could one put in a typical 80386 setup?



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


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;
}







31












$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$








  • 3




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    yesterday


















31












$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$








  • 3




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    yesterday














31












31








31


14



$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 yesterday







Olin Kirkland

















asked yesterday









Olin KirklandOlin Kirkland

16728




16728








  • 3




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    yesterday














  • 3




    $begingroup$
    I recommend a baysian classifier.
    $endgroup$
    – Acccumulation
    yesterday








3




3




$begingroup$
I recommend a baysian classifier.
$endgroup$
– Acccumulation
yesterday




$begingroup$
I recommend a baysian classifier.
$endgroup$
– Acccumulation
yesterday










3 Answers
3






active

oldest

votes


















21












$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$









  • 1




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



















43












$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
    yesterday






  • 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
    yesterday



















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
    yesterday












  • $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
    yesterday










  • $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
    yesterday












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









21












$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$









  • 1




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
















21












$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$









  • 1




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














21












21








21





$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 yesterday









Dr. PainDr. Pain

32613




32613




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.








  • 1




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














  • 1




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








1




1




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




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













43












$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
    yesterday






  • 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
    yesterday
















43












$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
    yesterday






  • 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
    yesterday














43












43








43





$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 yesterday









Alexandre Vaillancourt

12.8k114149




12.8k114149










answered yesterday









DMGregoryDMGregory

64.5k16115180




64.5k16115180








  • 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
    yesterday






  • 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
    yesterday














  • 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
    yesterday






  • 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
    yesterday








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
yesterday




$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
yesterday




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
yesterday




$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
yesterday











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
    yesterday












  • $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
    yesterday










  • $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
    yesterday
















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
    yesterday












  • $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
    yesterday










  • $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
    yesterday














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 yesterday





















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 yesterday









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
    yesterday












  • $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
    yesterday










  • $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
    yesterday














  • 2




    $begingroup$
    When a strait leads to a bay, then these two together might be labeled as a fjord.
    $endgroup$
    – Philipp
    yesterday












  • $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
    yesterday










  • $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
    yesterday








2




2




$begingroup$
When a strait leads to a bay, then these two together might be labeled as a fjord.
$endgroup$
– Philipp
yesterday






$begingroup$
When a strait leads to a bay, then these two together might be labeled as a fjord.
$endgroup$
– Philipp
yesterday














$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
yesterday




$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
yesterday












$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
yesterday




$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
yesterday


















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

VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...