shapely 1.0b2__tar.gz → 1.0b3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {Shapely-1.0b2 → Shapely-1.0b3}/PKG-INFO +3 -3
  2. {Shapely-1.0b2 → Shapely-1.0b3}/README.txt +2 -2
  3. {Shapely-1.0b2 → Shapely-1.0b3}/Shapely.egg-info/PKG-INFO +3 -3
  4. {Shapely-1.0b2 → Shapely-1.0b3}/Shapely.egg-info/SOURCES.txt +2 -0
  5. Shapely-1.0b3/manual/manual.txt +773 -0
  6. Shapely-1.0b3/manual/style.css +231 -0
  7. {Shapely-1.0b2 → Shapely-1.0b3}/setup.py +8 -2
  8. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/polygon.py +1 -1
  9. {Shapely-1.0b2 → Shapely-1.0b3}/CHANGES.txt +0 -0
  10. {Shapely-1.0b2 → Shapely-1.0b3}/CREDITS.txt +0 -0
  11. {Shapely-1.0b2 → Shapely-1.0b3}/HISTORY.txt +0 -0
  12. {Shapely-1.0b2 → Shapely-1.0b3}/LICENSE.txt +0 -0
  13. {Shapely-1.0b2 → Shapely-1.0b3}/Shapely.egg-info/dependency_links.txt +0 -0
  14. {Shapely-1.0b2 → Shapely-1.0b3}/Shapely.egg-info/requires.txt +0 -0
  15. {Shapely-1.0b2 → Shapely-1.0b3}/Shapely.egg-info/top_level.txt +0 -0
  16. {Shapely-1.0b2 → Shapely-1.0b3}/examples/geoms.py +0 -0
  17. {Shapely-1.0b2 → Shapely-1.0b3}/examples/world.py +0 -0
  18. {Shapely-1.0b2 → Shapely-1.0b3}/setup.cfg +0 -0
  19. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/__init__.py +0 -0
  20. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/__init__.py +0 -0
  21. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/base.py +0 -0
  22. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/collection.py +0 -0
  23. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/geo.py +0 -0
  24. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/linestring.py +0 -0
  25. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/multilinestring.py +0 -0
  26. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/multipoint.py +0 -0
  27. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/multipolygon.py +0 -0
  28. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geometry/point.py +0 -0
  29. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/geos.py +0 -0
  30. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/iterops.py +0 -0
  31. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/kml.py +0 -0
  32. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/predicates.py +0 -0
  33. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/topology.py +0 -0
  34. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/wkb.py +0 -0
  35. {Shapely-1.0b2 → Shapely-1.0b3}/shapely/wkt.py +0 -0
  36. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Array.txt +0 -0
  37. {Shapely-1.0b2 → Shapely-1.0b3}/tests/GeoInterface.txt +0 -0
  38. {Shapely-1.0b2 → Shapely-1.0b3}/tests/IterOps.txt +0 -0
  39. {Shapely-1.0b2 → Shapely-1.0b3}/tests/LineString.txt +0 -0
  40. {Shapely-1.0b2 → Shapely-1.0b3}/tests/MultiLineString.txt +0 -0
  41. {Shapely-1.0b2 → Shapely-1.0b3}/tests/MultiPoint.txt +0 -0
  42. {Shapely-1.0b2 → Shapely-1.0b3}/tests/MultiPolygon.txt +0 -0
  43. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Operations.txt +0 -0
  44. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Persist.txt +0 -0
  45. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Point.txt +0 -0
  46. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Polygon.txt +0 -0
  47. {Shapely-1.0b2 → Shapely-1.0b3}/tests/Predicates.txt +0 -0
  48. {Shapely-1.0b2 → Shapely-1.0b3}/tests/__init__.py +0 -0
  49. {Shapely-1.0b2 → Shapely-1.0b3}/tests/binascii_hex.txt +0 -0
  50. {Shapely-1.0b2 → Shapely-1.0b3}/tests/invalid_intersection.txt +0 -0
  51. {Shapely-1.0b2 → Shapely-1.0b3}/tests/rungrind.dist +0 -0
  52. {Shapely-1.0b2 → Shapely-1.0b3}/tests/test_doctests.py +0 -0
  53. {Shapely-1.0b2 → Shapely-1.0b3}/tests/valgrind-python.supp +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.0b2
3
+ Version: 1.0b3
4
4
  Summary: Geospatial geometries, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/projects/PCL/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -23,7 +23,7 @@ Description: Shapely
23
23
  Dependencies
24
24
  ------------
25
25
 
26
- * libgeos_c (2.2.3, also reported to work with 3.0 after small modifications.)
26
+ * libgeos_c (2.2.3, also reported to work with 3.0)
27
27
  * Python ctypes_ (standard in Python 2.5+)
28
28
 
29
29
  .. _ctypes: http://pypi.python.org/pypi/ctypes/
@@ -124,7 +124,7 @@ Description: Shapely
124
124
  For current information about this project, see the wiki_.
125
125
 
126
126
  .. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
127
- .. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
127
+ .. _manual: http://gispython.org/shapely/manual.html
128
128
 
129
129
  If you have questions, please consider joining our community list:
130
130
 
@@ -15,7 +15,7 @@ http://zcologia.com/news/564/shapely-for-python-3-0/.)
15
15
  Dependencies
16
16
  ------------
17
17
 
18
- * libgeos_c (2.2.3, also reported to work with 3.0 after small modifications.)
18
+ * libgeos_c (2.2.3, also reported to work with 3.0)
19
19
  * Python ctypes_ (standard in Python 2.5+)
20
20
 
