我想使用shapefile
available through生成一个带有五个点的 .shp pyshp
。但是,当我遍历我的列表时,我只得到最后一个值。这是有道理的,因为我没有将任何点附加到空列表(例如new_shp = []
)
import shapefile as sf
import os
filename2 = 'test/point10'
lis = [(33.21, -122.15, 'france'), (35.31, -122.15, 'germany'), (35.41, -123.15, 'Hawaii'), (30.51, -122.15, 'Philippines'),(32.30, -122.15, 'Texas')]
for l in lis:
w = sf.Writer(sf.POINT)
w.point(l[0], l[1])
w.field('location')
w.record(l[2], 'Point')
w.save(filename2)
# create the PRJ file
prj = open("%s.prj" % filename2, "w")
epsg = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'
prj.write(epsg)
prj.close()
我假设我必须在 for 循环中的某处附加所有点,但我不明白如何实际附加它。我如何有效地循环lis
获取所有五个点的 .shp 文件?