23.8. 명령 줄에서 공간 처리 알고리즘 사용

QGIS는 사용자가 QGIS 데스크탑 자체를 실행하지 않고서도 명령 줄에서 공간 처리 알고리즘과 (내장 또는 플러그인이 제공하는) 모델을 직접 실행할 수 있는 QGIS Processing Executor 라는 도구를 제공합니다.

명령 줄에서 qgis_process 를 실행하면 다음과 같은 화면을 보게 될 것입니다:

QGIS Processing Executor - 3.16.8-Hannover 'Hannover' (3.16.8-Hannover)
Usage: C:\OSGeo4W\apps\qgis-ltr\bin\qgis_process.exe [--json] [command] [algorithm id or path to model file] [parameters]

Options:

  --json          Output results as JSON objects

Available commands:

  plugins          list available and active plugins
  plugins enable   enables an installed plugin. The plugin name must be specified, e.g. "plugins enable cartography_tools"
  plugins disable  disables an installed plugin. The plugin name must be specified, e.g. "plugins disable cartography_tools"
  list             list all available processing algorithms
  help             show help for an algorithm. The algorithm id or a path to a model file must be specified.
  run              runs an algorithm. The algorithm id or a path to a model file and parameter values must be specified.
                   Parameter values are specified after -- with PARAMETER=VALUE syntax.
                   Ordered list values for a parameter can be created by specifying the parameter multiple times,
                   e.g. --LAYERS=layer1.shp --LAYERS=layer2.shp
                   If required, the ellipsoid to use for distance and area calculations can be specified via the "--ELLIPSOID=name" argument.
                   If required, an existing QGIS project to use during the algorithm execution can be specified via the "--PROJECT_PATH=path" argument.

참고

qgis_process 도구는 설치된 플러그인 가운데 metadata.txt 파일에 hasProcessingProvider=yes 를 명시한 플러그인만 식별하고, 활성화시키거나 불러올 수 있습니다.

list 명령어를 사용하면 사용할 수 있는 모든 제공자 및 알고리즘의 목록을 얻을 수 있습니다.

qgis_process list

help 명령어를 사용하면 명령어 또는 알고리즘에 대한 자세한 정보를 얻을 수 있습니다.

qgis_process help qgis:regularpoints

run 명령어를 사용하면 알고리즘 또는 모델을 실행할 수 있습니다. 첫 번째 파라미터로 알고리즘의 이름 또는 모델을 가리키는 경로를 지정하십시오.

qgis_process run qgis:buffer -- INPUT=source.shp DISTANCE=2 OUTPUT=buffered.shp

파라미터가 값 목록을 입력받는 경우, 동일 변수를 여러번 설정하십시오.

qgis_process run native:mergevectorlayers -- LAYERS=input1.shp LAYERS=input2.shp OUTPUT=merged.shp

알고리즘을 실행하는 도중에 텍스트 기반 피드백 막대가 표시되며, CTRL+C 단축키로 실행을 취소할 수 있습니다. run 명령어는 다음과 같은 심화 파라미터들도 지원합니다.

  • --json: 표준출력(stdout) 산출물 포맷을 JSON 구성 방식으로

  • --ellipsoid: 타원체를 지정한 타원체로 설정

  • --distance_units: 지정한 거리 단위를 사용

  • --area_units: 지정한 면적 단위를 사용

  • --project_path: 알고리즘을 실행하기 위해 지정한 프로젝트를 불러옵니다.