21
21
  .. _ctypes: http://pypi.python.org/pypi/ctypes/
@@ -116,7 +116,7 @@ Support
116
116
  For current information about this project, see the wiki_.
117
117
 
118
118
  .. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
119
- .. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
119
+ .. _manual: http://gispython.org/shapely/manual.html
120
120
 
121
121
  If you have questions, please consider joining our community list:
122
122
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.0b2
3
+ Version: 1.0b3
4
4
  Summary: Geospatial geometries, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/projects/PCL/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -23,7 +23,7 @@ Description: Shapely
23
23
  Dependencies
24
24
  ------------
25
25
 
26
- * libgeos_c (2.2.3, also reported to work with 3.0 after small modifications.)
26
+ * libgeos_c (2.2.3, also reported to work with 3.0)
27
27
  * Python ctypes_ (standard in Python 2.5+)
28
28
 
29
29
  .. _ctypes: http://pypi.python.org/pypi/ctypes/
@@ -124,7 +124,7 @@ Description: Shapely
124
124
  For current information about this project, see the wiki_.
125
125
 
126
126
  .. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
127
- .. _manual: http://trac.gispython.org/projects/PCL/wiki/ShapelyManual
127
+ .. _manual: http://gispython.org/shapely/manual.html
128
128
 
129
129
  If you have questions, please consider joining our community list:
130
130
 
@@ -11,6 +11,8 @@ Shapely.egg-info/requires.txt
11
11
  Shapely.egg-info/top_level.txt
12
12
  examples/geoms.py
13
13
  examples/world.py
14
+ manual/manual.txt
15
+ manual/style.css
14
16
  shapely/__init__.py
15
17
  shapely/geos.py
16
18
  shapely/iterops.py
@@ -0,0 +1,773 @@
1
+ ==================
2
+ The Shapely Manual
3
+ ==================
4
+
5
+ :Author: Sean Gillies
6
+ :address: sgillies@frii.com
7
+ http://zcologia.com/sgillies
8
+
9
+ :revision: 1.0
10
+ :date: 2 January 2008
11
+
12
+ :copyright: This work is licensed under a `Creative Commons Attribution-Share Alike 3.0 United States License`__.
13
+
14
+ .. __: http://creativecommons.org/licenses/by-sa/3.0/us/
15
+
16
+ :abstract: This document describes the Shapely Python package for programming with geospatial geometries.
17
+
18
+ .. sectnum::
19
+
20
+ .. contents::
21
+
22
+ Background
23
+ ==========
24
+
25
+ Shapely is a Python package for programming with geospatial geometries. It is
26
+ based on the GEOS_ library, a port of the `Java Topology Suite`_. Please refer
27
+ to the JTS overview for definitions and illustrations of the various geometry
28
+ types, operations, and predicates. See also the Shapely wiki_ and Python
29
+ Package Index record_.
30
+
31
+ .. _GEOS: http://geos.refractions.net
32
+ .. _Java Topology Suite: http://www.jump-project.org/project.php?PID=JTS&SID=OVER
33
+ .. _record: http://pypi.python.org/pypi/Shapely
34
+ .. _wiki: http://trac.gispython.org/projects/PCL/wiki/Shapely
35
+
36
+ Geometries
37
+ ==========
38
+
39
+ The basic, standard GIS geometry model consists of single points, line strings,
40
+ and polygons, homogeneous multi-point, multi-line string, and multi-polygon
41
+ collections, and heterogeneous geometry collections. See the JTS illustration_.
42
+
43
+ .. _illustration: http://www.jump-project.org/project.php?PID=JTS&SID=OVER#spatialdatatypes
44
+
45
+ Shapely 1.0 does not provide circles, arcs, splines or the like.
46
+
47
+ Factories
48
+ ---------
49
+
50
+ Geometries can be created in the typical Python fashion, using the geometry
51
+ classes themselves as factories.
52
+
53
+ Pseudo-code blocks in this section will use the following notation. Let **a**
54
+ be a Cartesian *x*, *y*, and optional *z* coordinate sequence. The coordinates
55
+ values must be numeric types. Let (**a**\ 1, ..., **a**\ M) and (**b**\ 1, ...,
56
+ **b**\ N) be ordered sequences of *M* and *N* such coordinate sequences,
57
+ defining lines or rings.
58
+
59
+ Points
60
+ ++++++
61
+
62
+ The point factory *Point* takes a coordinate sequence parameter
63
+
64
+ .. code-block:: python
65
+
66
+ >>> from shapely.geometry import Point
67
+ >>> point = Point(a)
68
+
69
+ The alternate form is to pass individual coordinate parameters
70
+
71
+ .. code-block:: python
72
+
73
+ >>> point = Point(x0, y0 [, z0])
74
+
75
+ LineStrings
76
+ +++++++++++
77
+
78
+ To create a line string, pass in an ordered sequence of coordinate sequences:
79
+
80
+ .. code-block:: python
81
+
82
+ >>> from shapely.geometry import LineString
83
+ >>> line = LineString((a1, ..., aM))
84
+
85
+ Polygons
86
+ ++++++++
87
+
88
+ A polygon with only an exterior boundary and no holes is created by passing the sequence representation of a closed ring
89
+
90
+ .. code-block:: python
91
+
92
+ >>> from shapely.geometry import Polygon
93
+ >>> polygon = Polygon((a1, ..., aM))
94
+
95
+ If **a**\ 1 is not exactly equal to **a**\ M, the factory will close the ring.
96
+ The following (unit square) polygons are therefore topologically equal
97
+
98
+ .. code-block:: python
99
+
100
+ >>> polygon1 = Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))
101
+ >>> polygon2 = Polygon(((0, 0), (0, 1), (1, 1), (1, 0)))
102
+
103
+ To create a polygon with interior boundaries pass a sequence of rings to the
104
+ second parameter (*holes*)
105
+
106
+ .. code-block:: python
107
+
108
+ >>> polygon = Polygon((a1, ..., aM), [(b1, ..., bN), ...])
109
+
110
+ Rings *must* be non-crossing, ordered coordinate sequences. The order may be
111
+ clockwise or counter-clockwise. The resulting topology is independent of the
112
+ order.
113
+
114
+ Multipart Geometry Factories
115
+ ----------------------------
116
+
117
+ MultiPoints
118
+ +++++++++++
119
+
120
+ An *N*\ -point geometry is created by passing an unordered sequence of
121
+ coordinate sequences [**c**\ 1, ..., **c**\ N]
122
+
123
+ .. code-block:: python
124
+
125
+ >>> from shapely.geometry import MultiPoint
126
+ >>> points = MultiPoint([c1, ..., cN])
127
+
128
+ MultiLineStrings
129
+ ++++++++++++++++
130
+
131
+ A multi-line geometry is created by passing a sequence of representations of
132
+ lines
133
+
134
+ .. code-block:: python
135
+
136
+ >>> from shapely.geometry import MultiLineString
137
+ >>> lines = MultiLineString([(a1, ..., aM), (b1, ..., bN), ...])
138
+
139
+ MultiPolygons
140
+ +++++++++++++
141
+
142
+ A multi-polygon geometry is created by passing a sequence of exterior ring and
143
+ hole list tuples
144
+
145
+ .. code-block:: python
146
+
147
+ >>> from shapely.geometry import MultiPolygon
148
+ >>> lines = MultiPolygon([((a1, ..., aM), [(b1, ..., bN), ...]), ...])
149
+
150
+ More explicit notation for the exterior and interior boundaries (or shells and
151
+ holes) makes usage more clear
152
+
153
+ .. code-block:: python
154
+
155
+ >>> shell = (a1, ..., aM)
156
+ >>> holes = [(b1, ..., bN), ...]
157
+ >>> lines = MultiPolygon([(shell, holes), ...])
158
+
159
+ Constructive Spatial Analysis Methods
160
+ -------------------------------------
161
+
162
+ There are methods of geometry classes that also serve as factories for new
163
+ geometries. It is important to note that these are topological and not
164
+ point-wise operations, and therefore may produce results that are not what one
165
+ might expect from operations on Python sets.
166
+
167
+ See also the JTS |illustration2|_.
168
+
169
+ .. |illustration2| replace:: illustration
170
+ .. _illustration2: http://www.jump-project.org/project.php?PID=JTS&SID=OVER#spatialanalysismethods
171
+
172
+ Example Geometries
173
+ ++++++++++++++++++
174
+
175
+ .. code-block:: python
176
+
177
+ >>> polygon = Polygon(((-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0), (1.0, -1.0)))
178
+ >>> point_r = Point(-1.5, 1.2)
179
+ >>> point_g = Point(-1.0, 1.0)
180
+ >>> point_b = Point(-0.5, 0.5)
181
+ >>> line_r = LineString(((-0.5, 0.5), (0.5, 0.5)))
182
+ >>> line_g = LineString(((1.0, -1.0), (1.8, 0.5)))
183
+ >>> line_b = LineString(((-1.8, -1.2), (1.8, 0.5)))
184
+
185
+ Buffer
186
+ ++++++
187
+
188
+ .buffer(width, quadsegs=16) : geometry
189
+ Returns a buffer region having the given width and with a specified number of
190
+ segments used to approximate curves.
191
+
192
+ The default result of buffering a point is an N-gon approximation of a circle:
193
+
194
+ .. code-block:: python
195
+
196
+ >>> buffered = point_r.buffer(1.0)
197
+ >>> buffered
198
+ <shapely.geometry.polygon.Polygon object at ...>
199
+ >>> buffered.length
200
+ 6.2806623139097271
201
+ >>> buffered.area
202
+ 3.1365484905463727
203
+ >>> len(buffered.exterior.coords)
204
+ 66
205
+
206
+ Boundary
207
+ ++++++++
208
+
209
+ .boundary : geometry
210
+ Returns a lower dimension geometry. The boundary of a polygon is a line, the
211
+ boundary of a line is a collection of points. The boundary of a point is an
212
+ empty (null) collection.
213
+
214
+ .. code-block:: python
215
+
216
+ >>> polygon.boundary
217
+ <shapely.geometry.linestring.LineString object at ...>
218
+ >>> line_b.boundary
219
+ <shapely.geometry.multipoint.MultiPoint object at ...>
220
+ >>> point_r.boundary.is_empty
221
+ True
222
+
223
+ Centroid
224
+ ++++++++
225
+
226
+ .centroid : geometry
227
+ Returns the centroid, or geometric center of the polygon.
228
+
229
+ .. code-block:: python
230
+
231
+ >>> centroid_point = polygon.centroid
232
+ >>> centroid_point.wkt
233
+ 'POINT (-0.0000000000000000 -0.0000000000000000)'
234
+
235
+
236
+ Convex Hull
237
+ +++++++++++
238
+
239
+ .convex_hull : geometry
240
+ Imagine an elastic band stretched around the geometry: that's a convex hull,
241
+ more or less.
242
+
243
+ For example, collect the three points into a multi-point geometry, and get the
244
+ triangular polygon that is their convex hull:
245
+
246
+ .. code-block:: python
247
+
248
+ >>> multi_point = point_r.union(point_g)
249
+ >>> multi_point = multi_point.union(point_b)
250
+ >>> multi_point.convex_hull
251
+ <shapely.geometry.polygon.Polygon object at ...>
252
+
253
+ Difference
254
+ ++++++++++
255
+
256
+ .difference(other) : geometry
257
+ Returns a geometry representing the points making up this geometry that do
258
+ not make up *other*. Note that A.difference(B) is not necessarily equal to
259
+ B.difference(A).
260
+
261
+ .. code-block:: python
262
+
263
+ >>> hull = multi_point.convex_hull
264
+ >>> polygon.difference(hull)
265
+ <shapely.geometry.polygon.Polygon object at ...>
266
+
267
+ Intersection
268
+ ++++++++++++
269
+
270
+ .intersection(other) : geometry
271
+ Returns the intersection of one geometry and the *other* geometry.
272
+
273
+ .. code-block:: python
274
+
275
+ >>> polygon.intersection(hull)
276
+ <shapely.geometry.polygon.Polygon object at ...>
277
+
278
+ Symmetric Difference
279
+ ++++++++++++++++++++
280
+
281
+ .symmetric_difference(other) : geometry
282
+ Returns a geometry combining the points in this geometry not in *other*, and
283
+ the points in *other* not in this geometry.
284
+
285
+ .. code-block:: python
286
+
287
+ >>> polygon.symmetric_difference(hull)
288
+ <shapely.geometry.multipolygon.MultiPolygon object at ...>
289
+
290
+ Union
291
+ +++++
292
+
293
+ .union(other) : geometry
294
+ Returns the union of one geometry and the *other* geometry.
295
+
296
+ Point unions were demonstrated above under convex hull. The union of polygons
297
+ will be a polygon or a multi-polygon depending on whether they intersect or
298
+ not:
299
+
300
+ .. code-block:: python
301
+
302
+ >>> hull.union(polygon)
303
+ <shapely.geometry.polygon.Polygon object at ...>
304
+
305
+ Unary Spatial Predicates
306
+ ------------------------
307
+
308
+ These are implemented as Python attributes.
309
+
310
+ Is Empty
311
+ ++++++++
312
+
313
+ .is_empty : bool
314
+ True if the set of points in this geometry is empty, else False. For more
315
+ details, see
316
+ http://geos.refractions.net/ro/doxygen_docs/html/classgeos_1_1geom_1_1Geometry.html#a17.
317
+
318
+ Is Valid
319
+ ++++++++
320
+
321
+ .is_valid : bool
322
+ True if the geometry is valid (definition depends on sub-class), else False.
323
+ For more details, see
324
+ http://geos.refractions.net/ro/doxygen_docs/html/classgeos_1_1geom_1_1Geometry.html#a16.
325
+
326
+ Is Ring
327
+ +++++++
328
+
329
+ .is_ring : bool
330
+ True if the geometry is a closed ring, else False.
331
+
332
+ Has Z
333
+ +++++
334
+
335
+ .has_z : bool
336
+ True if the geometry's coordinate sequence(s) have z values (are
337
+ 3-dimensional)
338
+
339
+ Examples
340
+ ++++++++
341
+
342
+ .. code-block:: python
343
+
344
+ >>> polygon.is_empty
345
+ False
346
+ >>> polygon.is_valid
347
+ True
348
+ >>> polygon.is_ring
349
+ False
350
+ >>> polygon.boundary.is_ring
351
+ True
352
+ >>> polygon.has_z
353
+ True
354
+
355
+ (Note: that last return value exposes a bug in GEOS 2.2.3. Should be False.)
356
+
357
+ Binary Spatial Predicates
358
+ -------------------------
359
+
360
+ All of these methods take a single positional argument, an *other* geometry. It
361
+ is important to note that these are topological and not point-wise operations,
362
+ and therefore may produce results that are not what one might expect from
363
+ operations on Python.
364
+
365
+ Contains
366
+ ++++++++
367
+
368
+ .contains(other) : bool
369
+ True if the geometry is spatially within, without touching. Applies to all
370
+ types of geometries.
371
+
372
+ .. code-block:: python
373
+
374
+ >>> polygon.contains(point_b)
375
+ True
376
+
377
+ Crosses
378
+ +++++++
379
+
380
+ .crosses(other) : bool
381
+ Only linear geometries (lines, rings, polygon boundaries) may ever cross. No
382
+ geometry may ever cross a point.
383
+
384
+ .. code-block:: python
385
+
386
+ >>> line_b.crosses(polygon)
387
+ True
388
+
389
+ Disjoint
390
+ ++++++++
391
+
392
+ .disjoint(other) : bool
393
+ True if geometries do not spatially relate in any way, else False. See the
394
+ complementary *intersects*.
395
+
396
+ .. code-block:: python
397
+
398
+ >>> polygon.disjoint(point_r)
399
+ True
400
+
401
+ Equals
402
+ ++++++
403
+
404
+ .equals(other) : bool
405
+ Two geometries are topologically equal if their interiors intersect and no
406
+ part of the interior or boundary of one geometry intersects the exterior of
407
+ the other. Not to be confused with Python's *__equals__*.
408
+
409
+ Intersects
410
+ ++++++++++
411
+
412
+ .intersects(other) : bool
413
+ This predicate is the complement of *disjoint*: geometries that do not
414
+ intersect are disjoint. Intersects is the most inclusive predicate.
415
+
416
+ .. code-block:: python
417
+
418
+ >>> polygon.intersects(point_b)
419
+ True
420
+
421
+ Touches
422
+ +++++++
423
+
424
+ .touches(other) : bool
425
+ True if geometries *only* touch. The least inclusive predicate.
426
+
427
+ .. code-block:: python
428
+
429
+ >>> polygon.touches(line_g)
430
+ True
431
+ >>> polygon.touches(line_b)
432
+ False
433
+
434
+ Within
435
+ ++++++
436
+
437
+ .within(other): bool
438
+ The inverse of *contains*.
439
+
440
+ General Methods
441
+ ---------------
442
+
443
+ Distance
444
+ ++++++++
445
+
446
+ .distance(other) : geometry
447
+ The minimum distance from one geometry to the other.
448
+
449
+ .. code-block:: python
450
+
451
+ >>> Point(0,0).distance(Point(1,1))
452
+ 1.4142135623730951
453
+
454
+
455
+ Scalar Properties
456
+ -----------------
457
+
458
+ Area
459
+ ++++
460
+
461
+ .area : float
462
+ Area of the geometry, unitless. Non-zero only for surfaces (polygons,
463
+ multi-polygons).
464
+
465
+ Length
466
+ ++++++
467
+
468
+ .length : float
469
+ Length of the geometry, unitless. Non-zero only for linear geometries
470
+ (line strings, rings, polygon boundaries)
471
+
472
+ Examples
473
+ ++++++++
474
+
475
+ .. code-block:: python
476
+
477
+ >>> polygon.area
478
+ 4.0
479
+ >>> polygon.length
480
+ 8.0
481
+ >>> line_r.length
482
+ 1.0
483
+ >>> line_b.length
484
+ 3.9812058474788765
485
+
486
+ Geometry Parts and Coordinates
487
+ ==============================
488
+
489
+ Coordinate Sequences
490
+ --------------------
491
+
492
+ The coordinates of points, line strings, and polygon rings can be accessed
493
+ through the *coords* attribute of a geometry. *Coords* is an iterator over
494
+ coordinate tuples.
495
+
496
+ .. code-block:: python
497
+
498
+ >>> point_r.coords
499
+ <shapely.geometry.base.CoordinateSequence object at ...>
500
+ >>> len(point_r.coords)
501
+ 1
502
+ >>> point_r.coords[0]
503
+ (-1.5, 1.2)
504
+ >>> list(point_r.coords)
505
+ [(-1.5, 1.2)]
506
+
507
+ The coordinate sequence can be modifed by assigning a sequence (**a**\ 1, ...,
508
+ **a**\ M) to the coords attribute.
509
+
510
+ .. code-block:: python
511
+
512
+ >>> point_new = Point(0, 0)
513
+ >>> point_new.coords = (1, 1)
514
+ >>> list(point_new.coords)
515
+ [(1.0, 1.0)]
516
+
517
+ For line strings:
518
+
519
+ .. code-block:: python
520
+
521
+ >>> line_new = LineString([(0,0), (1,1)])
522
+ >>> line_new.coords = [(1,1), (2,2)]
523
+ >>> list(line_new.coords)
524
+ [(1.0, 1.0), (2.0, 2.0)]
525
+
526
+ Polygon Rings
527
+ -------------
528
+
529
+ The exterior boundary of a polygon can be accessed through the *exterior*
530
+ attribute of the geometry object.
531
+
532
+ .. code-block:: python
533
+
534
+ >>> polygon.exterior
535
+ <shapely.geometry.polygon.LinearRing object at ...>
536
+ >>> list(polygon.exterior.coords)
537
+ [(-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0), (1.0, -1.0), (-1.0, -1.0)]
538
+
539
+ The interior boundaries (or holes) of a polygon can be accessed through the
540
+ *interiors* attribute, which is a list of rings.
541
+
542
+ Sub-geometries
543
+ --------------
544
+
545
+ The parts of a multi-part geometry can be accessed through the *geoms*
546
+ attribute of the geometry object, which is an iterator over the sub-geometries:
547
+
548
+ .. code-block:: python
549
+
550
+ >>> multi_point.geoms
551
+ <shapely.geometry.base.GeometrySequence object at ...>
552
+ >>> len(multi_point.geoms)
553
+ 3
554
+ >>> from pprint import pprint
555
+ >>> pprint(list(multi_point.geoms))
556
+ [<shapely.geometry.point.Point object at ...>,
557
+ <shapely.geometry.point.Point object at ...>,
558
+ <shapely.geometry.point.Point object at ...>]
559
+
560
+ The coordinate sequences of these sub-geometries can then be accessed as
561
+ described above.
562
+
563
+ Interoperation
564
+ ==============
565
+
566
+ Shapely provides 4 avenues for interoperation with other Python and GIS
567
+ software.
568
+
569
+ Well-known Formats
570
+ ------------------
571
+
572
+ Well-known Text (WKT)
573
+ +++++++++++++++++++++
574
+
575
+ The WKT representation of any geometry object can be had via the **wkt**
576
+ attribute:
577
+
578
+ .. code-block:: python
579
+
580
+ >>> point_r.wkt
581
+ 'POINT (-1.5000000000000000 1.2000000000000000)'
582
+
583
+ Hex-encode that string and you have a value that can be conveniently inserted directly into PostGIS
584
+
585
+ .. code-block:: python
586
+
587
+ >>> point_r.wkt.encode('hex')
588
+ '504f494e5420282d312e3530303030303030303030303030303020312e3230303030303030303030303030303029'
589
+
590
+ New geometries can be created from WKT representations using the
591
+ *shapely.wkt.loads* factory (inspired by the *pickle* module)
592
+
593
+ .. code-block:: python
594
+
595
+ >>> from shapely.wkt import loads
596
+ >>> loads('POINT (0 0)')
597
+ <shapely.geometry.point.Point object at ...>
598
+
599
+ Well-known Binary (WKB)
600
+ +++++++++++++++++++++++
601
+
602
+ The WKB representation of any geometry object can be had via the **wkb**
603
+ attribute. New geometries can be created from WKB data using the
604
+ *shapely.wkb.loads* factory. Use this format to interoperate with ogr.py:
605
+
606
+ .. code-block:: python
607
+
608
+ >>> import ogr
609
+ >>> from shapely.wkb import loads
610
+ >>> source = ogr.Open("/tmp/world_borders.shp")
611
+ >>> borders = source.GetLayerByName("world_borders")
612
+ >>> feature = borders.GetNextFeature()
613
+ >>> loads(feature.GetGeometryRef().ExportToWkb())
614
+ <shapely.geometry.polygon.Polygon object at ...>
615
+
616
+ Python Sequences
617
+ ----------------
618
+
619
+ Python sequence data can be analyzed as Shapely geometries using the
620
+ *shapely.geometry.as\** adapters while leaving the data in its original
621
+ storage. A pair of float can be treated as a point with **asPoint**:
622
+
623
+ .. code-block:: python
624
+
625
+ >>> from shapely.geometry import asPoint
626
+ >>> coords = [3.0, 4.0]
627
+ >>> pa = asPoint(coords)
628
+ >>> pa.wkt
629
+ 'POINT (3.0000000000000000 4.0000000000000000)'
630
+
631
+ Move the coordinates and watch the geometry adapter change
632
+
633
+ .. code-block:: python
634
+
635
+ >>> coords[0] = 1.0
636
+ >>> pa.wkt
637
+ 'POINT (1.0000000000000000 4.0000000000000000)'
638
+
639
+ The **asLineString** adapter works much the same. The **asPolygon** adapter is
640
+ used like
641
+
642
+ .. code-block:: python
643
+
644
+ >>> from shapely.geometry import asPolygon
645
+ >>> coords = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0]]
646
+ >>> hole_coords = [((0.1,0.1), (0.1,0.2), (0.2,0.2), (0.2,0.1))]
647
+ >>> pa = asPolygon(coords, hole_coords)
648
+ >>> len(pa.exterior.coords)
649
+ 5
650
+ >>> len(pa.interiors)
651
+ 1
652
+ >>> len(pa.interiors[0].coords)
653
+ 5
654
+
655
+ Numpy Array Interface
656
+ ---------------------
657
+
658
+ Shapely geometries provide the Numpy array interface which means that points,
659
+ line strings, and polygon rings can be used as Numpy arrays:
660
+
661
+ .. code-block:: python
662
+
663
+ >>> from numpy import array
664
+ >>> a = array(polygon.exterior)
665
+ >>> a
666
+ array([[-1., -1.],
667
+ [-1., 1.],
668
+ [ 1., 1.],
669
+ [ 1., -1.],
670
+ [-1., -1.]])
671
+
672
+ The *numpy.asarray* function does not copy coordinate values at the price of
673
+ slower numpy access to coordinates.
674
+
675
+ The *shapely.geometry.as\** functions can also be used to wrap numpy arrays,
676
+ which can then be analyzed using Shapely while maintaining their original
677
+ storage. A 1 x 2 array can be adapted to a point
678
+
679
+ .. code-block:: python
680
+
681
+ >>> a = array([1.0, 2.0])
682
+ >>> pa = asPoint(a)
683
+ >>> pa.wkt
684
+ 'POINT (1.0000000000000000 2.0000000000000000)'
685
+
686
+ and a N x 2 array can be adapted to a line string
687
+
688
+ .. code-block:: python
689
+
690
+ >>> from shapely.geometry import asLineString
691
+ >>> a = array([[1.0, 2.0], [3.0, 4.0]])
692
+ >>> la = asLineString(a)
693
+ >>> la.wkt
694
+ 'LINESTRING (1.0000000000000000 2.0000000000000000, 3.0000000000000000 4.0000000000000000)'
695
+
696
+ There is no Numpy array representation of a polygon.
697
+
698
+ Python Geo Interface
699
+ --------------------
700
+
701
+ Any object that provides the GeoJSON-like `Python geo interface`_ can be
702
+ adapted and used as a Shapely geometry using the *shapely.geometry.asShape*
703
+ function. For example, a dictionary:
704
+
705
+ .. code-block:: python
706
+
707
+ >>> from shapely.geometry import asShape
708
+ >>> d = {"type": "Point", "coordinates": (0.0, 0.0)}
709
+ >>> shape = asShape(d)
710
+ >>> shape.geom_type
711
+ 'Point'
712
+ >>> list(shape.coords)
713
+ [(0.0, 0.0)]
714
+
715
+ Or a simple placemark-type object:
716
+
717
+ .. code-block:: python
718
+
719
+ >>> class GeoThing(object):
720
+ ... def __init__(self, d):
721
+ ... self.__geo_interface__ = d
722
+ >>> thing = GeoThing({"type": "Point", "coordinates": (0.0, 0.0)})
723
+ >>> shape = asShape(thing)
724
+ >>> shape.geom_type
725
+ 'Point'
726
+ >>> list(shape.coords)
727
+ [(0.0, 0.0)]
728
+
729
+ .. _Python geo interface: http://trac.gispython.org/projects/PCL/wiki/PythonGeoInterface
730
+
731
+ Advanced Features
732
+ =================
733
+
734
+ Iterative Operations
735
+ --------------------
736
+
737
+ Shapely provides functions for efficient operations on large sets of
738
+ geometries.
739
+
740
+ Contains
741
+ ++++++++
742
+
743
+ To find the subset of points that are contained within a polygon, use
744
+ *shapely.iterops.contains*:
745
+
746
+ .. code-block:: python
747
+
748
+ >>> from shapely.geometry import Polygon
749
+ >>> from shapely.geometry import Point
750
+ >>> coords = ((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0))
751
+ >>> polygon = Polygon(coords)
752
+ >>> points = [Point(0.5, 0.5), Point(2.0, 2.0)]
753
+ >>> from shapely import iterops
754
+ >>> list(iterops.contains(polygon, points, True))
755
+ [<shapely.geometry.point.Point object at ...>]
756
+
757
+ The second parameter to *iterops.contains* can be any kind of iterator, even a
758
+ generator of objects. If it yields tuples, then the second element of the tuple
759
+ will be ultimately yielded from *iterops.contains*.
760
+
761
+ .. code-block:: python
762
+
763
+ >>> list(iterops.contains(polygon, iter((p, p.wkt) for p in points)))
764
+ ['POINT (0.5000000000000000 0.5000000000000000)']
765
+
766
+ Credits
767
+ =======
768
+
769
+ Shapely is written by Sean Gillies with contributions from Howard Butler, Kai
770
+ Lautaportti (Hexagon IT), Frédéric Junod (Camptocamp SA), Eric Lemoine
771
+ (Camptocamp SA) and ctypes tips from Justin Bronn (GeoDjango).
772
+
773
+
@@ -0,0 +1,231 @@
1
+ /* css */
2
+
3
+ body {
4
+ font: 90% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
5
+ background: #ffffff;
6
+ color: black;
7
+ margin: 2em;
8
+ padding: 2em;
9
+ }
10
+
11
+ a[href] {
12
+ color: #436976;
13
+ background-color: transparent;
14
+ }
15
+
16
+ a.toc-backref {
17
+ text-decoration: none;
18
+ }
19
+
20
+ h1 a[href] {
21
+ text-decoration: none;
22
+ color: #fcb100;
23
+ background-color: transparent;
24
+ }
25
+
26
+ a.strong {
27
+ font-weight: bold;
28
+ }
29
+
30
+ img {
31
+ margin: 0;
32
+ border: 0;
33
+ }
34
+
35
+ p {
36
+ margin: 0.5em 0 1em 0;
37
+ line-height: 1.5em;
38
+ }
39
+ p a {
40
+ text-decoration: underline;
41
+ }
42
+ p a:visited {
43
+ color: purple;
44
+ background-color: transparent;
45
+ }
46
+ p a:active {
47
+ color: red;
48
+ background-color: transparent;
49
+ }
50
+ a:hover {
51
+ text-decoration: none;
52
+ }
53
+ p img {
54
+ border: 0;
55
+ margin: 0;
56
+ }
57
+
58
+ h1, h2, h3, h4, h5, h6 {
59
+ color: #003a6b;
60
+ background-color: transparent;
61
+ font: 100% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
62
+ margin: 0;
63
+ padding-top: 0.5em;
64
+ }
65
+
66
+ h1 {
67
+ font-size: 160%;
68
+ margin-bottom: 0.5em;
69
+ border-bottom: 1px solid #fcb100;
70
+ }
71
+ h2 {
72
+ font-size: 140%;
73
+ margin-bottom: 0.5em;
74
+ border-bottom: 1px solid #aaa;
75
+ }
76
+ h3 {
77
+ font-size: 130%;
78
+ margin-bottom: 0.5em;
79
+ text-decoration: underline;
80
+ }
81
+ h4 {
82
+ font-size: 110%;
83
+ font-weight: bold;
84
+ }
85
+ h5 {
86
+ font-size: 100%;
87
+ font-weight: bold;
88
+ }
89
+ h6 {
90
+ font-size: 80%;
91
+ font-weight: bold;
92
+ }
93
+
94
+ ul a, ol a {
95
+ text-decoration: underline;
96
+ }
97
+
98
+ dt {
99
+ font-weight: bold;
100
+ }
101
+ dt a {
102
+ text-decoration: none;
103
+ }
104
+
105
+ dd {
106
+ line-height: 1.5em;
107
+ margin-bottom: 1em;
108
+ }
109
+
110
+ legend {
111
+ background: #ffffff;
112
+ padding: 0.5em;
113
+ }
114
+
115
+ form {
116
+ margin: 0;
117
+ }
118
+
119
+
120
+ dl.form {
121
+ margin: 0;
122
+ padding: 1em;
123
+ }
124
+
125
+ dl.form dt {
126
+ width: 30%;
127
+ float: left;
128
+ margin: 0;
129
+ padding: 0 0.5em 0.5em 0;
130
+ text-align: right;
131
+ }
132
+
133
+ input {
134
+ font: 100% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
135
+ color: black;
136
+ background-color: white;
137
+ vertical-align: middle;
138
+ }
139
+
140
+ abbr, acronym, .explain {
141
+ color: black;
142
+ background-color: transparent;
143
+ }
144
+
145
+ q, blockquote {
146
+ }
147
+
148
+ code, pre {
149
+ font-family: monospace;
150
+ font-size: 1.2em;
151
+ display: block;
152
+ padding: 10px;
153
+ border: 1px solid #838183;
154
+ background-color: #eee;
155
+ color: #000;
156
+ overflow: auto;
157
+ margin: 0.5em 1em;
158
+ }
159
+
160
+ tt.docutils {
161
+ background-color: #eeeeee;
162
+ }
163
+
164
+ .docinfo {
165
+ text-align: left;
166
+ }
167
+
168
+ div.highlight {
169
+ margin-left: 2em ;
170
+ margin-right: 2em ;
171
+ background-color: #eeeeee
172
+ }
173
+
174
+ .c { color: #008800; font-style: italic } /* Comment */
175
+ .err { border: 1px solid #FF0000 } /* Error */
176
+ .k { color: #AA22FF; font-weight: bold } /* Keyword */
177
+ .o { color: #666666 } /* Operator */
178
+ .cm { color: #008800; font-style: italic } /* Comment.Multiline */
179
+ .cp { color: #008800 } /* Comment.Preproc */
180
+ .c1 { color: #008800; font-style: italic } /* Comment.Single */
181
+ .gd { color: #A00000 } /* Generic.Deleted */
182
+ .ge { font-style: italic } /* Generic.Emph */
183
+ .gr { color: #FF0000 } /* Generic.Error */
184
+ .gh { color: #000080; font-weight: bold } /* Generic.Heading */
185
+ .gi { color: #00A000 } /* Generic.Inserted */
186
+ .go { color: #808080 } /* Generic.Output */
187
+ .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
188
+ .gs { font-weight: bold } /* Generic.Strong */
189
+ .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
190
+ .gt { color: #0040D0 } /* Generic.Traceback */
191
+ .kc { color: #AA22FF; font-weight: bold } /* Keyword.Constant */
192
+ .kd { color: #AA22FF; font-weight: bold } /* Keyword.Declaration */
193
+ .kp { color: #AA22FF } /* Keyword.Pseudo */
194
+ .kr { color: #AA22FF; font-weight: bold } /* Keyword.Reserved */
195
+ .kt { color: #AA22FF; font-weight: bold } /* Keyword.Type */
196
+ .m { color: #666666 } /* Literal.Number */
197
+ .s { color: #BB4444 } /* Literal.String */
198
+ .na { color: #BB4444 } /* Name.Attribute */
199
+ .nb { color: #AA22FF } /* Name.Builtin */
200
+ .nc { color: #0000FF } /* Name.Class */
201
+ .no { color: #880000 } /* Name.Constant */
202
+ .nd { color: #AA22FF } /* Name.Decorator */
203
+ .ni { color: #999999; font-weight: bold } /* Name.Entity */
204
+ .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
205
+ .nf { color: #00A000 } /* Name.Function */
206
+ .nl { color: #A0A000 } /* Name.Label */
207
+ .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
208
+ .nt { color: #008000; font-weight: bold } /* Name.Tag */
209
+ .nv { color: #B8860B } /* Name.Variable */
210
+ .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
211
+ .mf { color: #666666 } /* Literal.Number.Float */
212
+ .mh { color: #666666 } /* Literal.Number.Hex */
213
+ .mi { color: #666666 } /* Literal.Number.Integer */
214
+ .mo { color: #666666 } /* Literal.Number.Oct */
215
+ .sb { color: #BB4444 } /* Literal.String.Backtick */
216
+ .sc { color: #BB4444 } /* Literal.String.Char */
217
+ .sd { color: #BB4444; font-style: italic } /* Literal.String.Doc */
218
+ .s2 { color: #BB4444 } /* Literal.String.Double */
219
+ .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
220
+ .sh { color: #BB4444 } /* Literal.String.Heredoc */
221
+ .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
222
+ .sx { color: #008000 } /* Literal.String.Other */
223
+ .sr { color: #BB6688 } /* Literal.String.Regex */
224
+ .s1 { color: #BB4444 } /* Literal.String.Single */
225
+ .ss { color: #B8860B } /* Literal.String.Symbol */
226
+ .bp { color: #AA22FF } /* Name.Builtin.Pseudo */
227
+ .vc { color: #B8860B } /* Name.Variable.Class */
228
+ .vg { color: #B8860B } /* Name.Variable.Global */
229
+ .vi { color: #B8860B } /* Name.Variable.Instance */
230
+ .il { color: #666666 } /* Literal.Number.Integer.Long */
231
+
@@ -1,11 +1,17 @@
1
1
 
2
2
  from setuptools import setup, Extension
3
+ from sys import version_info
4
+
5
+ # Require ctypes egg only for Python < 2.5
6
+ install_requires = ['setuptools']
7
+ if version_info[:2] < (2,5):
8
+ install_requires.append('ctypes')
3
9
 
4
10
  # Get text from README.txt
5
11
  readme_text = file('README.txt', 'rb').read()
6
12
 
7
13
  setup(name = 'Shapely',
8
- version = '1.0b2',
14
+ version = '1.0b3',
9
15
  description = 'Geospatial geometries, predicates, and operations',
10
16
  license = 'BSD',
11
17
  keywords = 'geometry topology',
@@ -16,7 +22,7 @@ setup(name = 'Shapely',
16
22
  url = 'http://trac.gispython.org/projects/PCL/wiki/Shapely',
17
23
  long_description = readme_text,
18
24
  packages = ['shapely', 'shapely.geometry'],
19
- install_requires = ['setuptools', 'ctypes'],
25
+ install_requires = install_requires,
20
26
  #tests_require = ['numpy'], -- not working with "tests" command
21
27
  test_suite = 'tests.test_suite',
22
28
  classifiers = [
@@ -399,7 +399,7 @@ class PolygonAdapter(Polygon):
399
399
  return geos_polygon_from_py(self.shell, self.holes)[0]
400
400
 
401
401
 
402
- def asPolygon(shell, holes):
402
+ def asPolygon(shell, holes=None):
403
403
  """Factory for PolygonAdapter instances."""
404
404
  return PolygonAdapter(shell, holes)
405
405
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes