NetLogo 7.0.0-beta2:

gis:have-relationship?

gis:have-relationship? x y

Reports true if the spatial representations of the two objects have the given spatial relationship, and false otherwise. The spatial relationship is specified using a Dimensionally Extended Nine- Intersection Model (DE-9IM) matrix. The matrix consists of 9 elements, each of which specifies the required relationship between the two objects’ interior space, boundary space, or exterior space. The elements must have one of six possible values:

  • “T”, meaning the spaces must intersect in some way
  • “F”, meaning the spaces must not intersect in any way
  • “0”, meaning the dimension of the spaces’ intersection must be zero (i.e., it must be a point or non-empty set of points).
  • “1”, meaning the dimension of the spaces’ intersection must be one (i.e., it must be a line or non-empty set of line segments).
  • “2”, meaning the dimension of the spaces’ intersection must be two (i.e., it must be a polygon or set of polygons whose area is greater than zero).
  • “*”, meaning that the two spaces may have any relationship.

For example, this matrix:

x
Interior Boundary Exterior
y Interior T * *
Boundary * * *
Exterior F F *

would return true if and only if some part of object x’s interior lies inside object y’s interior, and no part of object x’s interior or boundary intersects object y’s exterior. This is essentially a more restrictive form of the contains? primitive; one in which polygons are not considered to contain their boundaries.

The matrix is given to the have-relationship? primitive as a string, whose elements are given in the following order:

1 2 3
4 5 6
7 8 9

So to use the example matrix above, you would write:

gis:have-relationship? x y "T*****FF*"

A much more detailed and formal description of the DE-9IM matrix and the associated point-set theory can be found in the OpenGIS Simple Features Specification for SQL.

The objects x and y may be any one of:

  • a VectorDataset, in which case the object’s spatial representation is the union of all the points, lines, or polygons the dataset contains.
  • a VectorFeature, in which case the object’s spatial representation is defined by the point, line, or polygon the feature contains.
  • A turtle, in which case the spatial representation is a point.
  • A link, whose spatial representation is a line segment connecting the two points represented by the turtles the link is connecting.
  • A patch, whose spatial representation is a rectangular polygon.
  • An agentset, whose spatial representation is the union of the representations of all of the agents it contains.
  • A list containing of any of the items listed here, including another list. The spatial representation of such a list is the union of the spatial representations of its contents.

Take me to the full GIS Extension Dictionary