[AstroPy] Spherical point in polygon test?

Chris Beaumont beaumont at hawaii.edu
Wed May 7 13:53:39 EDT 2014


Thanks everyone. Mike is right that I need something that handles spherical
geometry correctly and, once Christine pointed me to a source URL, the
stsci.sphere package works well.

Two followup questions:

- Should stsci.sphere be on PyPI? It appears to be a blank upload at the
moment https://pypi.python.org/pypi/stsci.sphere
- Can stsci.sphere (or scikit learn, or something else) be used to do
efficient nearest neighbor searches?

Thanks,
Chris


On Wed, May 7, 2014 at 5:09 AM, Michael Droettboom <mdroe at stsci.edu> wrote:

>  The Polygon package is for 2D, not spherical, polygons.  Sometimes the
> approximation doesn't matter, and you can project from one into the other,
> preserving area etc.  However, in some cases it's important to stay in
> spherical space, particularly when the polygon is large or the extent of it
> isn't known up front (for example, when doing mosaicing from a large
> database of images).
>
> I'm the author of the stsci.sphere package, which does work with spherical
> polygons in vector space natively.
>
> With it, you can do:
>
> ```
> >>> from sphere import SphericalPolygon
> >>> from sphere import vector
> >>> polygon = SphericalPolygon.from_radec(...)
> >>> x, y, z = vector.radec_to_vector(...)
> >>> polygon.point_inside(x, y, z)
> ```
>
> Mike
>
>
> On 05/06/2014 08:36 PM, JJ Kavelaars wrote:
>
> https://pypi.python.org/pypi/Polygon/2.0.4
>
>  Or version 3 if you are python3. Works well. Has reasonable set of
> geometric functions. CONTAINs and OVERLAPs IIRC. I use this a few times a
> year.
>
> JJ
>
> On May 6, 2014, at 5:10 PM, Christine Slocum <cslocum at stsci.edu> wrote:
>
>   I can't answer the first question, but you can find the source here:
>
> https://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk/
>
> Christine
>
>  ------------------------------
> *From:* astropy-bounces at scipy.org [astropy-bounces at scipy.org] on behalf
> of Chris Beaumont [beaumont at hawaii.edu]
> *Sent:* Tuesday, May 06, 2014 7:58 PM
> *To:* astropy
> *Subject:* [AstroPy] Spherical point in polygon test?
>
>  What's the easiest way to compute whether a set of lat/lon points is
> inside a spherical quad on the sky?
>
>  This package claims to do it, but I can't seem to find a good place to
> download the source
> http://ssb.stsci.edu/doc/stsci_python_dev/stsci.sphere.doc/html/
>
>  Ideas?
> Chris
>
>  _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
>
> _______________________________________________
> AstroPy mailing listAstroPy at scipy.orghttp://mail.scipy.org/mailman/listinfo/astropy
>
>
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> http://www.droettboom.com
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>


-- 
*************************************
Chris Beaumont
Senior Software Engineer
Harvard Center for Astrophysics
60 Garden Street, MS 42
Cambridge, MA 02138
chrisbeaumont.org
*************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140507/567f8995/attachment.html>


More information about the AstroPy mailing list