2D Topographical Map

Hi, I’m very new to Processing. I’m looking to create a small square plot that has contour lines like the 2D topographical map shown in the image below. How would I go about doing this? Thanks.


1 Like

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)