Gathering the Boundary of a GIS shape by using all of its constituent components.

| Aug 20, 2020 min read

Warning: This post is totally obscure.

I've been doing a ton of work in Repast Simphony lately for a client project. The other day I was modeling some municipal regulatory body influence on my agents and realized that one of my data inputs doesn't come with a block group identifier (to tie it to something like a neighborhood.)

I do however have another set of data that includes latitude, longitude and block group id so I had a thought: What if I simply aggregate the one set by finding whether the agents in that set lay within the bounding area of the block groups as defined by the other?

Repast includes the jar for JTS, which, has a ton of tools, but the documentation really needs some help. It took me a lot longer to find the solution I wanted but it ended up being a matter of stepping through all of the method calls on most of the geometry objects to find one that led me to Delaunay.

// class Neighborhood...
public void generatePolygon() {
  GeometryFactory factory = new GeometryFactory();
  this.envelope = DelaunayTriangulationBuilder.envelope(this.points());
}

This method assumes that points() returns a list of JTS coordinates; they don't need to be ordered, they don't need to loop-back, it's just a glob of points in space. The envelope method returns just the boundary. The naming convention didn't jibe with my past experience but I'm still learning the deeper taxonomy of GIS. With that chunk of code you can do something like:

if (neighborhood.envelope.contains(myAgent.getCoordinate()) {
  neighborhood.interestingAgents.add(myAgent);
}

Hopefully someone will stumble across this one and save themselves half a day.