2D Topographical Map

Hi @heatmiser,

That related forum thread can be a good starter.

In a nutshell, you can either work with pixels (see LuckSmith’s suggestion) or with line segments. For the latter, people usually use the Marching Square algorithm or a variant approach called Meandering Triangles (see JeremyDouglass’ post). You can also have a library do all the work for you (see the “blobDetection” example).

If you need to easily have access to each and every contour-line or convert them to PShapes, resorting to a library might be more appropriate.
On the contrary, if customization is not a priority and you want to find the contours by yourself the Meandering Triangles approach could be a good choice.

example (meandering triangles)

edit: Example in p5.js (link)

3 Likes