sukri12 / pysal

Automatically exported from code.google.com/p/pysal
Other
0 stars 0 forks source link

Research Shapely Compatibility #165

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Research what it would take to make pysal spatial objects compatible with 
Shapely and/or other external GIS libraries.  This would allow pysal users to 
use pysal object in shapely and shapely objects in pysal. This would eliminate 
the need for us to implement our own spatial operations.

Original issue reported on code.google.com by schmi...@gmail.com on 11 Aug 2011 at 6:35

GoogleCodeExporter commented 8 years ago
Integration with shapely isn't possible by simply implementing their shape 
interface.  Spatial operations in shapely are methods of the spatial objects 
themselves and are not exposed as standalone functions. Thus using shapely 
requires a multistep process, 
1.) Convert PySAL spatial object to Shapely object (via, WKT/WKB, numpy array 
interface (no polygon support), a GeoJSON (dictionary) like interface, or 
Shapely __geo_interface__)
2.) Perform the spatial operation.
3.) Convert the shapely object back into a PySAL object.

Without creating a dependency on shapely true integration with the library 
becomes difficult as we'd need to create 2 version of our CG library, one for 
those with shapely and one for those without, while ensuring that both versions 
conform to the same internal API.

A few options to move forward...
1. Add shapely as a required dependency. (not recommended, shapely is still a 
young library with a relatively difficult install process.)
2. Use an import try/except to detect shapely and provide spatial operation 
methods when present. 
3. Create a relatively painless pathway for users to cross between the two 
libraries such as implementing the GeoJSON like adapters or the 
__geo_interface__.
4. Move forward with a pure python CG library.
5. Fork Shapely and modify it such that pysal's objects can be passed directly 
to GEOS making it a truly optional dependancy.

Original comment by schmi...@gmail.com on 16 Aug 2011 at 6:41