GIS General Examples

GIS General Examples preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner about 11 years ago

gis 

Tagged by Reuven M. Lerner over 10 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 16114 times • Downloaded 703 times • Run 3 times
Download the 'GIS General Examples' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

how to use a point dataset as turtles (Question)

hello i'm biginre in netlogo and i need to use a point dataset as turtles. can any body help me please?

Posted almost 12 years ago

Point datasets

Hi, Naifseh. When you say that you have a "point dataset," in what format is it? Do you want to translate it into NetLogo code, or import it from an external file into a NetLogo model?

Posted almost 12 years ago

Having problems with model (Question)

Hello, Not sure if anyone else is having this issue, but I can't seem to run this model. It doesn't work in my browser, so I downloaded it. First I get the error when I press the "setup" button - actually "setup/n" that / is not an allowed character. I changed it to just "setup" because I assume that's usually what it should be. When I press setup, I get the error Extension exception: projection file "data/WGS_84_Geographic.prj does not exist". This happens when I try to load any of the GIS files as well. Is it possible that the download doesn't include the necessary GIS files (ie the shp. and .asc files). Or possibly I am missing a whole step (I am pretty new to Netlogo)! Thank you!

Posted almost 11 years ago

Missing files

Hi, Shannon. I think that I know what the problem is -- the version of this model, like others from the NetLogo Models Library, was imported using a program that I wrote to do the transfer. Unfortunately, I seem to have neglected to import/attach files other than the preview. I'll try to get those imported pretty soon -- but for now, I'm afraid that the best (stopgap) solution would be to download the latest version of NetLogo, and to use the model from there. I'll update this discussion board when I update the model and its files, hopefully in the coming days.

Posted almost 11 years ago

While I'm writing...

You can't run the model in the browser for the same reason; I've recently enabled extensions and remote files from the browser-based system, but there are some weird issues with Java applets that make it hard to get this to work completely. That said, attaching the files will at least give us a fighting chance of success -- assuming that your browser will allow you to run applets.

Posted almost 11 years ago

Missing files 2 (Question)

Hi Reuven, Thank you for the reply! Unfortunately the same happens when I download the model into Netlogo. The interface loads properly, but in running the model I am notified that the files are missing (ie the .prj, .shp, .asc files). "Extension exception: projection file "data/WGS_84_Geographic.prj does not exist". This is actually happening for your gradient model as well. I'm trying to import raster layers and sample patches from the layers, which is why I am so interested in your models! Thank you - Shannon

Posted almost 11 years ago

Problem fixed

