From 8650cafaacc59dc723c91361f7f2b47e85a1f04e Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Wed, 18 May 2022 19:16:46 +1000 Subject: [PATCH 1/2] Change path to QGIS python --- qgis/export.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgis/export.bat b/qgis/export.bat index 2892ec3..0958406 100644 --- a/qgis/export.bat +++ b/qgis/export.bat @@ -1,4 +1,4 @@ -set PYTHON="C:\Program Files\QGIS 3.20.3\bin\python-qgis.bat" +set PYTHON="C:\Program Files\QGIS 3.22.5\bin\python-qgis-ltr.bat" %PYTHON% export.py From 29dcb89c17440596e22d76404845478dc51d41dd Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Wed, 18 May 2022 19:18:44 +1000 Subject: [PATCH 2/2] Check shapefile validity --- qgis/export.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qgis/export.py b/qgis/export.py index 7bc5315..b3894fc 100644 --- a/qgis/export.py +++ b/qgis/export.py @@ -61,6 +61,13 @@ def unique_attributes(layer): map_layers = project.mapLayers().items() layers = [v for k, v in map_layers if re.search(r'\d{4}', v.name())] +try: + next(layers[0].getFeatures()) +except StopIteration: + msg = 'No hazard lines found. Check shapefile data.' + raise ValueError(msg) + + # Get all EP values and profile types from first hazard line layer eps, types, years = unique_attributes(layers[0])