shapely 1.2b5__tar.gz → 1.2b6__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.
- {Shapely-1.2b5 → Shapely-1.2b6}/CHANGES.txt +4 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/PKG-INFO +4 -4
- {Shapely-1.2b5 → Shapely-1.2b6}/README.txt +3 -3
- {Shapely-1.2b5 → Shapely-1.2b6}/Shapely.egg-info/PKG-INFO +4 -4
- Shapely-1.2b6/examples/dissolve.py +53 -0
- Shapely-1.2b6/examples/intersect.py +81 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/setup.py +1 -1
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/base.py +12 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/collection.py +1 -1
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/__init__.py +2 -0
- Shapely-1.2b5/examples/dissolve.py +0 -52
- Shapely-1.2b5/examples/intersect.py +0 -80
- {Shapely-1.2b5 → Shapely-1.2b6}/CREDITS.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/LICENSE.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/MANIFEST.in +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/Shapely.egg-info/SOURCES.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/Shapely.egg-info/dependency_links.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/Shapely.egg-info/top_level.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/setup.cfg +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/__init__.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/coords.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/ctypes_declarations.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/__init__.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/geo.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/linestring.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/multilinestring.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/multipoint.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/multipolygon.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/point.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/polygon.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geometry/proxy.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geoms.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/geos.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/impl.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/iterops.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/linref.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/ops.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/predicates.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/prepared.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Array.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/GeoInterface.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/IterOps.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/LineString.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/MultiLineString.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/MultiPoint.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/MultiPolygon.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Operations.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Persist.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Point.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Polygon.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/Predicates.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/attribute-chains.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/binascii_hex.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/dimensions.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/invalid_intersection.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/linear-referencing.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/linemerge.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/polygonize.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/test_doctests.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/test_equality.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/test_geomseq.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/test_prepared.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/test_xy.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/threading_test.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/tests/wkt_locale.txt +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/topology.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/wkb.py +0 -0
- {Shapely-1.2b5 → Shapely-1.2b6}/shapely/wkt.py +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
All tickets are children of http://trac.gispython.org/lab/ticket.
|
|
2
2
|
|
|
3
|
+
1.2b6 (2010-04-13)
|
|
4
|
+
------------------
|
|
5
|
+
- Broken GeometryCollection fixed.
|
|
6
|
+
|
|
3
7
|
1.2b5 (2010-04-09)
|
|
4
8
|
------------------
|
|
5
9
|
- Objects can be constructed from others of the same type, thereby making
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2b6
|
|
4
4
|
Summary: Planar geometries, predicates, and operations
|
|
5
5
|
Home-page: http://trac.gispython.org/lab/wiki/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
@@ -10,9 +10,9 @@ Description:
|
|
|
10
10
|
Shapely
|
|
11
11
|
=======
|
|
12
12
|
|
|
13
|
-
.. image:: http://
|
|
14
|
-
:width:
|
|
15
|
-
:height:
|
|
13
|
+
.. image:: http://farm3.static.flickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
14
|
+
:width: 800
|
|
15
|
+
:height: 400
|
|
16
16
|
|
|
17
17
|
Shapely is a BSD-licensed Python package for manipulation and analysis of
|
|
18
18
|
planar geometries. It is not concerned with data formats or coordinate
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Shapely
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
-
.. image:: http://
|
|
6
|
-
:width:
|
|
7
|
-
:height:
|
|
5
|
+
.. image:: http://farm3.static.flickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
6
|
+
:width: 800
|
|
7
|
+
:height: 400
|
|
8
8
|
|
|
9
9
|
Shapely is a BSD-licensed Python package for manipulation and analysis of
|
|
10
10
|
planar geometries. It is not concerned with data formats or coordinate
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.0
|
|
2
2
|
Name: Shapely
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2b6
|
|
4
4
|
Summary: Planar geometries, predicates, and operations
|
|
5
5
|
Home-page: http://trac.gispython.org/lab/wiki/Shapely
|
|
6
6
|
Author: Sean Gillies
|
|
@@ -10,9 +10,9 @@ Description:
|
|
|
10
10
|
Shapely
|
|
11
11
|
=======
|
|
12
12
|
|
|
13
|
-
.. image:: http://
|
|
14
|
-
:width:
|
|
15
|
-
:height:
|
|
13
|
+
.. image:: http://farm3.static.flickr.com/2738/4511827859_b5822043b7_o_d.png
|
|
14
|
+
:width: 800
|
|
15
|
+
:height: 400
|
|
16
16
|
|
|
17
17
|
Shapely is a BSD-licensed Python package for manipulation and analysis of
|
|
18
18
|
planar geometries. It is not concerned with data formats or coordinate
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# dissolve.py
|
|
2
|
+
#
|
|
3
|
+
# Demonstrate how Shapely can be used to build up a collection of patches by
|
|
4
|
+
# dissolving circular regions and how Shapely supports plotting of the results.
|
|
5
|
+
|
|
6
|
+
from functools import partial
|
|
7
|
+
import random
|
|
8
|
+
|
|
9
|
+
import pylab
|
|
10
|
+
|
|
11
|
+
from shapely.geometry import Point
|
|
12
|
+
from shapely.ops import cascaded_union
|
|
13
|
+
|
|
14
|
+
# Use a partial function to make 100 points uniformly distributed in a 40x40
|
|
15
|
+
# box centered on 0,0.
|
|
16
|
+
r = partial(random.uniform, -20.0, 20.0)
|
|
17
|
+
points = [Point(r(), r()) for i in range(100)]
|
|
18
|
+
|
|
19
|
+
# Buffer the points, producing 100 polygon spots
|
|
20
|
+
spots = [p.buffer(2.5) for p in points]
|
|
21
|
+
|
|
22
|
+
# Perform a cascaded union of the polygon spots, dissolving them into a
|
|
23
|
+
# collection of polygon patches
|
|
24
|
+
patches = cascaded_union(spots)
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
# Illustrate the results using matplotlib's pylab interface
|
|
28
|
+
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
29
|
+
|
|
30
|
+
for patch in patches.geoms:
|
|
31
|
+
assert patch.geom_type in ['Polygon']
|
|
32
|
+
assert patch.is_valid
|
|
33
|
+
|
|
34
|
+
# Fill and outline each patch
|
|
35
|
+
x, y = patch.exterior.xy
|
|
36
|
+
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
37
|
+
pylab.plot(x, y, color='#666666', aa=True, lw=1.0)
|
|
38
|
+
|
|
39
|
+
# Do the same for the holes of the patch
|
|
40
|
+
for hole in patch.interiors:
|
|
41
|
+
x, y = hole.xy
|
|
42
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
43
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
44
|
+
|
|
45
|
+
# Plot the original points
|
|
46
|
+
pylab.plot([p.x for p in points], [p.y for p in points], 'b,', alpha=0.75)
|
|
47
|
+
|
|
48
|
+
# Write the number of patches and the total patch area to the figure
|
|
49
|
+
pylab.text(-25, 25,
|
|
50
|
+
"Patches: %d, total area: %.2f" % (len(patches.geoms), patches.area))
|
|
51
|
+
|
|
52
|
+
pylab.savefig('dissolve.png')
|
|
53
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# intersect.py
|
|
2
|
+
#
|
|
3
|
+
# Demonstrate how Shapely can be used to analyze and plot the intersection of
|
|
4
|
+
# a trajectory and regions in space.
|
|
5
|
+
|
|
6
|
+
from functools import partial
|
|
7
|
+
import random
|
|
8
|
+
|
|
9
|
+
import pylab
|
|
10
|
+
|
|
11
|
+
from shapely.geometry import LineString, Point
|
|
12
|
+
from shapely.ops import cascaded_union
|
|
13
|
+
|
|
14
|
+
# Build patches as in dissolved.py
|
|
15
|
+
r = partial(random.uniform, -20.0, 20.0)
|
|
16
|
+
points = [Point(r(), r()) for i in range(100)]
|
|
17
|
+
spots = [p.buffer(2.5) for p in points]
|
|
18
|
+
patches = cascaded_union(spots)
|
|
19
|
+
|
|
20
|
+
# Represent the following geolocation parameters
|
|
21
|
+
#
|
|
22
|
+
# initial position: -25, -25
|
|
23
|
+
# heading: 45.0
|
|
24
|
+
# speed: 50*sqrt(2)
|
|
25
|
+
#
|
|
26
|
+
# as a line
|
|
27
|
+
vector = LineString(((-25.0, -25.0), (25.0, 25.0)))
|
|
28
|
+
|
|
29
|
+
# Find intercepted and missed patches. List the former so we can count them
|
|
30
|
+
# later
|
|
31
|
+
intercepts = [patch for patch in patches.geoms if vector.intersects(patch)]
|
|
32
|
+
misses = (patch for patch in patches.geoms if not vector.intersects(patch))
|
|
33
|
+
|
|
34
|
+
# Plot the intersection
|
|
35
|
+
intersection = vector.intersection(patches)
|
|
36
|
+
assert intersection.geom_type in ['MultiLineString']
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
# Illustrate the results using matplotlib's pylab interface
|
|
40
|
+
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
41
|
+
|
|
42
|
+
# Plot the misses
|
|
43
|
+
for spot in misses:
|
|
44
|
+
x, y = spot.exterior.xy
|
|
45
|
+
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
46
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
47
|
+
|
|
48
|
+
# Do the same for the holes of the patch
|
|
49
|
+
for hole in spot.interiors:
|
|
50
|
+
x, y = hole.xy
|
|
51
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
52
|
+
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
53
|
+
|
|
54
|
+
# Plot the intercepts
|
|
55
|
+
for spot in intercepts:
|
|
56
|
+
x, y = spot.exterior.xy
|
|
57
|
+
pylab.fill(x, y, color='red', alpha=0.25, aa=True)
|
|
58
|
+
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
59
|
+
|
|
60
|
+
# Do the same for the holes of the patch
|
|
61
|
+
for hole in spot.interiors:
|
|
62
|
+
x, y = hole.xy
|
|
63
|
+
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
64
|
+
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
65
|
+
|
|
66
|
+
# Draw the projected trajectory
|
|
67
|
+
pylab.arrow(-25, -25, 50, 50, color='#999999', aa=True,
|
|
68
|
+
head_width=1.0, head_length=1.0)
|
|
69
|
+
|
|
70
|
+
for segment in intersection.geoms:
|
|
71
|
+
x, y = segment.xy
|
|
72
|
+
pylab.plot(x, y, color='red', aa=True, lw=1.5)
|
|
73
|
+
|
|
74
|
+
# Write the number of patches and the total patch area to the figure
|
|
75
|
+
pylab.text(-28, 25,
|
|
76
|
+
"Patches: %d/%d (%d), total length: %.1f" \
|
|
77
|
+
% (len(intercepts), len(patches.geoms),
|
|
78
|
+
len(intersection.geoms), intersection.length))
|
|
79
|
+
|
|
80
|
+
pylab.savefig('intersect.png')
|
|
81
|
+
|
|
@@ -16,7 +16,7 @@ readme_text = file('README.txt', 'rb').read()
|
|
|
16
16
|
setup_args = dict(
|
|
17
17
|
metadata_version = '1.2',
|
|
18
18
|
name = 'Shapely',
|
|
19
|
-
version = '1.
|
|
19
|
+
version = '1.2b6',
|
|
20
20
|
requires_python = '>=2.5,<3',
|
|
21
21
|
requires_external = 'libgeos_c (>=3.1)',
|
|
22
22
|
description = 'Planar geometries, predicates, and operations',
|
|
@@ -460,6 +460,18 @@ class BaseMultipartGeometry(BaseGeometry):
|
|
|
460
460
|
else:
|
|
461
461
|
return iter([])
|
|
462
462
|
|
|
463
|
+
def __len__(self):
|
|
464
|
+
if not self.is_empty:
|
|
465
|
+
return len(self.geoms)
|
|
466
|
+
else:
|
|
467
|
+
return 0
|
|
468
|
+
|
|
469
|
+
def __getitem__(self, index):
|
|
470
|
+
if not self.is_empty:
|
|
471
|
+
return self.geoms[index]
|
|
472
|
+
else:
|
|
473
|
+
return ()[index]
|
|
474
|
+
|
|
463
475
|
|
|
464
476
|
class GeometrySequence(object):
|
|
465
477
|
"""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from unittest import TestSuite
|
|
2
2
|
|
|
3
3
|
import test_doctests, test_prepared, test_equality, test_geomseq, test_xy
|
|
4
|
+
import test_collection
|
|
4
5
|
|
|
5
6
|
def test_suite():
|
|
6
7
|
suite = TestSuite()
|
|
@@ -9,5 +10,6 @@ def test_suite():
|
|
|
9
10
|
suite.addTest(test_equality.test_suite())
|
|
10
11
|
suite.addTest(test_geomseq.test_suite())
|
|
11
12
|
suite.addTest(test_xy.test_suite())
|
|
13
|
+
suite.addTest(test_collection.test_suite())
|
|
12
14
|
return suite
|
|
13
15
|
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# dissolve.py
|
|
2
|
-
#
|
|
3
|
-
# Demonstrate how Shapely can be used to build up a collection of patches by
|
|
4
|
-
# dissolving circular regions and how Shapely supports plotting of the results.
|
|
5
|
-
|
|
6
|
-
from functools import partial
|
|
7
|
-
import random
|
|
8
|
-
|
|
9
|
-
import pylab
|
|
10
|
-
|
|
11
|
-
from shapely.geometry import Point
|
|
12
|
-
from shapely.ops import cascaded_union
|
|
13
|
-
|
|
14
|
-
# Use a partial function to make 100 points uniformly distributed in a 40x40
|
|
15
|
-
# box centered on 0,0.
|
|
16
|
-
r = partial(random.uniform, -20.0, 20.0)
|
|
17
|
-
points = [Point(r(), r()) for i in range(100)]
|
|
18
|
-
|
|
19
|
-
# Buffer the points, producing 100 polygon spots
|
|
20
|
-
spots = [p.buffer(2.5) for p in points]
|
|
21
|
-
|
|
22
|
-
# Perform a cascaded union of the polygon spots, dissolving them into a
|
|
23
|
-
# collection of polygon patches
|
|
24
|
-
patches = cascaded_union(spots)
|
|
25
|
-
|
|
26
|
-
# Illustrate the results using matplotlib's pylab interface
|
|
27
|
-
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
28
|
-
|
|
29
|
-
for patch in patches.geoms:
|
|
30
|
-
assert patch.geom_type in ['Polygon']
|
|
31
|
-
assert patch.is_valid
|
|
32
|
-
|
|
33
|
-
# Fill and outline each patch
|
|
34
|
-
x, y = patch.exterior.xy
|
|
35
|
-
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
36
|
-
pylab.plot(x, y, color='#666666', aa=True, lw=1.0)
|
|
37
|
-
|
|
38
|
-
# Do the same for the holes of the patch
|
|
39
|
-
for hole in patch.interiors:
|
|
40
|
-
x, y = hole.xy
|
|
41
|
-
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
42
|
-
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
43
|
-
|
|
44
|
-
# Plot the original points
|
|
45
|
-
pylab.plot([p.x for p in points], [p.y for p in points], 'b,', alpha=0.75)
|
|
46
|
-
|
|
47
|
-
# Write the number of patches and the total patch area to the figure
|
|
48
|
-
pylab.text(-25, 25,
|
|
49
|
-
"Patches: %d, total area: %.2f" % (len(patches.geoms), patches.area))
|
|
50
|
-
|
|
51
|
-
pylab.savefig('dissolve.png')
|
|
52
|
-
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# intersect.py
|
|
2
|
-
#
|
|
3
|
-
# Demonstrate how Shapely can be used to analyze and plot the intersection of
|
|
4
|
-
# a trajectory and regions in space.
|
|
5
|
-
|
|
6
|
-
from functools import partial
|
|
7
|
-
import random
|
|
8
|
-
|
|
9
|
-
import pylab
|
|
10
|
-
|
|
11
|
-
from shapely.geometry import LineString, Point
|
|
12
|
-
from shapely.ops import cascaded_union
|
|
13
|
-
|
|
14
|
-
# Build patches as in dissolved.py
|
|
15
|
-
r = partial(random.uniform, -20.0, 20.0)
|
|
16
|
-
points = [Point(r(), r()) for i in range(100)]
|
|
17
|
-
spots = [p.buffer(2.5) for p in points]
|
|
18
|
-
patches = cascaded_union(spots)
|
|
19
|
-
|
|
20
|
-
# Represent the following geolocation parameters
|
|
21
|
-
#
|
|
22
|
-
# initial position: -25, -25
|
|
23
|
-
# heading: 45.0
|
|
24
|
-
# speed: 50*sqrt(2)
|
|
25
|
-
#
|
|
26
|
-
# as a line
|
|
27
|
-
vector = LineString(((-25.0, -25.0), (25.0, 25.0)))
|
|
28
|
-
|
|
29
|
-
# Find intercepted and missed patches. List the former so we can count them
|
|
30
|
-
# later
|
|
31
|
-
intercepts = [patch for patch in patches.geoms if vector.intersects(patch)]
|
|
32
|
-
misses = (patch for patch in patches.geoms if not vector.intersects(patch))
|
|
33
|
-
|
|
34
|
-
# Illustrate the results using matplotlib's pylab interface
|
|
35
|
-
pylab.figure(num=None, figsize=(4, 4), dpi=180)
|
|
36
|
-
|
|
37
|
-
# Plot the misses
|
|
38
|
-
for spot in misses:
|
|
39
|
-
x, y = spot.exterior.xy
|
|
40
|
-
pylab.fill(x, y, color='#cccccc', aa=True)
|
|
41
|
-
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
42
|
-
|
|
43
|
-
# Do the same for the holes of the patch
|
|
44
|
-
for hole in spot.interiors:
|
|
45
|
-
x, y = hole.xy
|
|
46
|
-
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
47
|
-
pylab.plot(x, y, color='#999999', aa=True, lw=1.0)
|
|
48
|
-
|
|
49
|
-
# Plot the intercepts
|
|
50
|
-
for spot in intercepts:
|
|
51
|
-
x, y = spot.exterior.xy
|
|
52
|
-
pylab.fill(x, y, color='red', alpha=0.25, aa=True)
|
|
53
|
-
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
54
|
-
|
|
55
|
-
# Do the same for the holes of the patch
|
|
56
|
-
for hole in spot.interiors:
|
|
57
|
-
x, y = hole.xy
|
|
58
|
-
pylab.fill(x, y, color='#ffffff', aa=True)
|
|
59
|
-
pylab.plot(x, y, color='red', alpha=0.5, aa=True, lw=1.0)
|
|
60
|
-
|
|
61
|
-
# Draw the projected trajectory
|
|
62
|
-
pylab.arrow(-25, -25, 50, 50, color='#999999', aa=True,
|
|
63
|
-
head_width=1.0, head_length=1.0)
|
|
64
|
-
|
|
65
|
-
# Plot the intersection
|
|
66
|
-
intersection = vector.intersection(patches)
|
|
67
|
-
assert intersection.geom_type in ['MultiLineString']
|
|
68
|
-
|
|
69
|
-
for segment in intersection.geoms:
|
|
70
|
-
x, y = segment.xy
|
|
71
|
-
pylab.plot(x, y, color='red', aa=True, lw=1.5)
|
|
72
|
-
|
|
73
|
-
# Write the number of patches and the total patch area to the figure
|
|
74
|
-
pylab.text(-28, 25,
|
|
75
|
-
"Patches: %d/%d (%d), total length: %.1f" \
|
|
76
|
-
% (len(intercepts), len(patches.geoms),
|
|
77
|
-
len(intersection.geoms), intersection.length))
|
|
78
|
-
|
|
79
|
-
pylab.savefig('intersect.png')
|
|
80
|
-
|
|
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
|
|
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
|