I realized this example is already in my Netlogo library - it runs from there just fine! (It doesn't work in browser, or if I download from website). Sorry for the hassle!

Posted almost 11 years ago

turtles in polygon (Question)

Hi, I am wondering how I could ask turtles to take a random location within a polygon, and subsequently to move only inside the polygon. thanks

Posted over 10 years ago

import raster

Hi,I import two rasterdataset,one of them is polygon and it has 4 class,and i want to show each of them by one color,I use the cod bellow,but it isn't desired result.please help me. to display-parcel gis:paint parcel 0 gis:apply-raster parcel structure let min-structure gis:minimum-of parcel let max-structure gis:maximum-of parcel ask patches [if (structure <= 0) or (structure &rt;= 0) [set pcolor scale-color red structure min-structure max-structure]] end

Posted over 10 years ago

import vector

hi when i import my vectordataset such as polyline,but this error appears "Extension exception: unsupported shape type 13" would you please guide me?

Posted over 10 years ago

try netlogo-users

Somayeh, the best place to post your questions is http://groups.yahoo.com/neo/groups/netlogo-users/info . Lots of people who use the GIS extension read questions posted there. http://stackoverflow.com is a good place too.

Posted over 10 years ago

try netlogo-user

Seth, I've posted 3times in yahoogroups up to now,but I have recieved nothing :(

Posted over 10 years ago

netlogo-users

Somayeh, you mean you asked your question on netlogo-users and nobody responded? Or you mean you weren't able to post there at all?

Posted over 10 years ago

netlogo-user

I mean I asked 3 question on netlogo-users and nobody responded!

Posted over 10 years ago

netlogo-users

I see your questions now (http://groups.yahoo.com/neo/groups/netlogo-users/conversations/messages/17207, http://groups.yahoo.com/neo/groups/netlogo-users/conversations/messages/17453, http://groups.yahoo.com/neo/groups/netlogo-users/conversations/messages/17463). The fire question, nobody answered because it's way too broad. Saying "help me" usually doesn't work; you need to ask something specific. The question about raster vs. vector is also too broad. No one can possibly know whether you ought to choose raster or vector unless they know more about what you're trying to accomplish. If all we have to go on is that you're trying to model fire spread, it's impossible to give specific advice. The file-open question seems the closest to being a specific question about a specific problem you're having, but the question itself is unclear. I suggest you either: 1) Try again on netlogo-users, but try to ask specific, detailed questions about specific technical problems — not broad questions that are too much work to answer by anyone who can't read your mind. Mention that you've asked the question before, didn't get a response, and you're trying again, and trying to ask better this time; that will probably get people's attention. 2) Try Stack Overflow instead. On Stack Overflow, you're allowed to edit your question and improve it based on feedback about whether the question itself is good.

Posted over 10 years ago

netlogo-user

Dear Seth Tisue thank you so much for your advices,and I'll try again to ask my questions better.but what do you mean " Try Stack Overflow" .I have another question and that is how can I improve coding in netlogo,I studied the references which I had,such as,It's help,some of it's model,and the tutorials,but I have many problems with it,and I can't solve them!

Posted over 10 years ago

SO & learning NetLogo

Stack Overflow is a website where you can ask questions about programming in any language, including the NetLogo. Here's the NetLogo questions people have asked: http://stackoverflow.com/questions/tagged/netlogo As for how to improve coding in NetLogo: I think usually if someone has trouble it's because they're trying to learn too much all at once by writing a big program all at once. Write a really small program; get it working; attempt to make a very small improvement to it, and get that working; and so on. If at any point you get stuck, you'll be able to get help easily because you were only trying to do something small and specific.

Posted over 10 years ago

Modeling urban road network (Question)

Hi. I'm going to model urban road network in an ABM platform. so, I'm looking for an appropriate platform. I've found some platforms like Repast simphony, NetLogo,AnyLogic,SeSAm and GAMA. I want to model roads as agent's enviroment and add cars as agents into it. But I dont know which one is the best for my modeling. Can any body heip me??

Posted over 9 years ago

Exporting xcor ycor as projected coordinates?

Hi there, I have a well functioning model of pedestrians i a generic, urban environment loaded from shapefiles - including projection/transformation. See selected code lines below. How do I export the xcor's and ycors of turtles to text files, projected/transformed into the original projection system? Thanks in advance Hans code examples... gis:load-coordinate-system (word "../data/testLines_2.prj") set ODLines gis:load-dataset "../data/testLines_2.shp" setUpEnvelopeExtented ODLines 10

Posted about 9 years ago

GIS General Examples

I am looking for a model that uses a map - U.S. for now - and I found this GIS General Example. However, I cannot unzip the file - it has errors. And I think it may be missing data. There is an old version from Marcello Tomasini, but that also does not unzip. Don't know if this is a problem with my WinZip, or the file. Does anyone have examples using some sort of map as a background? Thanks.

Posted over 7 years ago

files not found (Question)

the shape and prj files are not included , where i may find them ?

Posted over 6 years ago

Click to Run Model

extensions [ gis ]
globals [ cities-dataset
          rivers-dataset
          countries-dataset
          elevation-dataset ]
breed [ city-labels city-label ]
breed [ country-labels country-label ]
breed [ country-vertices country-vertex ]
breed [ river-labels river-label ]
patches-own [ population country-name elevation ]

to setup
  ca
  ; Note that setting the coordinate system here is optional, as
  ; long as all of your datasets use the same coordinate system.
  gis:load-coordinate-system (word "data/" projection ".prj")
  ; Load all of our datasets
  set cities-dataset gis:load-dataset "data/cities.shp"
  set rivers-dataset gis:load-dataset "data/rivers.shp"
  set countries-dataset gis:load-dataset "data/countries.shp"
  set elevation-dataset gis:load-dataset "data/world-elevation.asc"
  ; Set the world envelope to the union of all of our dataset's envelopes
  gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of cities-dataset)
                                                (gis:envelope-of rivers-dataset)
                                                (gis:envelope-of countries-dataset)
                                                (gis:envelope-of elevation-dataset))
