Paulo Sergio
Paulo Sergio

Reputation: 39

slider to change gis data

I currently have a dataset consisting of four shp files - minimum temperature, maximum temperature, mean temperature and precipitation - for each coordinate of the file. The problem I'm trying to solve demands that I should be able to dynamically change these variables while running the model. I was thinking of using a slider but I'm not sure if it is possible to use a slider to change shapefile values and I also did a little research on the web and haven't found anyone trying to solve this issue. Is it possible to do what I'm trying to do?

Thanks.

Upvotes: 0

Views: 52

Answers (1)

JenB
JenB

Reputation: 17678

Okay, so in your setup code, you have something that reads in the GIS data and assigns four attributes for each patch. Assume those variables are called min-temp, max-temp, mean-temp and precipitation. So you have some code like this at the top:

patches-own
[ min-temp
  max-temp
  mean-temp
  precipitation
]

You can create extra variables - so replace that with something like:

patches-own
[ min-temp-GIS
  max-temp-GIS
  mean-temp-GIS
  precipitation-GIS
  min-temp
  max-temp
  mean-temp
  precipitation
]

Assign the values from the GIS dataset to the first four variables. Create your sliders (eg max-temp-factor) and add the following to your setup code.

to setup
  ... <all the code to import the values>
  ask patches
  [ set max-temp max-temp-GIS * max-temp-factor
    ... <same for other three variables>
  ]
  ...
end

Now the patches have two values and your slider is simply a multiplier (or can go from -10 to +10 and adds to the temperature etc) so that you can have scenarios like 'what if there is a 20% lower precipitation' or 'what if max temperature was 10 degrees higher'. Your default values on the sliders would be 0 for the 'addition' factors and 1 for the 'multiplier' factors.

If you want to change the values during the simulation (so the first year has normal temperature but then it goes up), then you will need to do the ask patches [set max-temp max-temp-GIS * max-temp-factor] code in the beginning of the go step so that it calculates these variables each tick.

Upvotes: 1

Related Questions