Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. import sys
  2. from qgis.core import *
  3.  
  4. QgsApplication.setPrefixPath("/usr", True)
  5. qgs = QgsApplication([], True)
  6. qgs.initQgis()
  7. print(QgsApplication.showSettings())
  8.  
  9. ##Processing initialization
  10. sys.path.extend(['/usr/share/qgis/python/plugins', '/usr/share/qgis/python/plugins/processing',
  11. '/usr/share/qgis/python', '/usr/lib/qgis/plugins']) # Folder for Processing
  12. import processing
  13. from processing.core.Processing import Processing
  14. Processing.initialize() # needed to be able to use the functions afterwards
  15.  
  16. ##Get and load the project instance
  17. project = QgsProject.instance()
  18. project.setCrs(QgsCoordinateReferenceSystem(2154))
  19.  
  20. ## Chargement d'une couche
  21. vlayer = QgsVectorLayer('/my/place/to/save/zone_etude.shp','zone_etude','ogr')
  22. project.addMapLayer(vlayer)
  23.  
  24. param = {'INPUT':'/my/place/to/save/zone_etude.shp',
  25. 'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:4326'),
  26. 'OUTPUT':'TEMPORARY_OUTPUT'}
  27. processing.run("native:reprojectlayer", param)
  28.  
  29. project.write('/my/place/to/save/tutoproject.qgs')
  30. qgs.exitQgis()
  31.  
  32. Application state:
  33. QGIS_PREFIX_PATH env var:
  34. Prefix: /usr
  35. Plugin Path: /usr/lib/qgis/plugins
  36. Package Data Path: /usr/share/qgis
  37. Active Theme Name:
  38. Active Theme Path: /usr/share/qgis/resources/themes//icons/
  39. Default Theme Path: :/images/themes/default/
  40. SVG Search Paths: /usr/share/qgis/svg/
  41. /home/edelb/.local/share/profiles/default/svg/
  42. User DB Path: /usr/share/qgis/resources/qgis.db
  43. Auth DB Path: /home/edelb/.local/share/profiles/default/qgis-auth.db
  44.  
  45. Backend TkAgg is interactive backend. Turning interactive mode on.
  46. /usr/lib/python3/dist-packages/osgeo/gdal.py:112: DeprecationWarning:
  47. gdal.py was placed in a namespace, it is now available as osgeo.gdal
  48.  
  49. Traceback (most recent call last):
  50. File "/my/place/to/save/repro_bug.py", line 26, in <module>
  51. processing.run("native:reprojectlayer", param)
  52. File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 106, in run
  53. return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  54. File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 125, in runAlgorithm
  55. raise QgsProcessingException(msg)
  56. _core.QgsProcessingException: Error: Algorithm native:reprojectlayer not found
  57.  
  58. >>>for alg in QgsApplication.processingRegistry().algorithms():
  59. print("{}:{} --> {}".format(alg.provider().name(), alg.name(), alg.displayName()))
  60.  
  61.  
  62. GDAL:aspect --> Aspect
  63. GDAL:assignprojection --> Assign projection
  64. ...
  65. GRASS:r.spreadpath --> r.spreadpath
  66. ...
  67. QGIS:vectorlayerscatterplot --> Vector layer scatterplot
  68. QGIS:voronoipolygons --> Voronoi polygons
  69. QGIS:zonalstatistics --> Zonal statistics
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement