3

Currently this excerpt of code will not save to file (as it is supposed to).

The memory layer is visible and editable. Yet even when manually saving the layer, any priorly added features (geometries) are non-present.

The variables 'FileDirectory._destination' and 'GetMaps._TOPOcrs' are proper as confirmed via the print command.

It should be noted, that the error prompt for the FileWriter indeed reads an error with the value '1'.

Any clues?

try:
    self.estabLocal()
except ValueError:
    iface.messageBar().pushMessage("Error", "Please select a central folder location to save your model to!", level=QgsMessageBar.CRITICAL, duration=3)
    return
try:
    self.estabCRS()
except ValueError:
    iface.messageBar().pushMessage("Error", "Please select a topographic map for your simulation!", level=QgsMessageBar.CRITICAL, duration=3)
    return
pointstress = QgsVectorLayer("Point?crs=" + GetMaps._TOPOcrs + "&field=Well:string(3)&field=Discharge:string(6)&index=yes", "Points" , "memory")
pr = pointstress.dataProvider()
QgsMapLayerRegistry.instance().addMapLayers([pointstress])
PointStressFeat = FindDirectory._destination+"Points.shp"
writer = QgsVectorFileWriter(PointStressFeat, "CP1250", pr.fields(), QGis.WKBPoint, pr.crs(), "ESRI Shapefile" )
if writer.hasError() != QgsVectorFileWriter.NoError:
    print "Error when creating shapefile: ", writer.hasError()
iface.setActiveLayer(pointstress)
pointstress.startEditing()
iface.actionAddFeature().trigger()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.