calculate distances in GIS data

55 views
Skip to first unread message

Azbina Rahman

unread,
Nov 2, 2023, 2:56:50 PM11/2/23
to netlogo-users
Dear netlogo users,

I am a new user of Netlogo and I am facing some problem with a simple application, I will be grateful to have your suggestion. I have two sets of GIS data, one is a polygon of a watershed with numbers of subbasins, other one is a data of some points. I want to measure the distance between the points and the centroid of each subbasins. I am sharing my code and data here as attachment. Please give me your suggestions on how can I calculate the distance.

With warm regards,
Azbina
code_nlogo.docx
WWTP_data.zip
subbasin.zip

Azbina Rahman

unread,
Nov 7, 2023, 3:31:03 PM11/7/23
to netlogo-users
Following up on my past question.

Pradeesh Kumar K V

unread,
Nov 8, 2023, 5:58:48 AM11/8/23
to netlogo-users
Hello Azbina,

The code for determining centroid is very clearly provided in the GIS example within the models library. I have used the same code and modified it a bit as given below:

to draw-basin-labels
  foreach gis:feature-list-of subbasin-zekiah [ this-basin-vector-feature ->
    let centroid1 gis:location-of gis:centroid-of this-basin-vector-feature
    ; centroid will be an empty list if it lies outside the bounds
    ; of the current NetLogo world, as defined by our current GIS
    ; coordinate transformation
    if not empty? centroid1 [
    create-turtles 1
      [ set xcor item 0 centroid1
        set ycor item 1 centroid1
        set size 0.8
        set color yellow
        set shape "circle"
        ;set label gis:property-value this-basin-vector-feature "CNTRY_NAME"
        ]
      ]
  ]
end

The above code will identify the centroids of each subbasin and show it with a yellow-colored turtle.

For finding distance between the points, you can create turtles on these points and then ask the turtles to measure distance between each other. I have modified your code as follows:
to draw-wwtp
  gis:set-drawing-color yellow
  gis:create-turtles-from-points wwtp-data wwtps [ set shape "circle" set color blue]
  ;gis:draw wwtp-data 3.0
end

wwtps is a breed that I created. The points will be marked with turtles in blue color.

Hope this helps.

Best,

Pradeesh

--
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/b033b0cc-4b1b-474c-8e7c-3c96af43d887n%40googlegroups.com.

Azbina Rahman

unread,
Nov 8, 2023, 12:10:53 PM11/8/23
to Pradeesh Kumar K V, netlogo-users
Thank you so much, Pradeesh. This is very helpful.

Best regards,
Azbina



--
-------------------------------------------------------------------------------------
Azbina Rahman PhD
Postdoctoral Associate,
Department of Environmental Science and Technology,
University of Maryland College Park.
Reply all
Reply to author
Forward
0 new messages