Thanks William! All is working now. Chris - here's what is working for me: https://gist.github.com/dmofot/94345126db10660053ccfb0d76a1e32a
and I'm just passing the layers (full path) into the script. For example, /Users/<user>/Documents/<shp_filename.shp> DT On Mon, Aug 6, 2018 at 11:03 AM, Chris B <snowsto...@mac.com> wrote: > Thanks so much for helping out with this. > > The script now no longer fails looking for Qt, great! > > But I'm still getting a very basic error -- loading a layer from the file > system doesn't work. Here's the script: > > import sys > > sys.path.insert(0,'/Applications/QGIS3.app/Contents/Frameworks/') > sys.path.insert(0,'/Applications/QGIS3.app/Contents/Resources/python/') > sys.path.insert(0,'/Applications/QGIS3.app/Contents/Resources/python/ > plugins') > > from qgis.core import ( > QgsApplication, > QgsProcessingFeedback, > QgsVectorLayer > ) > from qgis.analysis import QgsNativeAlgorithms > > # Start the QGIS App > > qgs = QgsApplication([], False) > qgs.initQgis() > > # Start Processing plugin > > import processing > from processing.core.Processing import Processing > Processing.initialize() > QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) > > # Load Layer > > layer = QgsVectorLayer('21185.shp', 'my layer', 'ogr') > > if not layer.isValid(): > print("Layer failed to load!") > > # Set parameters > > params = { > 'INPUT': layer, > 'OUTPUT': 'memory:' > } > feedback = QgsProcessingFeedback() > > # Run processing algorithm > > res = processing.run("native:extractvertices", params, feedback=feedback) > res['OUTPUT'] # Access your output layer > > When I test for layer validity, it says the layer fails to load and then > segfaults (which makes sense since the object is null). > > I tried referring to the file locally (eg. 'file.shp') and from the root of > the drive ('/Users/[user]/path/to/script/file.shp') and neither worked. > > Am I missing something for QgsVectorLayer to work? Seems like an odd > error. > > Thanks again, > C. > > > > -- > Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html > _______________________________________________ > Qgis-user mailing list > Qgis-user@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user >
_______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user