-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFarmlandPolygonLayer.py
More file actions
37 lines (30 loc) · 1.13 KB
/
FarmlandPolygonLayer.py
File metadata and controls
37 lines (30 loc) · 1.13 KB
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
# coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import skimage.io as io
from skimage import measure, data, color
from shapely.geometry import Polygon
class FarmlandPolygonLayer(object):
# 有点类似其它高级语言的构造函数
def __init__(self, filePath):
self.filePath = filePath
self.f = open(filePath, 'w')
self.f.write("_=moduleid:Integer,date:String,location:Geometry:srid=4326\n")
# 写多边形
def wirte(self, moduleid, date, polygon):
self.f.write('stations.%d=%d|%s|%s\n' % (moduleid,moduleid, date, polygon))
# 写多边形
def wirteList(self,moduleid, date, polygons):
for polygon in polygons:
self.wirte(moduleid, date, polygon)
# 保存
def save(self):
self.f.close()
# def main():
# obj = WritePolygon("")
# obj.wirte(3046, "2017-12-03", "POLYGON ((120.0085836909871 40.00504291845493, 120.0085622317597 40.00502145922747, 120.0085836909871 40.005, 120.0086051502146 40.00502145922747, 120.0085836909871 40.00504291845493))")
# obj.save()
#
#
# main()