1
# Take in the shapefile given and convert to .geo file.
4
import matplotlib.pyplot as pyplot
7
r = shapefile.Reader("large-area")
9
# Take in the shape info of the objects.
11
print shapes[0].points
13
for j in range(len(shapes[0].parts)-1):
15
for i in range(shapes[0].parts[j], shapes[0].parts[j + 1]):
16
x.append(shapes[0].points[i][0]); y.append(shapes[0].points[i][1])
21
for i in range(shapes[0].parts[0], shapes[0].parts[1]):
22
x.append(shapes[0].points[i][0]); y.append(shapes[0].points[i][1])
29
# Arbitrarily pick the 4th entry.
30
#Write the .geo file from the data read.
31
target = open("python.geo", "w") # Creates python.geo file to write to.
32
for i in range(len(shapes[3].points)):
33
target.write('Point(%d) = {%.3f, %.3f, 0, %.3f};\n' %(i + 1, shapes[3].points[i][0], shapes[3].points[i][1], 1.0))