end 

; Drawing point data from a shapefile, and optionally loading the
; data into turtles, if label-cities is true

to display-cities
  ask city-labels [ die ]
  foreach gis:feature-list-of cities-dataset
  [ gis:set-drawing-color scale-color red (gis:property-value ? "POPULATION") 5000000 1000
    gis:fill ? 2.0
    if label-cities
    [ ; a feature in a point dataset may have multiple points, so we
      ; have a list of lists of points, which is why we need to use
      ; first twice here
      let location gis:location-of (first (first (gis:vertex-lists-of ?)))
      ; location will be an empty list if the point lies outside the
      ; bounds of the current NetLogo world, as defined by our current
      ; coordinate transformation
      if not empty? location
      [ create-city-labels 1
        [ set xcor item 0 location
          set ycor item 1 location
          set size 0
          set label gis:property-value ? "NAME" ] ] ] ]
end 

; Drawing polyline data from a shapefile, and optionally loading some
; of the data into turtles, if label-rivers is true

to display-rivers
  ask river-labels [ die ]
  gis:set-drawing-color blue
  gis:draw rivers-dataset 1
  if label-rivers
  [ foreach gis:feature-list-of rivers-dataset
    [ let centroid gis:location-of gis:centroid-of ?
      ; 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? centroid
      [ create-river-labels 1
          [ set xcor item 0 centroid
            set ycor item 1 centroid
            set size 0
            set label gis:property-value ? "NAME" ] ] ] ]
end 

; Drawing polygon data from a shapefile, and optionally loading some
; of the data into turtles, if label-countries is true

to display-countries
  ask country-labels [ die ]
  gis:set-drawing-color white
  gis:draw countries-dataset 1
  if label-countries
  [ foreach gis:feature-list-of countries-dataset
    [ let centroid gis:location-of gis:centroid-of ?
      ; 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? centroid
      [ create-country-labels 1
        [ set xcor item 0 centroid
          set ycor item 1 centroid
          set size 0
          set label gis:property-value ? "CNTRY_NAME" ] ] ] ]
end 

; Loading polygon data into turtles connected by links

to display-countries-using-links
  ask country-vertices [ die ]
  foreach gis:feature-list-of countries-dataset
  [ foreach gis:vertex-lists-of ?
    [ let previous-turtle nobody
      let first-turtle nobody
      ; By convention, the first and last coordinates of polygons
      ; in a shapefile are the same, so we don't create a turtle
      ; on the last vertex of the polygon
      foreach but-last ?
      [ let location gis:location-of ?
        ; location 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? location
        [ create-country-vertices 1
          [ set xcor item 0 location
            set ycor item 1 location
            ifelse previous-turtle = nobody
            [ set first-turtle self ]
            [ create-link-with previous-turtle ]
            set hidden? true
            set previous-turtle self ] ] ]
      ; Link the first turtle to the last turtle to close the polygon
      if first-turtle != nobody and first-turtle != previous-turtle
      [ ask first-turtle
        [ create-link-with previous-turtle ] ] ] ]
end 

; Using gis:intersecting to find the set of patches that intersects
; a given vector feature (in this case, a river).

to display-rivers-in-patches
  ask patches [ set pcolor black ]
  ask patches gis:intersecting rivers-dataset
  [ set pcolor cyan ]
end 

; Using gis:apply-coverage to copy values from a polygon dataset
; to a patch variable

to display-population-in-patches
  gis:apply-coverage countries-dataset "POP_CNTRY" population
  ask patches
  [ ifelse (population > 0)
    [ set pcolor scale-color red population 500000000 100000 ]
    [ set pcolor blue ] ]
end 

; Using find-one-of to find a particular VectorFeature, then using
; gis:intersects? to do something with all the features from another
; dataset that intersect that feature.

to draw-us-rivers-in-green
  let united-states gis:find-one-feature countries-dataset "CNTRY_NAME" "United States"
  gis:set-drawing-color green
  foreach gis:feature-list-of rivers-dataset
  [ if gis:intersects? ? united-states
    [ gis:draw ? 1 ] ]
