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 (EDIT: is fixed now..):

#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
##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(line_start.x()+x_add, line_start.y()+y_add)
    outFeat = QgsFeature()
    outFeat.setGeometry(QgsGeometry.fromPolyline([line_start, line_end]))

del writer

Furthermore 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.

1 Answer 1


Method getobject() cannot be found in module processing because the method is named getObject() (mention the big O). Try getFeatures() in the following line, it is the same problem here.

  • Was there a syntax-change? I took this snippet from another script where it was working.. Anyways, I changed both syntax errors, but now I get 'module' object has no attribute 'getFeatures'
    – Kay
    Apr 28, 2015 at 14:34
  • ..it turns out that there was a change! See gis.stackexchange.com/questions/98066/…..
    – Kay
    May 20, 2015 at 15:35
  • ..I fixed the syntax error. However the original questions remains. How to get the segments in map units?
    – Kay
    May 20, 2015 at 15:36
  • Problem, solved - it turned out that of course it is map units that are used here, and that it was only my unprojected CRS that led to false distances..
    – Kay
    May 20, 2015 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.