Adding elevation and gradient in NetLogo

320 views
Skip to first unread message

Woi Sok Oh

unread,
Apr 21, 2021, 2:15:55 PM4/21/21
to netlogo-users
Hello,

I would like to add elevation to the model environment (conceptual environment) like below and calculate provide gradient attribute as a patch property. Do you have any suggestions or related model to implement this environment?

Thanks,
Woi

KakaoTalk_20210421_123945021.jpg

Michael Tamillow

unread,
Apr 21, 2021, 5:36:27 PM4/21/21
to Woi Sok Oh, netlogo-users
Hi Woi Sok Oh,

One of the issues with creating a gradient here is with regards to the fact that the model looks to have a stepwise pattern of elevation, so in functional terms it wouldn’t have a smooth derivative, but rather a differential relationship.

That being said, Netlogo also has discrete boundaries with patches, and yet has continuous x, y coordinates as turtles move. What I would do would be to create differentials between neighboring patches in each direction. I would also use hexagonal patches if possible to create symmetry across the whole environment. Each patch has an elevation, and the differentials are calculated as it’s own elevation minus the elevation of neighboring patches. Probably put the 6 differentials in a list and consistent in relative starts (eg. top start and calculate clockwise) so that operations using the differentials can be easily mapped across all patches.

I assume you meant gradient with respect to location, but if you meant with respect to time than that’s another case.

Sent from my iPhone

On Apr 21, 2021, at 1:15 PM, Woi Sok Oh <two...@gmail.com> wrote:

Hello,

I would like to add elevation to the model environment (conceptual environment) like below and calculate provide gradient attribute as a patch property. Do you have any suggestions or related model to implement this environment?

Thanks,
Woi

<KakaoTalk_20210421_123945021.jpg>

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/aa1332ae-46cd-44d4-94cb-607a1a0917b5n%40googlegroups.com.
<KakaoTalk_20210421_123945021.jpg>

wade.s...@gmail.com

unread,
Apr 21, 2021, 6:03:12 PM4/21/21
to netlogo-users
There is Netlogo-3D described in the user manual, and the Hill Climbing 2.5d model in the model library. ( 2.5d Patch View Example).
I haven't used either but there is a "view2.5d" extension to check out.

Obviously, as you make the patches smaller your model will take more space and be longer to run, probably, or possibly,  but the fit to a gradient surface will be better.
I'm not sure how one would make hexagonal patches without a lot of work.

