Skip to content

Feature request: gis:min-distance-of primitive to compute minimum distance between GeoFeatures #52

@EwoutH

Description

@EwoutH

Summary

Add a gis:min-distance-of reporter that returns the minimum geometric distance between a target geometry (a VectorFeature or NetLogo agent with a GIS geometry) and any member of a collection (a VectorDataset or an agentset). Distance follows the units of the active GIS projection (e.g., meters if projected, degrees if unprojected lat/lon). Returns 0 when geometries touch or intersect.

This feature request builds on the work started in PR #46, and #17, #18 and #19, originally written by @josephzhao.

Proposed API

gis:min-distance-of <collection> <target>  ;; -> number

Parameters

  • <collection>: VectorDataset | agentset
  • <target>: VectorFeature | agent (turtle/link/patch) that has a GIS geometry

Return value

  • Minimum JTS geometry distance between <target> and any geometry in <collection>.

Example usage

extensions [ gis ]

to setup
  ca
  set roads-ds gis:load-dataset "roads.shp"
  ; ensure appropriate projection/transform is set for meaningful units
end

to-report dist-to-roads [car]
  report gis:min-distance-of roads-ds car
end

to-report nearest-obstacle-dist [peds]
  ; peds is an agentset of pedestrian turtles
  let d gis:min-distance-of peds one-of cars
  report d
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions