pax_global_header 0000666 0000000 0000000 00000000064 12606105165 0014514 g ustar 00root root 0000000 0000000 52 comment=f8f3f2998313a751d2ce376bb6bbbe010b12e2d1
Shapely-1.5.13/ 0000775 0000000 0000000 00000000000 12606105165 0013210 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/.gitignore 0000664 0000000 0000000 00000000236 12606105165 0015201 0 ustar 00root root 0000000 0000000 *.pyc
*.pyo
*.c
*.so
VERSION.txt
Shapely.egg-info/
build/
dist/
docs/_build/
docs/shapely.*.txt
docs/shapely.txt
docs/modules.txt
.cache/
.idea/
*.pyd
*.pdb
Shapely-1.5.13/.travis.yml 0000664 0000000 0000000 00000001104 12606105165 0015315 0 ustar 00root root 0000000 0000000 language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
env:
- "TRAVIS_SPEEDUP_OPTS=--with-speedups"
- "TRAVIS_SPEEDUP_OPTS="
before_install:
- sudo add-apt-repository -y ppa:ubuntugis/ppa
- sudo apt-get update -qq
- sudo apt-get install -qq libgeos-dev python-numpy
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install unittest2; fi
- pip install --install-option="--no-cython-compile" cython
- pip install -r requirements-dev.txt
install:
- pip install -e .
script: "py.test tests ${TRAVIS_SPEEDUP_OPTS}"
notifications:
email: false
Shapely-1.5.13/CHANGES.txt 0000664 0000000 0000000 00000027001 12606105165 0015021 0 ustar 00root root 0000000 0000000 Changes
=======
1.5.13 (2015-10-09)
-------------------
- Restore setup and runtime discovery and loading of GEOS shared library to
state at version 1.5.9 (#326).
- On OS X we try to reuse any GEOS shared library that may have been loaded
via import of Fiona or Rasterio in order to avoid a bug involving the
GEOS AbstractSTRtree (#324, #327).
1.5.12 (2015-08-27)
-------------------
- Remove configuration of root logger from libgeos.py (#312).
- Skip test_fallbacks on Windows (#308).
- Call setlocale(locale.LC_ALL, "") instead of resetlocale() on Windows when
tearing down the locale test (#308).
- Fix for Sphinx warnings (#309).
- Addition of .cache, .idea, .pyd, .pdb to .gitignore (#310).
1.5.11 (2015-08-23)
-------------------
- Remove packaging module requirement added in 1.5.10 (#305). Distutils can't
parse versions using 'rc', but if we stick to 'a' and 'b' we will be fine.
1.5.10 (2015-08-22)
-------------------
- Monkey patch affinity module by absolute reference (#299).
- Raise TopologicalError in relate() instead of crashing (#294, #295, #303).
1.5.9 (2015-05-27)
------------------
- Fix for 64 bit speedups compatibility (#274).
1.5.8 (2015-04-29)
------------------
- Setup file encoding bug fix (#254).
- Support for pyinstaller (#261).
- Major prepared geometry operation fix for Windows (#268, #269).
- Major fix for OS X binary wheel (#262).
1.5.7 (2015-03-16)
------------------
- Test and fix buggy error and notice handlers (#249).
1.5.6 (2015-02-02)
------------------
- Fix setup regression (#232, #234).
- SVG representation improvements (#233, #237).
1.5.5 (2015-01-20)
------------------
- MANIFEST changes to restore _geox.pxi (#231).
1.5.4 (2015-01-19)
------------------
- Fixed OS X binary wheel library load path (#224).
1.5.3 (2015-01-12)
------------------
- Fixed ownership and potential memory leak in polygonize (#223).
- Wider release of binary wheels for OS X.
1.5.2 (2015-01-04)
------------------
- Fail installation if GEOS dependency is not met, preventing update breakage
(#218, #219).
1.5.1 (2014-12-04)
------------------
- Restore geometry hashing (#209).
1.5.0 (2014-12-02)
------------------
- Affine transformation speedups (#197).
- New `==` rich comparison (#195).
- Geometry collection constructor (#200).
- ops.snap() backed by GEOSSnap (#201).
- Clearer exceptions in cases of topological invalidity (#203).
1.4.4 (2014-11-02)
------------------
- Proper conversion of numpy float32 vals to coords (#186).
1.4.3 (2014-10-01)
------------------
- Fix for endianness bug in WKB writer (#174).
1.4.2 (2014-09-29)
------------------
- Fix bungled 1.4.1 release (#176).
1.4.1 (2014-09-23)
------------------
- Return of support for GEOS 3.2 (#176, #178).
1.4.0 (2014-09-08)
------------------
- SVG representations for IPython's inline image protocol.
- Efficient and fast vectorized contains().
- Change mitre_limit default to 5.0; raise ValueError with 0.0 (#139).
- Allow mix of tuples and Points in sped-up LineString ctor (#152).
- New STRtree class (#73).
- Add ops.nearest_points() (#147).
- Faster creation of geometric objects from others (cloning) (#165).
- Removal of tests from package.
1.3.3 (2014-07-23)
------------------
- Allow single-part geometries as argument to ops.cacaded_union() (#135).
- Support affine transformations of LinearRings (#112).
1.3.2 (2014-05-13)
------------------
- Let LineString() take a sequence of Points (#130).
1.3.1 (2014-04-22)
------------------
- More reliable proxy cleanup on exit (#106).
- More robust DLL loading on all platforms (#114).
1.3.0 (2013-12-31)
------------------
- Include support for Python 3.2 and 3.3 (#56), minimum version is now 2.6.
- Switch to GEOS WKT/WKB Reader/Writer API, with defaults changed to enable 3D
output dimensions, and to 'trim' WKT output for GEOS >=3.3.0.
- Use GEOS version instead of GEOS C API version to determine library
capabilities (#65).
1.2.19 (2013-12-30)
-------------------
- Add buffering style options (#55).
1.2.18 (2013-07-23)
--------------------
- Add shapely.ops.transform.
- Permit empty sequences in collection constructors (#49, #50).
- Individual polygons in MultiPolygon.__geo_interface__ are changed to tuples
to match Polygon.__geo_interface__ (#51).
- Add shapely.ops.polygonize_full (#57).
1.2.17 (2013-01-27)
-------------------
- Avoid circular import between wkt/wkb and geometry.base by moving calls
to GEOS serializers to the latter module.
- Set _ndim when unpickling (issue #6).
- Don't install DLLs to Python's DLL directory (#37).
- Add affinity module of affine transformation (#31).
- Fix NameError that blocked installation with PyPy (#40, #41).
1.2.16 (2012-09-18)
-------------------
- Add ops.unary_union function.
- Alias ops.cascaded_union to ops.unary_union when GEOS CAPI >= (1,7,0).
- Add geos_version_string attribute to shapely.geos.
- Ensure parent is set when child geometry is accessed.
- Generate _speedups.c using Cython when building from repo when missing,
stale, or the build target is "sdist".
- The is_simple predicate of invalid, self-intersecting linear rings now
returns ``False``.
- Remove VERSION.txt from repo, it's now written by the distutils setup script
with value of shapely.__version__.
1.2.15 (2012-06-27)
-------------------
- Eliminate numerical sensitivity in a method chaining test (Debian bug
#663210).
- Account for cascaded union of random buffered test points being a polygon
or multipolygon (Debian bug #666655).
- Use Cython to build speedups if it is installed.
- Avoid stumbling over SVN revision numbers in GEOS C API version strings.
1.2.14 (2012-01-23)
-------------------
- A geometry's coords property is now sliceable, yielding a list of coordinate
values.
- Homogeneous collections are now sliceable, yielding a new collection of the
same type.
1.2.13 (2011-09-16)
-------------------
- Fixed errors in speedups on 32bit systems when GEOS references memory above
2GB.
- Add shapely.__version__ attribute.
- Update the manual.
1.2.12 (2011-08-15)
-------------------
- Build Windows distributions with VC7 or VC9 as appropriate.
- More verbose report on failure to speed up.
- Fix for prepared geometries broken in 1.2.11.
- DO NOT INSTALL 1.2.11
1.2.11 (2011-08-04)
-------------------
- Ignore AttributeError during exit.
- PyPy 1.5 support.
- Prevent operation on prepared geometry crasher (#12).
- Optional Cython speedups for Windows.
- Linux 3 platform support.
1.2.10 (2011-05-09)
-------------------
- Add optional Cython speedups.
- Add is_cww predicate to LinearRing.
- Add function that forces orientation of Polygons.
- Disable build of speedups on Windows pending packaging work.
1.2.9 (2011-03-31)
------------------
- Remove extra glob import.
- Move examples to shapely.examples.
- Add box() constructor for rectangular polygons.
- Fix extraneous imports.
1.2.8 (2011-12-03)
------------------
- New parallel_offset method (#6).
- Support for Python 2.4.
1.2.7 (2010-11-05)
------------------
- Support for Windows eggs.
1.2.6 (2010-10-21)
------------------
- The geoms property of an empty collection yields [] instead of a ValueError
(#3).
- The coords and geometry type sproperties have the same behavior as above.
- Ensure that z values carry through into products of operations (#4).
1.2.5 (2010-09-19)
------------------
- Stop distributing docs/_build.
- Include library fallbacks in test_dlls.py for linux platform.
1.2.4 (2010-09-09)
------------------
- Raise AttributeError when there's no backend support for a method.
- Raise OSError if libgeos_c.so (or variants) can't be found and loaded.
- Add geos_c DLL loading support for linux platforms where find_library doesn't
work.
1.2.3 (2010-08-17)
------------------
- Add mapping function.
- Fix problem with GEOSisValidReason symbol for GEOS < 3.1.
1.2.2 (2010-07-23)
------------------
- Add representative_point method.
1.2.1 (2010-06-23)
------------------
- Fixed bounds of singular polygons.
- Added shapely.validation.explain_validity function (#226).
1.2 (2010-05-27)
----------------
- Final release.
1.2rc2 (2010-05-26)
-------------------
- Add examples and tests to MANIFEST.in.
- Release candidate 2.
1.2rc1 (2010-05-25)
-------------------
- Release candidate.
1.2b7 (2010-04-22)
------------------
- Memory leak associated with new empty geometry state fixed.
1.2b6 (2010-04-13)
------------------
- Broken GeometryCollection fixed.
1.2b5 (2010-04-09)
------------------
- Objects can be constructed from others of the same type, thereby making
copies. Collections can be constructed from sequences of objects, also making
copies.
- Collections are now iterators over their component objects.
- New code for manual figures, using the descartes package.
1.2b4 (2010-03-19)
------------------
- Adds support for the "sunos5" platform.
1.2b3 (2010-02-28)
------------------
- Only provide simplification implementations for GEOS C API >= 1.5.
1.2b2 (2010-02-19)
------------------
- Fix cascaded_union bug introduced in 1.2b1 (#212).
1.2b1 (2010-02-18)
------------------
- Update the README. Remove cruft from setup.py. Add some version 1.2 metadata
regarding required Python version (>=2.5,<3) and external dependency
(libgeos_c >= 3.1).
1.2a6 (2010-02-09)
------------------
- Add accessor for separate arrays of X and Y values (#210).
TODO: fill gap here
1.2a1 (2010-01-20)
------------------
- Proper prototyping of WKB writer, and avoidance of errors on 64-bit systems
(#191).
- Prototype libgeos_c functions in a way that lets py2exe apps import shapely
(#189).
1.2 Branched (2009-09-19)
1.0.12 (2009-04-09)
-------------------
- Fix for references held by topology and predicate descriptors.
1.0.11 (2008-11-20)
-------------------
- Work around bug in GEOS 2.2.3, GEOSCoordSeq_getOrdinate not exported properly
(#178).
1.0.10 (2008-11-17)
-------------------
- Fixed compatibility with GEOS 2.2.3 that was broken in 1.0.8 release (#176).
1.0.9 (2008-11-16)
------------------
- Find and load MacPorts libgeos.
1.0.8 (2008-11-01)
------------------
- Fill out GEOS function result and argument types to prevent faults on a
64-bit arch.
1.0.7 (2008-08-22)
------------------
- Polygon rings now have the same dimensions as parent (#168).
- Eliminated reference cycles in polygons (#169).
1.0.6 (2008-07-10)
------------------
- Fixed adaptation of multi polygon data.
- Raise exceptions earlier from binary predicates.
- Beginning distributing new windows DLLs (#166).
1.0.5 (2008-05-20)
------------------
- Added access to GEOS polygonizer function.
- Raise exception when insufficient coordinate tuples are passed to LinearRing
constructor (#164).
1.0.4 (2008-05-01)
------------------
- Disentangle Python and topological equality (#163).
- Add shape(), a factory that copies coordinates from a geo interface provider.
To be used instead of asShape() unless you really need to store coordinates
outside shapely for efficient use in other code.
- Cache GEOS geometries in adapters (#163).
1.0.3 (2008-04-09)
------------------
- Do not release GIL when calling GEOS functions (#158).
- Prevent faults when chaining multiple GEOS operators (#159).
1.0.2 (2008-02-26)
------------------
- Fix loss of dimensionality in polygon rings (#155).
1.0.1 (2008-02-08)
------------------
- Allow chaining expressions involving coordinate sequences and geometry parts
(#151).
- Protect against abnormal use of coordinate accessors (#152).
- Coordinate sequences now implement the numpy array protocol (#153).
1.0 (2008-01-18)
----------------
- Final release.
1.0 RC2 (2008-01-16)
--------------------
- Added temporary solution for #149.
1.0 RC1 (2008-01-14)
--------------------
- First release candidate
Shapely-1.5.13/CREDITS.txt 0000664 0000000 0000000 00000003277 12606105165 0015057 0 ustar 00root root 0000000 0000000 Credits
=======
Shapely is written by:
* Sean Gillies
* Aron Bierbaum
* Kai Lautaportti
* Oliver Tonnhofer
Patches contributed by:
* Allan Adair (https://github.com/allanadair)
* Joshua Arnott (https://github.com/snorfalorpagus)
* David Baumgold (https://github.com/singingwolfboy)
* Howard Butler
* Gabi Davar (https://github.com/mindw)
* Phil Elson (https://github.com/pelson)
* Johan Euphrosine (https://github.com/proppy)
* Bertrand Gervais (https://github.com/BertrandGervais)
* Marc Jansen (https://github.com/marcjansen)
* Kelsey Jordahl (https://github.com/kjordahl)
* Frédéric Junod
* Thomas Kluyver (https://github.com/takluyver)
* William Kyngesburye (https://github.com/kyngchaos)
* Eric Lemoine
* Naveen Michaud-Agrawal (https://github.com/nmichaud)
* om-henners (https://github.com/om-henners)
* psagers https://github.com/psagers
* Jeethu Rao (https://github.com/jeethu)
* Benjamin Root (https://github.com/WeatherGod)
* Jason Sanford (https://github.com/JasonSanford)
* Johannes Schönberger (https://github.com/ahojnnes)
* Jonathan Tartley
* Kristian Thy
* Mike Toews (https://github.com/mwtoews)
* Maarten Vermeyen (https://github.com/maarten-vermeyen)
* Jacob Wasserman (https://github.com/jwass)
* Brandon Wood (https://github.com/woodb)
See also: https://github.com/Toblerity/Shapely/graphs/contributors.
Additional help from:
* Justin Bronn (GeoDjango) for ctypes inspiration
* Martin Davis (JTS)
* Jaakko Salli for the Windows distributions
* Sandro Santilli, Mateusz Loskot, Paul Ramsey, et al (GEOS Project)
Major portions of this work were supported by a grant (for Pleiades_) from the
U.S. National Endowment for the Humanities (http://www.neh.gov).
.. _Pleiades: http://pleiades.stoa.org
Shapely-1.5.13/DLLs_AMD64_VC9/ 0000775 0000000 0000000 00000000000 12606105165 0015322 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/DLLs_AMD64_VC9/README.txt 0000664 0000000 0000000 00000000013 12606105165 0017012 0 ustar 00root root 0000000 0000000 AMD64 DLLs
Shapely-1.5.13/DLLs_x86_VC7/ 0000775 0000000 0000000 00000000000 12606105165 0015172 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/DLLs_x86_VC7/README.txt 0000664 0000000 0000000 00000000011 12606105165 0016660 0 ustar 00root root 0000000 0000000 x86 DLLs
Shapely-1.5.13/DLLs_x86_VC9/ 0000775 0000000 0000000 00000000000 12606105165 0015174 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/DLLs_x86_VC9/README.txt 0000664 0000000 0000000 00000000011 12606105165 0016662 0 ustar 00root root 0000000 0000000 x86 DLLs
Shapely-1.5.13/GEOS-C-API.txt 0000664 0000000 0000000 00000006007 12606105165 0015300 0 ustar 00root root 0000000 0000000 Ctypes declarations for functions present in GEOS C API 1.4, but not present in
1.3, are listed below:
lgeos.GEOS_getWKBOutputDims.restype = ctypes.c_int
lgeos.GEOS_getWKBByteOrder.restype = ctypes.c_int
lgeos.GEOS_setWKBByteOrder.restype = ctypes.c_int
lgeos.GEOS_setWKBByteOrder.argtypes = [ctypes.c_int]
lgeos.GEOSGeomFromHEX_buf.restype = ctypes.c_void_p
lgeos.GEOSGeomFromHEX_buf.argtypes = [ctypes.c_void_p, ctypes.c_size_t]
lgeos.GEOSSimplify.restype = ctypes.c_void_p
lgeos.GEOSSimplify.argtypes = [ctypes.c_void_p, ctypes.c_double]
lgeos.GEOSTopologyPreserveSimplify.restype = ctypes.c_void_p
lgeos.GEOSTopologyPreserveSimplify.argtypes = [ctypes.c_void_p, ctypes.c_double]
lgeos.GEOSEqualsExact.restype = ctypes.c_int
lgeos.GEOSEqualsExact.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_double]
lgeos.GEOSNormalize.restype = ctypes.c_int
lgeos.GEOSNormalize.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKTReader_create.restype = ctypes.c_void_p
lgeos.GEOSWKTReader_destroy.restype = None
lgeos.GEOSWKTReader_destroy.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKTReader_read.restype = ctypes.c_void_p
lgeos.GEOSWKTReader_read.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
lgeos.GEOSWKTWriter_create.restype = ctypes.c_void_p
lgeos.GEOSWKTWriter_destroy.restype = None
lgeos.GEOSWKTWriter_destroy.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKTWriter_write.restype = ctypes.c_char_p
lgeos.GEOSWKTWriter_write.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
lgeos.GEOSWKBReader_create.restype = ctypes.c_void_p
lgeos.GEOSWKBReader_destroy.restype = None
lgeos.GEOSWKBReader_destroy.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKBReader_read.restype = ctypes.c_void_p
lgeos.GEOSWKBReader_read.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t]
lgeos.GEOSWKBReader_readHEX.restype = ctypes.c_void_p
lgeos.GEOSWKBReader_readHEX.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t]
lgeos.GEOSWKBWriter_create.restype = ctypes.c_void_p
lgeos.GEOSWKBWriter_destroy.restype = None
lgeos.GEOSWKBWriter_destroy.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKBWriter_getOutputDimension.restype = ctypes.c_int
lgeos.GEOSWKBWriter_getOutputDimension.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKBWriter_setOutputDimension.restype = None
lgeos.GEOSWKBWriter_setOutputDimension.argtypes = [ctypes.c_void_p, ctypes.c_int]
lgeos.GEOSWKBWriter_getByteOrder.restype = ctypes.c_int
lgeos.GEOSWKBWriter_getByteOrder.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKBWriter_setByteOrder.restype = None
lgeos.GEOSWKBWriter_setByteOrder.argtypes = [ctypes.c_void_p, ctypes.c_int]
lgeos.GEOSWKBWriter_getIncludeSRID.restype = ctypes.c_char
lgeos.GEOSWKBWriter_getIncludeSRID.argtypes = [ctypes.c_void_p]
lgeos.GEOSWKBWriter_setIncludeSRID.restype = None
lgeos.GEOSWKBWriter_setIncludeSRID.argtypes = [ctypes.c_void_p, ctypes.c_char]
Furthermore, the following unneeded declarations are removed to avoid problems
with Debian's 2.2.3 package:
lgeos.GEOSCoordSeq_getOrdinate.restype = ctypes.c_int
lgeos.GEOSCoordSeq_getOrdinate.argtypes = [ctypes.c_void_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_void_p]
Shapely-1.5.13/LICENSE.txt 0000664 0000000 0000000 00000002757 12606105165 0015046 0 ustar 00root root 0000000 0000000
Copyright (c) 2007, Sean C. Gillies
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Sean C. Gillies nor the names of
its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Shapely-1.5.13/MANIFEST.in 0000664 0000000 0000000 00000000566 12606105165 0014755 0 ustar 00root root 0000000 0000000 prune manual
prune debian
prune docs
prune DLLs_AMD64
prune DLLs_x86
exclude *.txt
exclude MANIFEST.in
include CHANGES.txt CREDITS.txt LICENSE.txt README.rst VERSION.txt
recursive-include tests *.py *.txt
recursive-include shapely/examples *.py
recursive-include shapely/speedups *.pyx
recursive-include shapely/vectorized *.pyx
include shapely/_geos.pxi
include docs/*.rst
Shapely-1.5.13/README.rst 0000664 0000000 0000000 00000010557 12606105165 0014707 0 ustar 00root root 0000000 0000000 =======
Shapely
=======
Manipulation and analysis of geometric objects in the Cartesian plane.
.. image:: https://travis-ci.org/Toblerity/Shapely.png?branch=master
:target: https://travis-ci.org/Toblerity/Shapely
.. image:: http://farm3.staticflickr.com/2738/4511827859_b5822043b7_o_d.png
:width: 800
:height: 400
Shapely is a BSD-licensed Python package for manipulation and analysis of
planar geometric objects. It is based on the widely deployed `GEOS
`__ (the engine of `PostGIS
`__) and `JTS
`__ (from which GEOS is ported)
libraries. Shapely is not concerned with data formats or coordinate systems,
but can be readily integrated with packages that are. For more details, see:
* Shapely on `GitHub `__
* The Shapely `manual `__
Requirements
============
Shapely 1.5.x requires
* Python >=2.6 (including Python 3.x)
* GEOS >=3.3 (Shapely 1.2.x requires only GEOS 3.1 but YMMV)
Installing Shapely
==================
Windows users should download an executable installer from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely or PyPI (if available).
On other systems, acquire the GEOS by any means (`brew install geos` on OS X or
`apt-get install libgeos-dev` on Debian/Ubuntu), make sure that it is on the
system library path, and install Shapely from the Python package index.
.. code-block:: console
$ pip install shapely
If you've installed GEOS to a non-standard location, the geos-config program
will be used to get compiler and linker options. If it is not on the PATH,
it can be specified with a GEOS_CONFIG environment variable, e.g.:
.. code-block:: console
$ GEOS_CONFIG=/path/to/geos-config pip install shapely
If your system's GEOS version is < 3.3.0 you cannot use Shapely 1.3+ and must
stick to 1.2.x as shown below.
.. code-block:: console
$ pip install shapely<1.3
Or, if you're using pip 6+
.. code-block:: console
$ pip install shapely~=1.2
Shapely is also provided by popular Python distributions like Canopy (Enthought)
and Anaconda (Continuum Analytics).
Usage
=====
Here is the canonical example of building an approximately circular patch by
buffering a point.
.. code-block:: pycon
>>> from shapely.geometry import Point
>>> patch = Point(0.0, 0.0).buffer(10.0)
>>> patch
>>> patch.area
313.65484905459385
See the manual for comprehensive usage snippets and the dissolve.py and
intersect.py examples.
Integration
===========
Shapely does not read or write data files, but it can serialize and deserialize
using several well known formats and protocols. The shapely.wkb and shapely.wkt
modules provide dumpers and loaders inspired by Python's pickle module.
.. code-block:: pycon
>>> from shapely.wkt import dumps, loads
>>> dumps(loads('POINT (0 0)'))
'POINT (0.0000000000000000 0.0000000000000000)'
Shapely can also integrate with other Python GIS packages using GeoJSON-like
dicts.
.. code-block:: pycon
>>> import json
>>> from shapely.geometry import mapping, shape
>>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
>>> s
>>> print(json.dumps(mapping(s)))
{"type": "Point", "coordinates": [0.0, 0.0]}
Development and Testing
=======================
Dependencies for developing Shapely are listed in requirements-dev.txt. Cython
and Numpy are not required for production installations, only for development.
Use of a virtual environment is strongly recommended.
.. code-block:: console
$ virtualenv .
$ source bin/activate
(env)$ pip install -r requirements-dev.txt
(env)$ pip install -e .
We use py.test to run Shapely's suite of unittests and doctests.
.. code-block:: console
(env)$ py.test tests
Roadmap and Maintenance
=======================
Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but
not Python 3+. There will be no new features in Shapely 1.2.x and only fixes
for major bugs.
Shapely 1.4.x is a maintenance-only branch supporting Pythons 2.7 and 3.3+.
Support
=======
Please discuss Shapely with us at
http://lists.gispython.org/mailman/listinfo/community.
Bugs may be reported at https://github.com/Toblerity/Shapely/issues.
Shapely-1.5.13/build-scripts/ 0000775 0000000 0000000 00000000000 12606105165 0015774 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/build-scripts/macosx-10.6-intel.sh 0000664 0000000 0000000 00000000607 12606105165 0021320 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Dependent on the Kyngchaos Frameworks:
# http://www.kyngchaos.com/software/frameworks
export GEOS_CONFIG="/Library/Frameworks/GEOS.framework/Versions/3/unix/bin/geos-config"
CFLAGS="`$GEOS_CONFIG --cflags`" LDFLAGS="`$GEOS_CONFIG --clibs`" python setup.py bdist_wheel
delocate-wheel -w fixed_wheels --require-archs=intel -v dist/Shapely-1.5.2-cp27-none-macosx_10_6_intel.whl
Shapely-1.5.13/build-wheels.sh 0000664 0000000 0000000 00000001637 12606105165 0016137 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Automation of this is a TODO. For now, it depends on manually built libraries
# as detailed in https://gist.github.com/sgillies/a8a2fb910a98a8566d0a.
export MACOSX_DEPLOYMENT_TARGET=10.6
export GEOS_CONFIG="/usr/local/bin/geos-config"
VERSION=$1
source $HOME/envs/pydotorg27/bin/activate
touch shapely/speedups/*.pyx
touch shapely/vectorized/*.pyx
CFLAGS="`$GEOS_CONFIG --cflags`" LDFLAGS="`$GEOS_CONFIG --libs`" python setup.py bdist_wheel -d wheels/$VERSION
source $HOME/envs/pydotorg34/bin/activate
touch shapely/speedups/*.pyx
touch shapely/vectorized/*.pyx
CFLAGS="`$GEOS_CONFIG --cflags`" LDFLAGS="`$GEOS_CONFIG --libs`" python setup.py bdist_wheel -d wheels/$VERSION
parallel delocate-wheel -w fixed_wheels/$VERSION --require-archs=intel -v {} ::: wheels/$VERSION/*.whl
parallel cp {} {.}.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl ::: fixed_wheels/$VERSION/*.whl
Shapely-1.5.13/docs/ 0000775 0000000 0000000 00000000000 12606105165 0014140 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/docs/Makefile 0000664 0000000 0000000 00000006333 12606105165 0015605 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/* build/plot_directive/*
html: apidocs
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp: apidocs
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Shapely.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Shapely.qhc"
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
apidocs:
sphinx-apidoc -f -s txt -o . ../shapely
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
Shapely-1.5.13/docs/code/ 0000775 0000000 0000000 00000000000 12606105165 0015052 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/docs/code/buffer.py 0000664 0000000 0000000 00000002732 12606105165 0016701 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
def plot_line(ax, ob):
x, y = ob.xy
ax.plot(x, y, color=GRAY, linewidth=3, solid_capstyle='round', zorder=1)
line = LineString([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1
ax = fig.add_subplot(121)
plot_line(ax, line)
dilated = line.buffer(0.5, cap_style=3)
patch1 = PolygonPatch(dilated, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch1)
ax.set_title('a) dilation, cap_style=3')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
patch2a = PolygonPatch(dilated, fc=GRAY, ec=GRAY, alpha=0.5, zorder=1)
ax.add_patch(patch2a)
eroded = dilated.buffer(-0.3)
# GeoJSON-like data works as well
polygon = eroded.__geo_interface__
# >>> geo['type']
# 'Polygon'
# >>> geo['coordinates'][0][:2]
# ((0.50502525316941682, 0.78786796564403572), (0.5247963548222736, 0.8096820147509064))
patch2b = PolygonPatch(polygon, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch2b)
ax.set_title('b) erosion, join_style=1')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/cascaded_union.py 0000664 0000000 0000000 00000001751 12606105165 0020367 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Point
from shapely.ops import cascaded_union
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
polygons = [Point(i, 0).buffer(0.7) for i in range(5)]
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1
ax = fig.add_subplot(121)
for ob in polygons:
p = PolygonPatch(ob, fc=GRAY, ec=GRAY, alpha=0.5, zorder=1)
ax.add_patch(p)
ax.set_title('a) polygons')
xrange = [-2, 6]
yrange = [-2, 2]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
u = cascaded_union(polygons)
patch2b = PolygonPatch(u, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch2b)
ax.set_title('b) union')
xrange = [-2, 6]
yrange = [-2, 2]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/convex_hull.py 0000664 0000000 0000000 00000002247 12606105165 0017757 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import MultiPoint
from descartes.patch import PolygonPatch
from figures import SIZE
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
fig.set_frameon(True)
# 1
ax = fig.add_subplot(121)
points2 = MultiPoint([(0, 0), (2, 2)])
for p in points2:
ax.plot(p.x, p.y, 'o', color='#999999')
hull2 = points2.convex_hull
x, y = hull2.xy
ax.plot(x, y, color='#6699cc', linewidth=3, alpha=0.5, zorder=2)
ax.set_title('a) N = 2')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
points1 = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
for p in points1:
ax.plot(p.x, p.y, 'o', color='#999999')
hull1 = points1.convex_hull
patch1 = PolygonPatch(hull1, facecolor='#6699cc', edgecolor='#6699cc', alpha=0.5, zorder=2)
ax.add_patch(patch1)
ax.set_title('b) N > 2')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/difference.py 0000664 0000000 0000000 00000002430 12606105165 0017515 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Point
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
a = Point(1, 1).buffer(1.5)
b = Point(2, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = a.difference(b)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('a.difference(b)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = b.difference(a)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('b.difference(a)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/figures.py 0000664 0000000 0000000 00000000160 12606105165 0017065 0 ustar 00root root 0000000 0000000 from math import sqrt
GM = (sqrt(5)-1.0)/2.0
W = 8.0
H = W*GM
SIZE = (W, H)
BLUE = '#6699cc'
GRAY = '#999999'
Shapely-1.5.13/docs/code/geometrycollection.py 0000664 0000000 0000000 00000003146 12606105165 0021337 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from figures import SIZE
BLUE = '#6699cc'
YELLOW = '#ffcc33'
GREEN = '#339933'
GRAY = '#999999'
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color=GRAY, zorder=1)
fig = pyplot.figure(1, figsize=SIZE, dpi=90) #1, figsize=(10, 4), dpi=180)
a = LineString([(0, 0), (1, 1), (1,2), (2,2)])
b = LineString([(0, 0), (1, 1), (2,1), (2,2)])
# 1: disconnected multilinestring
ax = fig.add_subplot(121)
plot_coords(ax, a)
plot_coords(ax, b)
x, y = a.xy
ax.plot(x, y, color=YELLOW, alpha=0.5, linewidth=3, solid_capstyle='round', zorder=2)
x, y = b.xy
ax.plot(x, y, color=GREEN, alpha=0.5, linewidth=3, solid_capstyle='round', zorder=2)
ax.set_title('a) lines')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
x, y = a.xy
ax.plot(x, y, color=GRAY, alpha=0.7, linewidth=1, solid_capstyle='round', zorder=1)
x, y = b.xy
ax.plot(x, y, color=GRAY, alpha=0.7, linewidth=1, solid_capstyle='round', zorder=1)
for ob in a.intersection(b):
x, y = ob.xy
if len(x) == 1:
ax.plot(x, y, 'o', color=BLUE, zorder=2)
else:
ax.plot(x, y, color=BLUE, alpha=0.7, linewidth=3, solid_capstyle='round', zorder=2)
ax.set_title('b) collection')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/intersection-sym-difference.py 0000664 0000000 0000000 00000002757 12606105165 0023043 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Point
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
a = Point(1, 1).buffer(1.5)
b = Point(2, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = a.intersection(b)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('a.intersection(b)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = a.symmetric_difference(b)
if c.geom_type == 'Polygon':
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
elif c.geom_type == 'MultiPolygon':
for p in c:
patchp = PolygonPatch(p, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchp)
ax.set_title('a.symmetric_difference(b)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/linearring.py 0000664 0000000 0000000 00000002365 12606105165 0017564 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry.polygon import LinearRing
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ff3333'
}
def v_color(ob):
return COLOR[ob.is_valid]
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
def plot_line(ax, ob):
x, y = ob.xy
ax.plot(x, y, color=v_color(ob), alpha=0.7, linewidth=3, solid_capstyle='round', zorder=2)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: valid ring
ax = fig.add_subplot(121)
ring = LinearRing([(0, 0), (0, 2), (1, 1), (2, 2), (2, 0), (1, 0.8), (0, 0)])
plot_coords(ax, ring)
plot_line(ax, ring)
ax.set_title('a) valid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
ring2 = LinearRing([(0, 0), (0, 2), (1, 1), (2, 2), (2, 0), (1, 1), (0, 0)])
plot_coords(ax, ring2)
plot_line(ax, ring2)
ax.set_title('b) invalid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/linestring.py 0000664 0000000 0000000 00000002463 12606105165 0017607 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ffcc33'
}
def v_color(ob):
return COLOR[ob.is_simple]
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
def plot_bounds(ax, ob):
x, y = zip(*list((p.x, p.y) for p in ob.boundary))
ax.plot(x, y, 'o', color='#000000', zorder=1)
def plot_line(ax, ob):
x, y = ob.xy
ax.plot(x, y, color=v_color(ob), alpha=0.7, linewidth=3, solid_capstyle='round', zorder=2)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: simple line
ax = fig.add_subplot(121)
line = LineString([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
plot_coords(ax, line)
plot_bounds(ax, line)
plot_line(ax, line)
ax.set_title('a) simple')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_ylim(*yrange)
ax.set_yticks(list(range(*yrange)) + [yrange[-1]])
ax.set_aspect(1)
#2: complex line
ax = fig.add_subplot(122)
line2 = LineString([(0, 0), (1, 1), (0, 2), (2, 2), (-1, 1), (1, 0)])
plot_coords(ax, line2)
plot_bounds(ax, line2)
plot_line(ax, line2)
ax.set_title('b) complex')
xrange = [-2, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_ylim(*yrange)
ax.set_yticks(list(range(*yrange)) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/multilinestring.py 0000664 0000000 0000000 00000003026 12606105165 0020656 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import MultiLineString
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ffcc33'
}
def v_color(ob):
return COLOR[ob.is_simple]
def plot_coords(ax, ob):
for line in ob:
x, y = line.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
def plot_bounds(ax, ob):
x, y = zip(*list((p.x, p.y) for p in ob.boundary))
ax.plot(x, y, 'o', color='#000000', zorder=1)
def plot_lines(ax, ob):
for line in ob:
x, y = line.xy
ax.plot(x, y, color=v_color(ob), alpha=0.7, linewidth=3, solid_capstyle='round', zorder=2)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: disconnected multilinestring
ax = fig.add_subplot(121)
mline1 = MultiLineString([((0, 0), (1, 1)), ((0, 2), (1, 1.5), (1.5, 1), (2, 0))])
plot_coords(ax, mline1)
plot_bounds(ax, mline1)
plot_lines(ax, mline1)
ax.set_title('a) simple')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
mline2 = MultiLineString([((0, 0), (1, 1), (1.5, 1)), ((0, 2), (1, 1.5), (1.5, 1), (2, 0))])
plot_coords(ax, mline2)
plot_bounds(ax, mline2)
plot_lines(ax, mline2)
ax.set_title('b) complex')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/multipolygon.py 0000664 0000000 0000000 00000003106 12606105165 0020166 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import MultiPolygon
from descartes.patch import PolygonPatch
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ff3333'
}
def v_color(ob):
return COLOR[ob.is_valid]
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: valid multi-polygon
ax = fig.add_subplot(121)
a = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]
b = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
multi1 = MultiPolygon([[a, []], [b, []]])
for polygon in multi1:
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(multi1), edgecolor=v_color(multi1), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('a) valid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
c = [(0, 0), (0, 1.5), (1, 1.5), (1, 0), (0, 0)]
d = [(1, 0.5), (1, 2), (2, 2), (2, 0.5), (1, 0.5)]
multi2 = MultiPolygon([[c, []], [d, []]])
for polygon in multi2:
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(multi2), edgecolor=v_color(multi2), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('b) invalid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/parallel_offset.py 0000664 0000000 0000000 00000003751 12606105165 0020574 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
def plot_coords(ax, x, y, color='#999999', zorder=1):
ax.plot(x, y, 'o', color=color, zorder=zorder)
def plot_line(ax, ob, color=GRAY):
parts = hasattr(ob, 'geoms') and ob or [ob]
for part in parts:
x, y = part.xy
ax.plot(x, y, color=color, linewidth=3, solid_capstyle='round', zorder=1)
def set_limits(ax, x_range, y_range):
ax.set_xlim(*x_range)
ax.set_xticks(range(*x_range) + [x_range[-1]])
ax.set_ylim(*y_range)
ax.set_yticks(range(*y_range) + [y_range[-1]])
ax.set_aspect(1)
line = LineString([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
line_bounds = line.bounds
ax_range = [int(line_bounds[0] - 1.0), int(line_bounds[2] + 1.0)]
ay_range = [int(line_bounds[1] - 1.0), int(line_bounds[3] + 1.0)]
fig = pyplot.figure(1, figsize=(SIZE[0], 2 * SIZE[1]), dpi=90)
# 1
ax = fig.add_subplot(221)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'left', join_style=1)
plot_line(ax, offset, color=BLUE)
ax.set_title('a) left, round')
set_limits(ax, ax_range, ay_range)
#2
ax = fig.add_subplot(222)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'left', join_style=2)
plot_line(ax, offset, color=BLUE)
ax.set_title('b) left, mitred')
set_limits(ax, ax_range, ay_range)
#3
ax = fig.add_subplot(223)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'left', join_style=3)
plot_line(ax, offset, color=BLUE)
ax.set_title('c) left, beveled')
set_limits(ax, ax_range, ay_range)
#4
ax = fig.add_subplot(224)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'right', join_style=1)
plot_line(ax, offset, color=BLUE)
ax.set_title('d) right, round')
set_limits(ax, ax_range, ay_range)
pyplot.show()
Shapely-1.5.13/docs/code/parallel_offset_mitre.py 0000664 0000000 0000000 00000004100 12606105165 0021761 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
def plot_coords(ax, x, y, color='#999999', zorder=1):
ax.plot(x, y, 'o', color=color, zorder=zorder)
def plot_line(ax, ob, color=GRAY):
parts = hasattr(ob, 'geoms') and ob or [ob]
for part in parts:
x, y = part.xy
ax.plot(x, y, color=color, linewidth=3, solid_capstyle='round', zorder=1)
def set_limits(ax, x_range, y_range):
ax.set_xlim(*x_range)
ax.set_xticks(range(*x_range) + [x_range[-1]])
ax.set_ylim(*y_range)
ax.set_yticks(range(*y_range) + [y_range[-1]])
ax.set_aspect(1)
line = LineString([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
line_bounds = line.bounds
ax_range = [int(line_bounds[0] - 1.0), int(line_bounds[2] + 1.0)]
ay_range = [int(line_bounds[1] - 1.0), int(line_bounds[3] + 1.0)]
fig = pyplot.figure(1, figsize=(SIZE[0], 2 * SIZE[1]), dpi=90)
# 1
ax = fig.add_subplot(221)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'left', join_style=2, mitre_limit=0.1)
plot_line(ax, offset, color=BLUE)
ax.set_title('a) left, limit=0.1')
set_limits(ax, ax_range, ay_range)
#2
ax = fig.add_subplot(222)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'left', join_style=2, mitre_limit=10.0)
plot_line(ax, offset, color=BLUE)
ax.set_title('b) left, limit=10.0')
set_limits(ax, ax_range, ay_range)
#3
ax = fig.add_subplot(223)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'right', join_style=2, mitre_limit=0.1)
plot_line(ax, offset, color=BLUE)
ax.set_title('c) right, limit=0.1')
set_limits(ax, ax_range, ay_range)
#4
ax = fig.add_subplot(224)
plot_line(ax, line)
x, y = list(line.coords)[0]
plot_coords(ax, x, y)
offset = line.parallel_offset(0.5, 'right', join_style=2, mitre_limit=10.0)
plot_line(ax, offset, color=BLUE)
ax.set_title('d) right, limit=10.0')
set_limits(ax, ax_range, ay_range)
pyplot.show()
Shapely-1.5.13/docs/code/polygon.py 0000664 0000000 0000000 00000003106 12606105165 0017113 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Polygon
from descartes.patch import PolygonPatch
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ff3333'
}
def v_color(ob):
return COLOR[ob.is_valid]
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: valid polygon
ax = fig.add_subplot(121)
ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
int = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)][::-1]
polygon = Polygon(ext, [int])
plot_coords(ax, polygon.interiors[0])
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(polygon), edgecolor=v_color(polygon), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('a) valid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
int = [(1, 0), (0, 1), (0.5, 1.5), (1.5, 0.5), (1, 0)][::-1]
polygon = Polygon(ext, [int])
plot_coords(ax, polygon.interiors[0])
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(polygon), edgecolor=v_color(polygon), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('b) invalid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/polygon2.py 0000664 0000000 0000000 00000003406 12606105165 0017200 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from matplotlib.patches import Circle
from shapely.geometry import Polygon
from descartes.patch import PolygonPatch
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ff3333'
}
def v_color(ob):
return COLOR[ob.is_valid]
def plot_coords(ax, ob):
x, y = ob.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 3: invalid polygon, ring touch along a line
ax = fig.add_subplot(121)
ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
int = [(0.5, 0), (1.5, 0), (1.5, 1), (0.5, 1), (0.5, 0)]
polygon = Polygon(ext, [int])
plot_coords(ax, polygon.interiors[0])
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(polygon), edgecolor=v_color(polygon), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('c) invalid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#4: invalid self-touching ring
ax = fig.add_subplot(122)
ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
int_1 = [(0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)]
int_2 = [(0.5, 1.25), (1, 1.25), (1, 1.75), (0.5, 1.75)]
# int_2 = [
polygon = Polygon(ext, [int_1, int_2])
plot_coords(ax, polygon.interiors[0])
plot_coords(ax, polygon.interiors[1])
plot_coords(ax, polygon.exterior)
patch = PolygonPatch(polygon, facecolor=v_color(polygon), edgecolor=v_color(polygon), alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.set_title('d) invalid')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/rotate.py 0000664 0000000 0000000 00000002546 12606105165 0016731 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import LineString
from shapely import affinity
from figures import SIZE, BLUE, GRAY
def add_origin(ax, geom, origin):
x, y = xy = affinity.interpret_origin(geom, origin, 2)
ax.plot(x, y, 'o', color=GRAY, zorder=1)
ax.annotate(str(xy), xy=xy, ha='center',
textcoords='offset points', xytext=(0, 8))
def plot_line(ax, ob, color):
x, y = ob.xy
ax.plot(x, y, color=color, alpha=0.7, linewidth=3,
solid_capstyle='round', zorder=2)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
line = LineString([(1, 3), (1, 1), (4, 1)])
xrange = [0, 5]
yrange = [0, 4]
# 1
ax = fig.add_subplot(121)
plot_line(ax, line, GRAY)
plot_line(ax, affinity.rotate(line, 90, 'center'), BLUE)
add_origin(ax, line, 'center')
ax.set_title(u"90\N{DEGREE SIGN}, default origin (center)")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
# 2
ax = fig.add_subplot(122)
plot_line(ax, line, GRAY)
plot_line(ax, affinity.rotate(line, 90, 'centroid'), BLUE)
add_origin(ax, line, 'centroid')
ax.set_title(u"90\N{DEGREE SIGN}, origin='centroid'")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/scale.py 0000664 0000000 0000000 00000003261 12606105165 0016515 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Polygon
from shapely import affinity
from descartes.patch import PolygonPatch
from figures import SIZE, BLUE, GRAY
def add_origin(ax, geom, origin):
x, y = xy = affinity.interpret_origin(geom, origin, 2)
ax.plot(x, y, 'o', color=GRAY, zorder=1)
ax.annotate(str(xy), xy=xy, ha='center',
textcoords='offset points', xytext=(0, 8))
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
triangle = Polygon([(1, 1), (2, 3), (3, 1)])
xrange = [0, 5]
yrange = [0, 4]
# 1
ax = fig.add_subplot(121)
patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY,
alpha=0.5, zorder=1)
triangle_a = affinity.scale(triangle, xfact=1.5, yfact=-1)
patch_a = PolygonPatch(triangle_a, facecolor=BLUE, edgecolor=BLUE,
alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.add_patch(patch_a)
add_origin(ax, triangle, 'center')
ax.set_title("a) xfact=1.5, yfact=-1")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
# 2
ax = fig.add_subplot(122)
patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY,
alpha=0.5, zorder=1)
triangle_b = affinity.scale(triangle, xfact=2, origin=(1, 1))
patch_b = PolygonPatch(triangle_b, facecolor=BLUE, edgecolor=BLUE,
alpha=0.5, zorder=2)
ax.add_patch(patch)
ax.add_patch(patch_b)
add_origin(ax, triangle, (1, 1))
ax.set_title("b) xfact=2, origin=(1, 1)")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/simplify.py 0000664 0000000 0000000 00000002305 12606105165 0017260 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import MultiPoint, Point
from descartes.patch import PolygonPatch
from figures import SIZE, BLUE, GRAY
fig = pyplot.figure(1, figsize=SIZE, dpi=90) #1, figsize=SIZE, dpi=90)
p = Point(1, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
q = p.simplify(0.2)
patch1a = PolygonPatch(p, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1)
ax.add_patch(patch1a)
patch1b = PolygonPatch(q, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch1b)
ax.set_title('a) tolerance 0.2')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2
ax = fig.add_subplot(122)
r = p.simplify(0.5)
patch2a = PolygonPatch(p, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1)
ax.add_patch(patch2a)
patch2b = PolygonPatch(r, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch2b)
ax.set_title('b) tolerance 0.5')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/skew.py 0000664 0000000 0000000 00000004721 12606105165 0016401 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.wkt import loads as load_wkt
from shapely import affinity
from descartes.patch import PolygonPatch
from figures import SIZE, BLUE, GRAY
def add_origin(ax, geom, origin):
x, y = xy = affinity.interpret_origin(geom, origin, 2)
ax.plot(x, y, 'o', color=GRAY, zorder=1)
ax.annotate(str(xy), xy=xy, ha='center',
textcoords='offset points', xytext=(0, 8))
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# Geometry from JTS TestBuilder with fixed precision model of 100.0
# Using CreateShape > FontGlyphSanSerif and A = triangle.wkt from scale.py
R = load_wkt('''\
POLYGON((2.218 2.204, 2.273 2.18, 2.328 2.144, 2.435 2.042, 2.541 1.895,
2.647 1.702, 3 1, 2.626 1, 2.298 1.659, 2.235 1.777, 2.173 1.873,
2.112 1.948, 2.051 2.001, 1.986 2.038, 1.91 2.064, 1.823 2.08, 1.726 2.085,
1.347 2.085, 1.347 1, 1 1, 1 3.567, 1.784 3.567, 1.99 3.556, 2.168 3.521,
2.319 3.464, 2.441 3.383, 2.492 3.334, 2.536 3.279, 2.604 3.152,
2.644 3.002, 2.658 2.828, 2.651 2.712, 2.63 2.606, 2.594 2.51, 2.545 2.425,
2.482 2.352, 2.407 2.29, 2.319 2.241, 2.218 2.204),
(1.347 3.282, 1.347 2.371, 1.784 2.371, 1.902 2.378, 2.004 2.4, 2.091 2.436,
2.163 2.487, 2.219 2.552, 2.259 2.63, 2.283 2.722, 2.291 2.828, 2.283 2.933,
2.259 3.025, 2.219 3.103, 2.163 3.167, 2.091 3.217, 2.004 3.253, 1.902 3.275,
1.784 3.282, 1.347 3.282))''')
xrange = [0, 5]
yrange = [0, 4]
# 1
ax = fig.add_subplot(121)
patch1a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY,
alpha=0.5, zorder=1)
skewR = affinity.skew(R, xs=20, origin=(1, 1))
patch1b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE,
alpha=0.5, zorder=2)
ax.add_patch(patch1a)
ax.add_patch(patch1b)
add_origin(ax, R, (1, 1))
ax.set_title("a) xs=20, origin(1, 1)")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
# 2
ax = fig.add_subplot(122)
patch2a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY,
alpha=0.5, zorder=1)
skewR = affinity.skew(R, ys=30)
patch2b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE,
alpha=0.5, zorder=2)
ax.add_patch(patch2a)
ax.add_patch(patch2b)
add_origin(ax, R, 'center')
ax.set_title("b) ys=30")
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/code/triangulate.py 0000664 0000000 0000000 00000001220 12606105165 0017736 0 ustar 00root root 0000000 0000000 from shapely.geometry import MultiPoint
from shapely.ops import triangulate
from matplotlib import pyplot
from descartes.patch import PolygonPatch
from figures import SIZE, BLUE, GRAY
points = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
triangles = triangulate(points)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
fig.set_frameon(True)
ax = fig.add_subplot(111)
for triangle in triangles:
patch = PolygonPatch(triangle, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patch)
for point in points:
pyplot.plot(point.x, point.y, 'o', color=GRAY)
pyplot.xlim(-0.5, 3.5)
pyplot.ylim(-0.5, 2.5)
pyplot.show()
Shapely-1.5.13/docs/code/union.py 0000664 0000000 0000000 00000002621 12606105165 0016555 0 ustar 00root root 0000000 0000000 from matplotlib import pyplot
from shapely.geometry import Point
from descartes import PolygonPatch
from figures import SIZE, BLUE, GRAY
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
a = Point(1, 1).buffer(1.5)
b = Point(2, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
patch1 = PolygonPatch(a, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch1)
patch2 = PolygonPatch(b, fc=GRAY, ec=GRAY, alpha=0.2, zorder=1)
ax.add_patch(patch2)
c = a.union(b)
patchc = PolygonPatch(c, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
ax.add_patch(patchc)
ax.set_title('a.union(b)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
def plot_line(ax, ob, color=GRAY):
x, y = ob.xy
ax.plot(x, y, color, linewidth=3, solid_capstyle='round', zorder=1)
#2
ax = fig.add_subplot(122)
plot_line(ax, a.exterior)
plot_line(ax, b.exterior)
u = a.exterior.union(b.exterior)
if u.geom_type in ['LineString', 'LinearRing', 'Point']:
plot_line(ax, u, color=BLUE)
elif u.geom_type is 'MultiLineString':
for p in u:
plot_line(ax, p, color=BLUE)
ax.set_title('a.boundary.union(b.boundary)')
xrange = [-1, 4]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
Shapely-1.5.13/docs/conf.py 0000664 0000000 0000000 00000015413 12606105165 0015443 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
#
# Shapely documentation build configuration file, created by
# sphinx-quickstart on Mon Apr 12 11:07:08 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(os.path.abspath('sphinxext'))
# Load latest source tree
sys.path.insert(0, os.path.abspath('..'))
import shapely
# For pyplots in code/, load functions here first, so they are visible
from shapely import geometry, affinity, wkt, wkb
from shapely.ops import cascaded_union
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'matplotlib.sphinxext.only_directives',
'matplotlib.sphinxext.plot_directive',
'sphinx.ext.autodoc',
#'sphinx.ext.pngmath', # <----- pick one, not both
'sphinx.ext.mathjax', # <--/
]
# Add any paths that contain templates here, relative to this directory.
#templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'Shapely'
copyright = '2011-2013, Sean Gillies, Aron Bierbaum, Kai Lautaportti ' \
'and others'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = shapely.__version__
# The full version, including alpha/beta/rc tags.
release = shapely.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme = 'haiku'
html_theme = 'sphinxdoc'
# html_theme = 'shapely'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['themes']
# The name for this set of Sphinx documents. If None, it defaults to
# " v documentation".
html_title = "Shapely 1.2 and 1.3 documentation"
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'Shapelydoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Shapely.tex', 'Shapely Documentation',
'Sean Gillies', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
Shapely-1.5.13/docs/design.rst 0000664 0000000 0000000 00000002603 12606105165 0016144 0 ustar 00root root 0000000 0000000 ============
Design Notes
============
Shapely provides classes that implement, more or less, the interfaces in the
OGC's simple feature acess specification [1]_. The classes are defined in
similarly named modules under ``shapely.geometry``: ``Point`` is in
``shapely.geometry.point``, ``MultiPolygon`` is in
``shapely.geometry.multipolygon``. These classes derive from
``shapely.geometry.base.BaseGeometry``. The simple features methods of
``BaseGeometry`` call functions registered in a class variable ``impl``. For
example, ``BaseGeometry.area`` calls ``BaseGeometry.impl['area']``.
The default registry is in the ``shapely.impl`` module. Its items are classes
that operate on single geometric objects or pairs of geometric objects.
Pluggability is a goal of this design, but we're not there yet. Some work needs
to be done before anybody can use CGAL as a Shapely backend.
In sum, Shapely's stack is 4 layers:
* Python geometry classes in ``shapely.geometry``
* An implementation registry: an abstraction that permits alternate geometry
engines, even a mix of geometry engines. The default is in ``shapely.impl``.
* The GEOS implementations of methods for the registry in ``shapely.geos``.
* libgeos: algorithms written in C++.
.. [1] John R. Herring, Ed.,
“OpenGIS Implementation Specification for Geographic information - Simple
feature access - Part 1: Common architecture,” Oct. 2006.
Shapely-1.5.13/docs/images/ 0000775 0000000 0000000 00000000000 12606105165 0015405 5 ustar 00root root 0000000 0000000 Shapely-1.5.13/docs/images/4511827859_b5822043b7_o.png 0000664 0000000 0000000 00000211661 12606105165 0021043 0 ustar 00root root 0000000 0000000 PNG
IHDR V%4 sBIT|d pHYs a a?i IDATxy|SU߽ӦYZ@\@aE}qEDEdQ|}UQ@eZhYPk&]%MǝFBM~>h{ν=