-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestUtils.py
23 lines (19 loc) · 954 Bytes
/
TestUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from qgis.core import *
from PyQt4.QtCore import *
def layerFromGeom(geometry, name):
layer = QgsVectorLayer('Polygon?crs=epsg:4326&index=yes', 'simplified', 'memory')
feat = QgsFeature()
feat.setGeometry(geometry)
layer.dataProvider().addFeatures([feat])
QgsVectorFileWriter.writeAsVectorFormat(layer, 'C:\Users\Attila\Documents\\test\\'+name+'.shp', 'CP1250', None)
def layerFromLayer(layer, name):
QgsVectorFileWriter.writeAsVectorFormat(layer, 'C:\Users\Attila\Documents\\test\\'+name+'.shp', 'CP1250', None)
def layerFromGeomList(list, name):
layer = QgsVectorLayer('Polygon?crs=epsg:4326&index=yes', 'simplified', 'memory')
features = []
for geom in list:
feat = QgsFeature()
feat.setGeometry(geom)
features.append(feat)
layer.dataProvider().addFeatures(features)
QgsVectorFileWriter.writeAsVectorFormat(layer, 'C:\Users\Attila\Documents\\test\\'+name+'.shp', 'CP1250', None)