Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from qgis.core import *
- QgsApplication.setPrefixPath("/usr", True)
- qgs = QgsApplication([], True)
- qgs.initQgis()
- print(QgsApplication.showSettings())
- ##Processing initialization
- sys.path.extend(['/usr/share/qgis/python/plugins', '/usr/share/qgis/python/plugins/processing',
- '/usr/share/qgis/python', '/usr/lib/qgis/plugins']) # Folder for Processing
- import processing
- from processing.core.Processing import Processing
- Processing.initialize() # needed to be able to use the functions afterwards
- ##Get and load the project instance
- project = QgsProject.instance()
- project.setCrs(QgsCoordinateReferenceSystem(2154))
- ## Chargement d'une couche
- vlayer = QgsVectorLayer('/my/place/to/save/zone_etude.shp','zone_etude','ogr')
- project.addMapLayer(vlayer)
- param = {'INPUT':'/my/place/to/save/zone_etude.shp',
- 'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:4326'),
- 'OUTPUT':'TEMPORARY_OUTPUT'}
- processing.run("native:reprojectlayer", param)
- project.write('/my/place/to/save/tutoproject.qgs')
- qgs.exitQgis()
- Application state:
- QGIS_PREFIX_PATH env var:
- Prefix: /usr
- Plugin Path: /usr/lib/qgis/plugins
- Package Data Path: /usr/share/qgis
- Active Theme Name:
- Active Theme Path: /usr/share/qgis/resources/themes//icons/
- Default Theme Path: :/images/themes/default/
- SVG Search Paths: /usr/share/qgis/svg/
- /home/edelb/.local/share/profiles/default/svg/
- User DB Path: /usr/share/qgis/resources/qgis.db
- Auth DB Path: /home/edelb/.local/share/profiles/default/qgis-auth.db
- Backend TkAgg is interactive backend. Turning interactive mode on.
- /usr/lib/python3/dist-packages/osgeo/gdal.py:112: DeprecationWarning:
- gdal.py was placed in a namespace, it is now available as osgeo.gdal
- Traceback (most recent call last):
- File "/my/place/to/save/repro_bug.py", line 26, in <module>
- processing.run("native:reprojectlayer", param)
- File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 106, in run
- return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
- File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 125, in runAlgorithm
- raise QgsProcessingException(msg)
- _core.QgsProcessingException: Error: Algorithm native:reprojectlayer not found
- >>>for alg in QgsApplication.processingRegistry().algorithms():
- print("{}:{} --> {}".format(alg.provider().name(), alg.name(), alg.displayName()))
- GDAL:aspect --> Aspect
- GDAL:assignprojection --> Assign projection
- ...
- GRASS:r.spreadpath --> r.spreadpath
- ...
- QGIS:vectorlayerscatterplot --> Vector layer scatterplot
- QGIS:voronoipolygons --> Voronoi polygons
- QGIS:zonalstatistics --> Zonal statistics
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement