QGIS processing script: Move points by specified distance and add segment

المشرف العام

Administrator
طاقم الإدارة
I try to move points (they come as WGS84, but I'm not sure if it works with unprojected CRS) by a specified distance and connect original and new point with a line segment with the below script, but get an error:

#ERROR: 'module' object has no attribute 'getobject' --> fixed syntax error!from PyQt4.QtCore import *from qgis.core import *from processing.core.VectorWriter import VectorWriter#====================================##[User scripts]=group##input=vector##output=output vector##x_add=number 100##y_add=number 100#====================================inputLayer = processing.getObject(input) # formerly getobject()features = processing.features(inputLayer) # formerly getFeatures()provider = inputLayer.dataProvider()writer = VectorWriter(output, None, provider.fields(), WKBLineString , inputLayer.crs())for ft in features: line_start = ft.geometry().asPoint() line_end = QgsPoint(pt.x()+x_add, pt.y()+y_add) outFeat = QgsFeature() outFeat.setGeometry(QgsGeometry.fromPolyline([line_start, line_end])) writer.addFeature(outFeat)del writerFurthermore I'd like to be able to move points by specifying the distance in map units (m), I'm not sure if this is what's actually happening here..

Any help is greatly appreciated!



أكثر...
 
أعلى