A QGIS file fully set up for atlas exports
*The script makes use of python-qgis.bat from the OSGeo4W bin directory (default C:\OSGeo4W64\bin\python-qgis.bat).
myProject = "c:your\\project\\location.qgs"
layoutName = "atlas_name"
coverageLayer = "Layer_name"
atlasFilter = '"column" = "value"'
outputFormat = "pdf"
outputFolder = "c:your\project\folder"
outputName = "query producing unique value"
pdfName = "Export"
\
is an escape character in python:c:your\\path\\here
"
or '
as part of a query/filter, escape these characters with a backslash: '\"FeatureType\" = \'building\''
-P "project path"
)The project file path in the following format: For example "c:your\\project\\location.qgs"
-L "atlas_name"
)The name of layout set up for atlas exporting: For example "Atlas_A4"
-C "layer_name"
)The name of the coverage layer used in the project file. This is derived from the layer name as displayed in the map's table of contents (and can contain spaces). Wrap the name in quotation marks: for example "Rights of Way"
-F "layer_name" "operator" "values"
)'\"FeatureType\" = \'building\''
''
'-F'
flag
"Road_Type"
"="
"<>"
">"
"<"
"LIKE"
"A Road"
-F "Road_Type" "=" "A Road"
-O "Format"
)"image"
or "pdf"
- "image" produces multiple image files, "pdf" produces a multi-page pdf
-D "directory"
)The output folder in the following format "c:your\\project\\folder"
-N "name query"
)The output name derived from attributes: For example \"Parish\" || \' \' || \"Number\"
or simply "@atlas_featurenid
-N "name"
)The output pdf name in the following format "name"
"C:\OSGeo4W64\bin\python-qgis.bat" "c:your\script\location\AtlasExport.py"
"C:\OSGeo4W64\bin\python-qgis.bat"
is the default path for OSGeo4W's batch file. It executes several other batch files, loading the environment for python 3.6 to run with QGIS libraries"c:your\script\location\AtlasExport.py"
Is the location of the python file on your machineThe script will now output the images of PDFs to the location noted in the script. If you encounter any errors, the explicit reason will be displayed in command line allowing you to troubleshoot.
These can be used to change many input and output parameters without modifying the code. Below is an exmaples in action: C:\OSGeo4W64\bin\python-qgis.bat C:\Temp\py\pyrow2.py -F "parishcode" "=" "207" -O image -D "C:\Users\Guy\Desktop"
"C:\OSGeo4W64\bin\python-qgis.bat" "c:your\script\location\AtlasExport.py"