/usr/share/pyshared/shapely/examples/geoms.py is in python-shapely 1.2.14-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from numpy import asarray
import pylab
from shapely.geometry import Point, LineString, Polygon
polygon = Polygon(((-1.0, -1.0), (-1.0, 1.0), (1.0, 1.0), (1.0, -1.0)))
point_r = Point(-1.5, 1.2)
point_g = Point(-1.0, 1.0)
point_b = Point(-0.5, 0.5)
line_r = LineString(((-0.5, 0.5), (0.5, 0.5)))
line_g = LineString(((1.0, -1.0), (1.8, 0.5)))
line_b = LineString(((-1.8, -1.2), (1.8, 0.5)))
def plot_point(g, o, l):
pylab.plot([g.x], [g.y], o, label=l)
def plot_line(g, o):
a = asarray(g)
pylab.plot(a[:,0], a[:,1], o)
def fill_polygon(g, o):
a = asarray(g.exterior)
pylab.fill(a[:,0], a[:,1], o, alpha=0.5)
def fill_multipolygon(g, o):
for g in g.geoms:
fill_polygon(g, o)
if __name__ == "__main__":
from numpy import asarray
import pylab
fig = pylab.figure(1, figsize=(4, 3), dpi=150)
#pylab.axis([-2.0, 2.0, -1.5, 1.5])
pylab.axis('tight')
a = asarray(polygon.exterior)
pylab.fill(a[:,0], a[:,1], 'c')
plot_point(point_r, 'ro', 'b')
plot_point(point_g, 'go', 'c')
plot_point(point_b, 'bo', 'd')
plot_line(line_r, 'r')
plot_line(line_g, 'g')
plot_line(line_b, 'b')
pylab.show()
|