end 

; Using find-greater-than to find a list of VectorFeatures by value.

to highlight-large-cities
  let united-states gis:find-one-feature countries-dataset "CNTRY_NAME" "United States"
  gis:set-drawing-color yellow
  foreach gis:find-greater-than cities-dataset "POPULATION" 10000000
  [ gis:draw ? 3 ]
end 

; Drawing a raster dataset to the NetLogo drawing layer, which sits
; on top of (and obscures) the patches.

to display-elevation
  gis:paint elevation-dataset 0
end 

to display-elevation-in-patches
  ; This is the preferred way of copying values from a raster dataset
  ; into a patch variable: in one step, using gis:apply-raster.
  gis:apply-raster elevation-dataset elevation
  ; Now, just to make sure it worked, we'll color each patch by its
  ; elevation value.
  let min-elevation gis:minimum-of elevation-dataset
  let max-elevation gis:maximum-of elevation-dataset
  ask patches
  [ ; note the use of the "<= 0 or >= 0" technique to filter out
    ; "not a number" values, as discussed in the documentation.
    if (elevation <= 0) or (elevation >= 0)
    [ set pcolor scale-color black elevation min-elevation max-elevation ] ]
end 

; This is a second way of copying values from a raster dataset into
; patches, by asking for a rectangular sample of the raster at each
; patch. This is somewhat slower, but it does produce smoother
; subsampling, which is desirable for some types of data.

to sample-elevation-with-patches
  let min-elevation gis:minimum-of elevation-dataset
  let max-elevation gis:maximum-of elevation-dataset
  ask patches
  [ set elevation gis:raster-sample elevation-dataset self
    if (elevation <= 0) or (elevation >= 0)
    [ set pcolor scale-color black elevation min-elevation max-elevation ] ]
end 

; This is an example of how to select a subset of a raster dataset
; whose size and shape matches the dimensions of the NetLogo world.
; It doesn't actually draw anything; it just modifies the coordinate
; transformation to line up patch boundaries with raster cell
; boundaries. You need to call one of the other commands after calling
; this one to see its effect.

to match-cells-to-patches
  gis:set-world-envelope gis:raster-world-envelope elevation-dataset 0 0
  cd
  ct
end 

; This command also demonstrates the technique of creating a new, empty
; raster dataset and filling it with values from a calculation.
;
; This command uses the gis:convolve primitive to compute the horizontal
; and vertical Sobel gradients of the elevation dataset, then combines
; them using the square root of the sum of their squares to compute an
; overall "image gradient". This is really more of an image-processing
; technique than a GIS technique, but I've included it here to show how
; it can be easily done using the GIS extension.

to display-gradient-in-patches
  let horizontal-gradient gis:convolve elevation-dataset 3 3 [ 1 0 -1 2 0 -2 1 0 -1 ] 1 1
  let vertical-gradient gis:convolve elevation-dataset 3 3 [ 1 2 1 0 0 0 -1 -2 -1 ] 1 1
  let gradient gis:create-raster gis:width-of elevation-dataset gis:height-of elevation-dataset gis:envelope-of elevation-dataset
  let x 0
  repeat (gis:width-of gradient)
  [ let y 0
    repeat (gis:height-of gradient)
    [ let gx gis:raster-value horizontal-gradient x y
      let gy gis:raster-value vertical-gradient x y
      if ((gx <= 0) or (gx >= 0)) and ((gy <= 0) or (gy >= 0))
      [ gis:set-raster-value gradient x y sqrt ((gx * gx) + (gy * gy)) ]
      set y y + 1 ]
    set x x + 1 ]
  let min-g gis:minimum-of gradient
  let max-g gis:maximum-of gradient
  gis:apply-raster gradient elevation
  ask patches
  [ if (elevation <= 0) or (elevation >= 0)
    [ set pcolor scale-color black elevation min-g max-g ] ]
end 


; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky almost 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 13 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky almost 14 years ago GIS General Examples Download this version
Uri Wilensky almost 14 years ago GIS General Examples Download this version

Attached files

File Type Description Last updated
GIS General Examples.png preview Preview almost 11 years ago, by Reuven M. Lerner Download

This model does not have any ancestors.

This model does not have any descendants.