-
Notifications
You must be signed in to change notification settings - Fork 20
/
documentation.conf
1681 lines (1560 loc) · 61.1 KB
/
documentation.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
extensionName = "gis"
markdownTemplate = """
# GIS Extension for NetLogo
This package contains the NetLogo GIS extension.
{{> BUILDING.md}}
{{> USING.md}}
## Primitives
{{#contents}}
### {{fullCategoryName}}
{{#prims}}
[`{{name}}`](#{{primitive.extensionName}}{{primitive.name}})
{{/prims}}
{{/contents}}
{{#primitives}}
{{> primTemplate}}
{{/primitives}}
{{> LICENSE.md}}
"""
additionalVariables = {
netlogoUrl: "http://ccl.northwestern.edu/netlogo/docs/"
},
primTemplate = """
### `{{name}}`
```NetLogo
{{#examples}}
{{#isOptional}}({{/isOptional}}{{primitive.fullName}}{{#args}} *{{argumentPlaceholder}}*{{/args}}{{#isOptional}}){{/isOptional}}
{{/examples}}
```
{{{description}}}
"""
filesToIncludeInManual = [ "USING.md", "primitives" ]
tableOfContents = {
"coord" : "Coordinate System Primitives",
"data" : "Dataset Primitives",
"vector" : "VectorDataset Primitives",
"raster" : "RasterDataset Primitives",
"drawing" : "Drawing Primitives"
}
primitives = [
{
name: set-transformation,
type: command,
tags: [ "coord" ],
arguments: [ { name: gis-envelope, type: list }, { name: netlogo-envelope, type: list } ]
description: """
Defines a mapping between GIS coordinates and NetLogo coordinates.
The *gis-envelope* and *netlogo-envelope* parameters must
each be four-element lists consisting of:
```
[minimum-x maximum-x minimum-y maximum-y]
```
The scale of the transformation will be equal to the minimum of the
scale necessary to make the mapping between the ranges of x values
and the scale necessary to make the mapping between the ranges of y
values. The GIS space will be centered in NetLogo space.
For example, the following two lists would map all of geographic
(latitude and longitude) space in degrees to NetLogo world space,
regardless of the current dimensions of the NetLogo world:
```
(list -180 180 -90 90)
(list min-pxcor max-pxcor min-pycor max-pycor)
```
However, if you're setting the envelope of the NetLogo world,
you should probably be using [set-world-envelope](#gisset-world-envelope).
"""
},
{
name: set-transformation-ds,
type: command,
tags: [ "coord" ],
arguments: [ { name: gis-envelope, type: list }, { name: netlogo-envelope, type: list } ]
description: """
Does the same thing as [set-transformation](#gisset-transformation) above, except that
it allows the scale for mapping the range of x values to be
different than the scale for y values. The "-ds" on the
end stands for "different scales". Using different scales
will cause distortion of the shape of GIS features, and so it is
generally not recommended, but it may be useful for some models.
Here is an example of the difference between [set-transformation](#gisset-transformation) and [set-transformation-ds](#gisset-transformation-ds):
<table width="80%" border="1" rules="cols" style="border-collaps: separate; border-spacing: 4px; text-align: center; margin: 0 auto;">
<tr>
<td style="padding: 8px">
<img alt="" src="images/set-transformation.png" width="200">
<td style="padding: 8px">
<img alt="" src="images/set-transformation-ds.png" width="200">
<tr>
<td style="padding: 8px">
Using [set-transformation](#gisset-transformation),
the scale along the x and y axis is the same, preserving the
round shape of the Earth in this Orthographic projection.
<td style="padding: 8px">
Using [set-transformation-ds](#gisset-transformation-ds), the
scale along the x axis is stretched so that the earth covers
the entire NetLogo View, which in this case distorts the shape
of the Earth.
</table>
"""
},
{
name: set-world-envelope,
type: command,
tags: [ "coord" ],
arguments: [ { name: gis-envelope, type: list } ],
description: """
A shorthand for setting the transformation by mapping the envelope
of the NetLogo world to the given envelope in GIS space, while
keeping the scales along the x and y axis the same. It is
equivalent to:
```
set-transformation gis-envelope (list min-pxcor max-pxcor min-pycor max-pycor)
```
This primitive is supplied because most of the time you'll want
to set the envelope of the entire NetLogo world, rather than just a
part of it.
"""
},
{
name: set-world-envelope-ds,
type: command,
tags: [ "coord" ],
arguments: [ { name: gis-envelope, type: list } ],
description: """
A shorthand for setting the transformation by mapping the envelope
of the NetLogo world to the given envelope in GIS space, using
different scales along the x and y axis if necessary. It is
equivalent to:
```
set-transformation-ds gis-envelope (list min-pxcor max-pxcor min-pycor max-pycor)
```
See the [pictures](#transformation-example) above for
the difference between using equal scales for x and y coordinates
and using different scales.
"""
},
{
name: world-envelope,
tags: [ "coord" ],
type: reporter,
returns: list,
description: """
Reports the envelope (bounding rectangle) of the NetLogo world,
transformed into GIS space. An envelope consists of a four-element
list of the form:
```
[minimum-x maximum-x minimum-y maximum-y]
```
"""
},
{
name: envelope-of,
type: reporter,
returns: list,
tags: [ "coord" ],
arguments: [ { name: thing, type: anything } ],
description: """
Reports the envelope (bounding rectangle) of *thing* in GIS
coordinates. The *thing* may be an Agent, an AgentSet, a
RasterDataset, a VectorDataset, or a VectorFeature. An envelope
consists of a four-element list of the form:
```
[minimum-x maximum-x minimum-y maximum-y]
```
"""
},
{
name: envelope-union-of,
type: reporter,
returns: list,
tags: [ "coord" ],
arguments: [ { name: envelope1, type: list }, { name: envelope2, type: list } ],
alternateArguments: [ { name: "envelope1...", type: "repeatable list" } ],
description: """
Reports an envelope (bounding rectangle) that entirely contains the
given envelopes. An envelope consists of a four-element list of the
form
```
[minimum-x maximum-x minimum-y maximum-y]
```
No assumption is made about the coordinate system of the arguments,
though if they are not in the same coordinate system, results will
be unpredictable.
"""
},
{
name: load-coordinate-system,
type: command,
tags: [ "coord" ],
arguments: [ { name: file, type: string } ]
description: """
Loads a new global projection used for projecting or re- projecting
GIS data as it is loaded from a file. The file must contain a valid
<a href="https://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html" target="_blank">
Well-Known Text (WKT)</a> projection description.
WKT projection files are frequently distributed alongside GIS data
files, and usually have a ".prj" filename extension.
Relative paths are resolved relative to the location of the current
model, or the user's home directory if the current model
hasn't been saved yet.
The GIS extension does not support all WKT coordinate systems and
projections. Only geographic (`"GEOGCS"`) and
projected (`"PROJCS"`) coordinate systems are
supported. For projected coordinate systems, only the following
projections are supported:
* Albers_Conic_Equal_Area
* Lambert_Conformal_Conic_2SP
* Polyconic
* Lambert_Azimuthal_Equal_Area
* Mercator_1SP
* Robinson
* Azimuthal_Equidistant
* Miller
* Stereographic
* Cylindrical_Equal_Area
* Oblique_Mercator
* Transverse_Mercator
* Equidistant_Conic
* hotine_oblique_mercator
* Gnomonic
* Orthographic
See <a href="http://remotesensing.org/geotiff/proj_list/" target="_blank">remotesensing.org</a>
for a complete list of WKT projections and their parameters.
"""
},
{
name: set-coordinate-system,
type: command,
tags: [ "coord" ],
arguments: [ { name: system, type: "string or list" } ]
description: """
Sets the global projection used for projecting or re- projecting
GIS data as it is loaded. The *system* must be either a string
in <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html" target="_blank">
Well-Known Text (WKT) format</a>, or a NetLogo list that consists
of WKT converted to a list by moving each keyword inside its
associated brackets and putting quotes around it. The latter is
preferred because it makes the code much more readable.
The same limitations on WKT support apply as described above in the
documentation for [load-coordinate-system](#gisload-coordinate-system)
"""
},
{
name: project-lat-lon,
type: reporter,
tags: [ "coord" ],
arguments: [
{ name: latitude, type: number },
{ name: longitude, type: number }
],
returns: list,
description: """
Report the position, in NetLogo space, of the given latitude
and longitude pair according to the current map projection and
transformation.
Like the `location-of` primitive, the reported xcor and ycor
values are reported in a two-item list of `[xcor ycor]`
and an empty list if the specified point is outside of
the bounds of the netlogo world.
For instance:
```
let location-of-abbey-road-studios gis:project-lat-lon 51.5320787 -0.1802646
let abbey-road-xcor item 0 location-of-abbey-road-studios
let abbey-road-ycor item 1 location-of-abbey-road-studios
```
Note that this primitive assumes that the given lat/lon pair
are relative to the WGS84 datum/ellipsoid. If your
data is based on GPS observations or GeoJson files, then your
data is already relative to WGS84. If you are unsure about
what datum your data is, then you should probably just assume
it is WGS84 and use this primitive. However, if you do know
that your data is relative to a different datum and that
extra degree of precision is important to you (if you are,
say, comparing values from location-of and project-lat-lon)
then you should use `project-lat-lon-from-ellipsoid` and
specify the desired datum's ellipsoid.
"""
},
{
name: project-lat-lon-from-ellipsoid,
type: reporter,
tags: [ "coord" ],
arguments: [
{ name: latitude, type: number },
{ name: longitude, type: number },
{ name: ellipsoid-radius, type: number },
{ name: ellipsoid-inverse-flattening, type: number }
],
returns: list,
description: """
Report the position, in NetLogo space, of the given latitude
and longitude pair according to the current map projection and
transformation and the given ellipsoid parameters.
Like the `location-of` primitive, the reported xcor and ycor
values are reported in a two-item list of `[xcor ycor]`
and an empty list if the specified point is outside of
the bounds of the netlogo world.
The two defining parameters of a ellipsoid for
the purposes of this primitive are the radius and the
inverse flattening metric. These parameters can be
easily found by examining either the WKT definition
of a given projection/datum pair or the .prj file for
the desired datum. For example, if you open the .prj file
for a shapefile exported with the WGS66 datum in a text editor,
you will see, somewhere in the file, this bit of text:
`DATUM["D_WGS_1966",SPHEROID["NWL_9D",6378145,298.25]]`.
If you look at the `SPHEROID` section of that text, the
first number is the radius of that ellipoid and the
second is the inverse flattening.
Once we have these numbers, we can project data that is
relative to WGS66 like so:
```
let location gis:project-lat-lon my-lat my-lon 6378145 298.25
```
For more on earth ellipoids, see: https://en.wikipedia.org/wiki/Earth_ellipsoid
"""
},
{
name: load-dataset,
type: reporter,
reports: "Raster dataset",
tags: [ "data" ],
arguments: [ { name: file, type: string } ]
description: """
Loads the given data file, re-projecting the data as necessary.
Relative paths are resolved relative to the location of the current
model, or the user's home directory if the current model
hasn't been saved yet.
For ESRI shapefiles and ESRI grid files, if there is a ".prj" file
associated with the file, then `load-datset` will consult that file
and re-project to the current global projection if needed. If no ".prj"
file is found, then the data is assumed to use the same projection as
the current global coordinate system.
For GeoJSON files, as per the most-recent specification (RFC 7946),
the coordinate system for GeoJSON files is always WGS84 and will be
imported accordingly.
Currently, three types of data file are supported:
* "**.shp**" (ESRI shapefile): contains vector data,
consisting of points, lines, or polygons. When the target file is a
shapefile, `load-dataset` reports a VectorDataset.
* "**.asc**" or "**.grd**" (ESRI ASCII grid):
contains raster data, consisting of a grid of values. When
the target file is an ASCII grid file, `load-dataset`
reports a RasterDataset.
* "**.geojson**" or "**.json**" (GeoJSON): contains vector data
similar to shapefiles and similarly reports a VectorDataset.
Note that not all aspects of the GeoJSON standard are supported.
In particular, to be properly imported, a GeoJSON file must
satisfy the following:
* It only contain numeric or string data within the properties.
all other json data will be stringified.
* All "Features" within a "FeatureCollection" must be of the same
shape type ("Point", "LineString", etc.) Additionally, if not all
the "Features" in the "FeatureCollection" have the same set of
property names, default values will be supplied where there
are missing entries (0 for numbers and "" for strings.)
* It must not use "GeometryCollection", which is not supported
Elevation/Z data is partially supported. For both .geojson and
.shp files, single points with Z data will have their Z
coordinate moved to a new "_Z" property that can be accessed
with `gis:property-value` like any other property. Any Z
information for other shape types will be discarded upon import.
"""
},
{
name: store-dataset,
type: command,
tags: [ "data" ],
arguments: [ { name: dataset, type: Dataset }, { name: file, type: string } ],
description: """
Exports the given dataset to the given file.
For VectorDatasets, two file formats are supported, ESRI shapefiles
and GeoJSON. If the given file name ends in ".geojson" or ".json",
then the file will be exported as a GeoJSON file. If the file name
ends in any other extension or no extension at all, the dataset
will be exported as a shapefile and the associated file extensions
will be supplied (".shp", ".prj", etc.)
For RasterDatasets, only ESRI ASCII grid files are supported and
the associated file extensions will be automatically supplied.
Relative paths are resolved relative to the location of the current
model, or the user's home directory if the current model hasn't
been saved yet.
"""
},
{
name: type-of,
type: reporter,
returns: string,
tags: [ "data" ],
arguments: [ { name: dataset, type: Dataset } ],
description: """Reports the type of the given GIS dataset: either "VECTOR" or "RASTER""""
},
{
name: patch-dataset,
type: reporter,
reports: "raster",
tags: [ "data" ],
arguments: [ { name: patch-variable, type: reference } ],
description: """
Reports a new raster whose cells correspond directly to NetLogo
patches, and whose cell values consist of the values of the given
patch variable. This primitive is basically the inverse of [apply-raster](#gisapply-raster);
`apply-raster` copies values from a raster dataset to a patch variable, while this
primitive copies values from a patch variable to a raster dataset.
"""
},
{
name: turtle-dataset,
type: reporter,
returns: dataset,
tags: [ "data" ],
arguments: [ { name: turtle-set, type: turtleset } ]
description: """
Reports a new, point VectorDataset built from the turtles in the
given agentset. The points are located at locations of the turtles,
translated from NetLogo space into GIS space using the current
coordinate transformation. And the dataset's properties consist
of all of the turtle variables common to every turtle in the
agentset.
"""
},
{
name: link-dataset
type: reporter,
returns: dataset,
tags: [ "data" ],
arguments: [ { name: link-set, type: linkset } ]
description: """
Reports a new, line VectorDataset built from the links in the given
agentset. The endpoints of each line are at the location of the
turtles connected by each link, translated from NetLogo space into
GIS space using the current coordinate transformation. And the
dataset's properties consist of all of the link variables
common to every link in the agentset.
"""
},
{
name: shape-type-of,
type: reporter,
returns: string,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset } ],
description: """
Reports the shape type of the given dataset. The possible output
values are "POINT", "LINE", and "POLYGON"."""
},
{
name: property-names,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset } ]
description: """
Reports a list of strings where each string is the name of a
property possessed by each VectorFeature in the given
VectorDataset, suitable for use in [gis:property-value](#gisproperty-value).
"""
},
{
name: feature-list-of,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset } ]
description: "Reports a list of all VectorFeatures in the given dataset."
},
{
name: vertex-lists-of,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorFeature, type: feature } ]
description: """
Reports a list of lists of Vertex values. For point datasets, each
vertex list will contain exactly one vertex: the location of a
point. For line datasets, each vertex list will contain at least
two points, and will represent a "polyline", connecting
each adjacent pair of vertices in the list. For polygon datasets,
each vertex list will contain at least three points, representing a
polygon connecting each vertex, and the first and last vertices in
the list will be the same.
"""
},
{
name: centroid-of,
type: reporter,
returns: vertex,
tags: ["vector"],
arguments: [ { name: VectorFeature, type: feature } ],
description: """
Reports a single Vertex representing the centroid (center of
gravity) of the given feature. For point datasets, the centroid is
defined as the average location of all points in the feature. For
line datasets, the centroid is defined as the average of the
locations of the midpoints of all line segments in the feature,
weighted by segment length. For polygon datasets, the centroid is
defined as the weighted sum of the centroids of a decomposition of
the area into (possibly overlapping) triangles. See <a href="http://www.faqs.org/faqs/graphics/algorithms-faq/" target="_blank">this FAQ</a>
for more details on the polygon centroid algorithm.
"""
},
{
name: random-point-inside,
type: reporter,
returs: vertex,
tags: ["vector"],
arguments: [ { name: VectorFeature, type: feature } ],
description: """
Reports a single randomly-generated Vertex that lies within the
given feature polygon. Generated points are uniformly
distributed within the polygon and both polygon holes and
multi-polygon features are supported.
```
; create 100 turtles randomly distributed throught a VectorFeature `vf`
crt 100 [
let loc gis:location-of gis:random-point-inside vf
set xcor item 0 loc
set ycor item 1 loc
]
```
"""
},
{
name: location-of,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: Vertex, type: vertex } ]
description: """
Reports a two-element list containing the x and y values (in that
order) of the given vertex translated into NetLogo world space
using the current transformation, or an empty list if the given
vertex lies outside the NetLogo world.
"""
},
{
name: set-property-value,
tags: ["vector"],
type: command,
arguments: [ { name: VectorFeature, type: feature }, { name: property-name, type: string }, {name: value, type: "string or number"} ]
description: """
Sets the value of the given property of the given VectorFeature. The
type of the given value (string or number) must match the property
type of the VectorFeature. This command may be used in conjunction
with store-dataset to make changes to VectorFeatures and export
them back as GIS datasets.
"""
},
{
name: property-value,
tags: ["vector"],
type: reporter,
returns: anything,
arguments: [ { name: VectorFeature, type: feature }, { name: property-name, type: string } ]
description: """
Reports the value of the property with the given name for the given
VectorDataset. The reported value may be a number, a string, or a
boolean value, depending on the type of the field in the underlying
data file.
For shapefiles, values from dBase `CHARACTER` and
`DATE` fields are returned as strings, values from
`NUMBER` and `FLOAT` fields are returned as numbers,
and values from `LOGICAL` fields are returned as boolean
values. `MEMO` fields are not supported. `DATE`
values are converted to strings using ISO 8601 format
(`YYYY-MM-DD`).
"""
},
{
name: find-features,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string }, { name: specified-value, type: "string or number" } ],
description: """
Reports a list of all VectorFeatures in the given dataset
whose value for the property *property-name* matches
*specified-value* (a string or number).
For strings, value comparison is not case sensitive, and the
wildcard character "*" will match any number of occurrences
(including zero) of any character.
For numbers, beware that there are some numbers that are too
big to be represented as an integer in NetLogo, so integer
data imported into NetLogo may start to lose precision
if they are larger than around 10^14.
"""
},
{
name: find-one-feature,
type: reporter,
returns: feature,
tags: ["vector"],
arguments: [
{ name: VectorDataset, type: dataset },
{ name: property-name, type: string },
{ name: specified-value, type: "string or number" }
],
description: """
Reports the first VectorFeature in the dataset whose value
for the property *property-name* matches the given string or
number. Reports `nobody` if no matching VectorFeature is
found.
For strings, Value comparison is not case sensitive, and the
wildcard character "*" will match any number of occurrences
(including zero) of any character. Features are searched in
the order that they appear in the data file that was the
source of the dataset, and searching stops as soon as a
match is found.
For numbers, beware that there are some numbers that are too
big to be represented as an integer in NetLogo, so if you
want to be able to identify features based on a unique ID,
keep the IDs you use on the relatively small side to play it
safe. Any number that can fit into a 32 bit unsigned integer
will work, but any larger than 10^14 and you could run into
issues. (Helpfully, the NetLogo app will warn you if you try
to type one of these too-large numbers into the editor if
you want to check.)
"""
},
{
name: find-less-than,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string }, { name: value, type: "string or number" } ]
description: """
Reports a list of all VectorFeatures in the given dataset whose
value for the property *property-name* is less than the given
*value*. String values are compared using case-sensitive
lexicographic order as defined in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#compareTo(java.lang.String)" target="_blank">
Java Documentation</a>. Using a string value for a numeric property
or a numeric value for a string property will cause an error.
"""
},
{
name: find-greater-than
tags: ["vector"],
type: reporter,
returns: list,
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string }, { name: value, type: "string or number" } ]
description: """
Reports a list of all VectorFeatures in the given dataset whose
value for the property *property-name* is greater than the
given *value*. String values are compared using case-sensitive
lexicographic order as defined in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#compareTo(java.lang.String)" target="_blank">
Java Documentation</a>. Using a string value for a numeric property
or a numeric value for a string property will cause an error.
"""
},
{
name: find-range,
type: reporter,
returns: list,
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string }, { name: minimum-value, type: "number or string" }, { name: maximum-value, type: "number or string" } ]
description: """
Reports a list of all VectorFeatures in the given dataset whose
value for the property *property-name* is strictly greater
than *minimum-value* and strictly less than
*maximum-value*. String values are compared using
case-sensitive lexicographic order as defined in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#compareTo(java.lang.String)" target="_blank">
Java Documentation</a>. Using a string value for a numeric property
or a numeric value for a string property will cause an error.
"""
},
{
name: property-minimum,
type: reporter,
returns: "number or string",
tags: ["vector"],
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string } ],
description: """
Reports the smallest value for the given property over all of the
VectorFeatures in the given dataset. String values are compared
using case-sensitive lexicographic order as defined in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#compareTo(java.lang.String)" target="_blank">
Java Documentation</a>.
"""
},
{
name: property-maximum
tags: ["vector"],
type: reporter,
returns: "number or string",
arguments: [ { name: VectorDataset, type: dataset }, { name: property-name, type: string } ],
description: """
Reports the largest value for the given property over all of the
VectorFeatures in the given dataset. String values are compared
using case-sensitive lexicographic order as defined in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#compareTo(java.lang.String)" target="_blank">
Java Documentation</a>.
"""
},
{
name: apply-coverage,
type: command,
tags: ["vector"],
arguments: [
{ name: VectorDataset, type: dataset },
{ name: property-name, type: string },
{ name: patch-variable, type: reference }
],
description: """
Copies values from the given property of the VectorDataset's
features to the given patch variable. The dataset must be a
`polygon` dataset; points and lines are not supported.
For each patch, it finds all VectorFeatures that intersect that
patch. Then, if the property is a string property, it computes the
majority value by computing the total area of the patch covered by
VectorFeatures having each possible value of the property, then
returning the value which represents the largest proportion of the
patch area. If the property is a numeric property, it computes a
weighted average of property values from all VectorFeatures which
intersect the patch, weighted by the proportion of the patch area
they cover.
There are two exceptions to this default behavior:
* If a percentage of a patches' area greater than the
coverage-maximum-threshold is covered by a single VectorFeature,
then the property value from that VectorFeature is copied directly.
If more than one VectorFeature covers a percentage of area greater
than the threshold, only the first will be used.
* If the total percentage of a patches' area covered by
VectorFeatures is less than the coverage-minimum-threshold, the
target patch variable is set to Not A Number.
By default, the minimum threshold is 10% and the maximum threshold
is 33%. These values may be modified using the four primitives that
follow.
"""
},
{
name: create-turtles-from-points,
type: command,
tags: ["vector"],
arguments: [
{ name: VectorDataset, type: dataset },
{ name: breed, type: breed },
{ name: commands, type: commandBlock}
],
description: """
For each point in a VectorDataset of points, create a turtle of
the specified breed at the point's location. For each agent variable
(as defined in `<breeds>-own`), if there is a property with the same
name in the dataset, set that variable's value to be the value of
that property. Finally, execute any commands in the optional
command block. To use generic turtles as the chosen breed, simply
supply `turtles` as the breed argument.
Property names and variable names are compared case-insensitively.
Keep in mind that when importing shapefiles, property names may be
modified for backwards compatibility reasons. The names given by
`gis:property-names` can always be trusted as authoritative. For
manually specifying a mapping between property names and variable
names, see the `create-turtles-from-points-manual` primitive.
For multi-point datasets, a turtle is created at each point of
multi-point feature, each with the same set of variable values.
Built-in variables such as "label" and "heading" are supported.
NetLogo color numeric representations are supported for setting
"color" and "label-color", as well as the 15 default color string
representations ("red", "blue", "black", etc.).
As an example: say you wanted to create a turtle of breed
"cities/city" for each city in a dataset of cities
like the one included in the "GIS General Examples" model from
the models library. The cities dataset has four properties,
"NAME", "COUNTRY", "POPULATION", and "CAPITAL". To map them all
to NetLogo turtle variables and set their shapes to circles, you
could do this:
```
extensions [gis]
breed [cities city]
cities-own [name country population capital]
globals [cities-dataset]
to setup
set cities-dataset gis:load-dataset "cities.shp"
gis:create-turtles-from-points cities-dataset cities [
set shape "circle"
]
end
```
"""
},
{
name: create-turtles-from-points-manual,
type: command,
tags: ["vector"],
arguments: [
{ name: VectorDataset, type: dataset },
{ name: breed, type: breed },
{ name: property-mapping, type: list },
{ name: commands, type: commandBlock}
],
description: """
Like `create-turtles-from-points`, creates a turtle for each point in a
VectorDataset of points and populates their variables with the values of
corresponding gis properties.
This primitive can be used to specify
additional mappings between gis property names and NetLogo variable names.
These mappings are specified as a list of lists of strings like so:
`[["property-name" "turtle-variable-name"] ["property-name" "turtle-variable-name"] (etc.)]`
These manual mappings modify the automatic mapping process that takes
place in the `create-turtles-from-points` primitive, so you only need
to specify the changes you want to make to the default mappings, and
the rest of the mappings will be untouched.
To return to the cities example from the
`create-turtles-from-points` entry, the variable name "capital" is not very
descriptive. something like "is-capital?" fits the NetLogo style much better.
To make that change, you would modify the example like so.
```
extensions [gis]
breed [cities city]
cities-own [name country population is-capital?]
globals [cities-dataset]
to setup
set cities-dataset gis:load-dataset "cities.shp"
;; Since we only want to change how the "CAPITAL" property is mapped, we only need to specify that one change.
gis:create-turtles-from-points-manual cities-dataset cities [["CAPITAL" "is-capital?"]] [
set shape "circle"
]
;; Each city turtle still has a name, country, and population set just like the non-manual version.
end
```
"""
},
{
name: create-turtles-inside-polygon,
type: command,
tags: ["vector"],
arguments: [
{ name: VectorFeature, type: feature },
{ name: breed, type: breed },
{ name: n, type: number },
{ name: commands, type: commandBlock}
],
description: """
Randomly create "n" turtles of the given breed within
the given VectorFeature and for each agent variable
(as defined in <breeds>-own), if there is a property with the same
name in the dataset, set that variable's value to be the value of
that property. Finally, execute any commands in the optional
command block. To use generic turtles as the chosen breed, simply
supply `turtles` as the breed argument.
Property names and variable names are compared case-insensitively.
Keep in mind that when importing shapefiles, property names may be
modified for backwards compatibility reasons. The names given by
`gis:property-names` can always be trusted as authoritative. For
manually specifying a mapping between property names and variable
names, see the `create-turtles-inside-polygon-manual` primitive.
Built-in variables such as "label" and "heading" are supported.
NetLogo color numeric representations are supported for setting
"color" and "label-color", as well as the 15 default color string
representations ("red", "blue", "black", etc.).
As an example: say you had a VectorDataset of polygons representing
different zip codes within a state and you want to create 100
different turtles within each zip code and have each turtle
know which zip code it originated in. The VectorDataset
has a field named "zip", so you should add a variable
named "zip" to the turtles with `turtles-own`. Then,
loop through each VectorFeature in the VectorDataset and use
the `create-turtles-inside-polygon` primitive to create 100
new turtles.
```
extensions [gis]
globals [dataset]
turtles-own [zip]
to setup
set dataset gis:load-dataset "dataset.shp"
gis:set-world-envelope envelope-of dataset
gis:set-drawing-color red
gis:draw dataset 1
foreach gis:feature-list-of dataset [ this-vector-feature ->
gis:create-turtles-inside this-vector-feature turtles 100 [
set shape "person"
]
]
end
```
"""
},
{
name: create-turtles-inside-polygon-manual,
type: command,
tags: ["vector"],
arguments: [
{ name: VectorFeature, type: feature },
{ name: breed, type: breed },
{ name: n, type: number },
{ name: property-mapping, type: list },
{ name: commands, type: commandBlock}
],
description: """
Like `create-turtles-inside-polygon`, creates "n" different turtles within the given VectorFeature and populates their
agent variables with values corresponding to the property values of the VectorFeature.
This primitive can be used to specify
additional mappings between gis property names and NetLogo variable names.
These mappings are specified as a list of lists of strings like so:
`[["property-name" "turtle-variable-name"] ["property-name" "turtle-variable-name"] (etc.)]`
These manual mappings modify the automatic mapping process that takes
place in the `create-turtles-inside-polygon` primitive, so you only need
to specify the changes you want to make to the default mappings, and
the rest of the mappings will be untouched.
See the `create-turtles-from-points-manual` entry for an example of
how to override default mappings with manual ones.
"""
},
{
name: coverage-minimum-threshold,
type: reporter,
returns: number,
tags: ["vector"],
description: """Reports the current coverage minimum threshold used by [gis:apply-coverage](#gisapply-coverage)."""
},
{
name: set-coverage-minimum-threshold,
type: command,
tags: ["vector"],
arguments: [ { name: new-threshold, type: number } ]
description: """Sets the current coverage minimum threshold to be used by [gis:apply-coverage](#gisapply-coverage)."""
},
{
name: coverage-maximum-threshold,
type: reporter,
returns: number,
tags: ["vector"],
description: """Reports the current coverage maximum threshold used by [gis:apply-coverage](#gisapply-coverage)."""