There's no reason to limit the patch's wisdom to neighboring patches.  Especially if run-time for setting up the patches is run exactly once,      or run once and exported and then imported for each new run,  you can use " import-pcolors filename " to  import an external jpg image with your gradient field accurate to a pixel, say, and values encoded in the 24-bit RGB fields, use more sophisticated 3-D surface fitting to, say, everything in some radius from a given patch, not just neighbors-4 or neighbors-8,  and store your best fit gradient vector as a patches-own variable  ( either  [x,y,z] or  heading-and-distance, though I'm not sure if Netlogo heading allows fractional angles or not.)

Or for that matter, you could generate not just the 3-d surface but compute the 3-D gradient in an external ( possibly compiled ! ) software product of some kind,   and read in the gradients.  Again, that's if the surface is not dynamically changing during your run.

Wade

wade.s...@gmail.com

unread,
Apr 21, 2021, 6:07:58 PM4/21/21
to netlogo-users
( oh, I believe I put a model up in the Modeling Commons a month or so ago that illustrated importing an image and using it to set pixels.  Sadly I can't recall and right now the commons is inaccessible due to too many people in the queue so I can't check! )

Wade

Brad Reisfeld

unread,
Apr 21, 2021, 6:35:11 PM4/21/21
to netlog...@googlegroups.com
I once created a flood model that used a number of stylized elevation maps that used analytical functions to describe the terrain. For these simple topographies, the slope or gradient could be calculated analytically as a function of the coordinates. I had each patch 'own' its elevation and slope, which became important in specifying the severity of the flood at any given grid location.

I don't know if a similar approach could be used in the OP's situation.

Kind regards,
Brad
 

 

Michael Tamillow

unread,
Apr 21, 2021, 8:02:26 PM4/21/21
to Brad Reisfeld, netlog...@googlegroups.com
Hey Wade,

I suggested hexagonal patches because it is a built in feature of Netlogo: https://ccl.northwestern.edu/netlogo/models/HexCellsExample

The reason it is a feature is because hexagonal shapes have excellent symmetry in how they link to one another, that way there is no corner vs. side decision. All neighbors are rotationally invariant.

There are certainly other things that can be done, but they might not be as intuitive to the underlying structure of how Netlogo was designed (to model the relationships between agents). I do not see playing with pixels as a something consistent with the design of Netlogo.

Sent from my iPhone

On Apr 21, 2021, at 5:35 PM, Brad Reisfeld <brad.r...@gmail.com> wrote:

 I once created a flood model that used a number of stylized elevation maps that used analytical functions to describe the terrain. For these simple topographies, the slope or gradient could be calculated analytically as a function of the coordinates. I had each patch 'own' its elevation and slope, which became important in specifying the severity of the flood at any given grid location.

wade.s...@gmail.com

unread,
Apr 22, 2021, 9:35:03 AM4/22/21
to netlogo-users
@Mikaelta,

That's cool - hexagonal cells. I'll check it out! Thank you!
Oh, I made a toy netlogo model that just builds one or two gaussian mountains on a 100x100 grid with variable mean and standard-deviation,
color codes the terrain, and draws a few contour lines.

Later if I get time I'll play with adding gradients and see how that affects my swarm migration.
You can pull up the model and download it from here, I think ( I haven't done this before but it worked for me! let me know if it doesn't work for you, )


Wade

Aaron Andre Brandes

unread,
Apr 22, 2021, 10:12:53 AM4/22/21
to wade.s...@gmail.com, netlogo-users

Hi,

Lots of great suggestions have already been made.

Here is one new idea:

I know Woi is talking about conceptual environments, but it might be worth looking at some of the capabilities of the GIS extension.

In particular the NetLogo Models Library (reachable through the File menu in NetLogo) contains the GIS Gradient Example.

The model uses gis:convolve to compute horizontal and vertical gradients based on an elevation data file.

 

Here is some more info on the view2.5d extension which Wade mentioned:

I think it is a natural choice for representing a turtle or patch-value as a third dimension.

The NetLogo Models Library contains the 2.5d Patch View Example in which the patch color is used to model elevation, and the turtles move to larger color values, reaching the top of the hills. It uses the uphill primitive.

 

Note that you can use any patches-own variable, which could be using an anonymous function. You might get some ideas from

 2.5d Turtle View Example which is a simple model (which I wrote) that shows how to use many of the features of view2.5d.

Here is the line that assigns the z coordinate to be the turtles-own variable height.

  view2.5d:turtle-view window-name turtles [ the-turtle -> [height] of the-turtle ]

 

Note that in this model the height is recomputed every tick. You would probably want to use a patch view and not change the elevation value.

 

Aaron

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

Woi Sok Oh

unread,
Apr 22, 2021, 10:43:06 AM4/22/21
to netlogo-users
Thank you all for your great suggestions!

2021년 4월 21일 수요일 오후 2시 15분 55초 UTC-4에 Woi Sok Oh님이 작성:

Woi Sok Oh

unread,
Apr 22, 2021, 10:48:14 AM4/22/21
to netlogo-users
Hi Brad,

Is your model uploaded online? I would like to take a look to get some idea.

Thanks,
Woi

2021년 4월 21일 수요일 오후 6시 35분 11초 UTC-4에 cytochrome님이 작성:

Brad Reisfeld

unread,
Apr 22, 2021, 11:30:27 AM4/22/21
to netlog...@googlegroups.com, two...@gmail.com
Hi Woi,

I'll send you a couple of code snippets that I hope will help.

Kind regards,
Brad
 
Reply all
Reply to author
Forward
0 new messages