Querying Distance to a Polygon

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Querying Distance to a Polygon

Grant, Tyler J [NREM]

Hi,

 

Monarchs can apparently smell their host plant, milkweed, from some distance, at least 100 to 150 m.  So I want to query all the polygons within some distance, say 100 m, of the agent.  I can do this with GeographyWithin(), I assume, but is there a way to determine the distance and heading to the nearest edge of the polygons?  I want to determine the probability they fly towards a particular polygon as a function of distance and milkweed density.  Then I need the heading for them to fly in that direction. 

 

Thanks,

Tyler

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Querying Distance to a Polygon

Tatara, Eric R.

All of the underlying geometry calculations are supported by the JTS library and it seems like they might have some support classes that will give you the distance between two geometries along with the pair of closest points in each.   You can use Geometry.distance(Geometry g) to calculate the minimal distance between two geometries.  There is another class DistanceOp (http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/operation/distance/DistanceOp.html) that also looks useful.  It seems like you just create a DisanceOp from two geometries and then use it to calculate both distance and get an array of the closest points.  I haven’t used this before, but it looks like the closestPoints()  method will give you a vector of Coordinates, one for each of the input geometries.  You can then calculate the heading based on the x,y in each coordinate.

 

eric

 

From: Grant, Tyler J [NREM] [mailto:[hidden email]]
Sent: Wednesday, November 04, 2015 1:48 PM
To: [hidden email]
Cc: Demuth, Gabriel O [STAT] <[hidden email]>
Subject: [Repast-interest] Querying Distance to a Polygon

 

Hi,

 

Monarchs can apparently smell their host plant, milkweed, from some distance, at least 100 to 150 m.  So I want to query all the polygons within some distance, say 100 m, of the agent.  I can do this with GeographyWithin(), I assume, but is there a way to determine the distance and heading to the nearest edge of the polygons?  I want to determine the probability they fly towards a particular polygon as a function of distance and milkweed density.  Then I need the heading for them to fly in that direction. 

 

Thanks,

Tyler

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 


------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Querying Distance to a Polygon

Grant, Tyler J [NREM]

Hi,

 

The DistanceOp class returns the distance in lat/long degree units.  Converting this to meters is not simple because the conversion factor varies by latitude of course.  So I’ve been looking for a class that converts this to meters, but haven’t had any luck yet.  Does anyone know of such a class?

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 

From: Tatara, Eric R. [mailto:[hidden email]]
Sent: Wednesday, November 04, 2015 4:23 PM
To: Grant, Tyler J [NREM] <[hidden email]>; [hidden email]
Cc: Demuth, Gabriel O [STAT] <[hidden email]>
Subject: RE: Querying Distance to a Polygon

 

All of the underlying geometry calculations are supported by the JTS library and it seems like they might have some support classes that will give you the distance between two geometries along with the pair of closest points in each.   You can use Geometry.distance(Geometry g) to calculate the minimal distance between two geometries.  There is another class DistanceOp (http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/operation/distance/DistanceOp.html) that also looks useful.  It seems like you just create a DisanceOp from two geometries and then use it to calculate both distance and get an array of the closest points.  I haven’t used this before, but it looks like the closestPoints()  method will give you a vector of Coordinates, one for each of the input geometries.  You can then calculate the heading based on the x,y in each coordinate.

 

eric

 

From: Grant, Tyler J [NREM] [[hidden email]]
Sent: Wednesday, November 04, 2015 1:48 PM
To: [hidden email]
Cc: Demuth, Gabriel O [STAT] <[hidden email]>
Subject: [Repast-interest] Querying Distance to a Polygon

 

Hi,

 

Monarchs can apparently smell their host plant, milkweed, from some distance, at least 100 to 150 m.  So I want to query all the polygons within some distance, say 100 m, of the agent.  I can do this with GeographyWithin(), I assume, but is there a way to determine the distance and heading to the nearest edge of the polygons?  I want to determine the probability they fly towards a particular polygon as a function of distance and milkweed density.  Then I need the heading for them to fly in that direction. 

 

Thanks,

Tyler

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Querying Distance to a Polygon

Tatara, Eric R.
It looks like JTS.orthodromicDistance(...) will provide the correct distance in meters from two Coordinates along the surface of the Earth:

http://docs.geotools.org/latest/javadocs/org/geotools/geometry/jts/JTS.html

You will need to first get the pair of closest points from the DistanceOp, and then use JTS.orthodromicDistance() to get the distance.

eric

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory


From: Grant, Tyler J [NREM] [[hidden email]]
Sent: Friday, December 04, 2015 1:07 PM
To: Tatara, Eric R.; [hidden email]
Cc: Demuth, Gabriel O [STAT]
Subject: RE: Querying Distance to a Polygon

Hi,

 

The DistanceOp class returns the distance in lat/long degree units.  Converting this to meters is not simple because the conversion factor varies by latitude of course.  So I’ve been looking for a class that converts this to meters, but haven’t had any luck yet.  Does anyone know of such a class?

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 

From: Tatara, Eric R. [mailto:[hidden email]]
Sent: Wednesday, November 04, 2015 4:23 PM
To: Grant, Tyler J [NREM] <[hidden email]>; [hidden email]
Cc: Demuth, Gabriel O [STAT] <[hidden email]>
Subject: RE: Querying Distance to a Polygon

 

All of the underlying geometry calculations are supported by the JTS library and it seems like they might have some support classes that will give you the distance between two geometries along with the pair of closest points in each.   You can use Geometry.distance(Geometry g) to calculate the minimal distance between two geometries.  There is another class DistanceOp (http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/operation/distance/DistanceOp.html) that also looks useful.  It seems like you just create a DisanceOp from two geometries and then use it to calculate both distance and get an array of the closest points.  I haven’t used this before, but it looks like the closestPoints()  method will give you a vector of Coordinates, one for each of the input geometries.  You can then calculate the heading based on the x,y in each coordinate.

 

eric

 

From: Grant, Tyler J [NREM] [[hidden email]]
Sent: Wednesday, November 04, 2015 1:48 PM
To: [hidden email]
Cc: Demuth, Gabriel O [STAT] <[hidden email]>
Subject: [Repast-interest] Querying Distance to a Polygon

 

Hi,

 

Monarchs can apparently smell their host plant, milkweed, from some distance, at least 100 to 150 m.  So I want to query all the polygons within some distance, say 100 m, of the agent.  I can do this with GeographyWithin(), I assume, but is there a way to determine the distance and heading to the nearest edge of the polygons?  I want to determine the probability they fly towards a particular polygon as a function of distance and milkweed density.  Then I need the heading for them to fly in that direction. 

 

Thanks,

Tyler

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest