From 0d56538429885a5b2a80d549f5026712b9e5cdc8 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 2 Oct 2023 03:24:18 +0200 Subject: =?UTF-8?q?Add=20support=20for=20extra=20layers=20(such=20as=20?= =?UTF-8?q?=E2=80=9CV=C3=A4rdek=C3=A4rnor=20skog=E2=80=9D).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gis-observation-map | 54 ++ "h\303\266ga-skogliga-naturv\303\244rden.qml" | 505 ++++++++++++++++++ kontinuitetsskog.qml | 711 +++++++++++++++++++++++++ nyckelbiotoper.qml | 703 ++++++++++++++++++++++++ "p\303\245g\303\245ende-reservatsbildning.qml" | 502 +++++++++++++++++ "skogliga-v\303\244rdek\303\244rnor.qml" | 704 ++++++++++++++++++++++++ 6 files changed, 3179 insertions(+) create mode 100644 "h\303\266ga-skogliga-naturv\303\244rden.qml" create mode 100644 kontinuitetsskog.qml create mode 100644 nyckelbiotoper.qml create mode 100644 "p\303\245g\303\245ende-reservatsbildning.qml" create mode 100644 "skogliga-v\303\244rdek\303\244rnor.qml" diff --git a/gis-observation-map b/gis-observation-map index 9c58b8e..248b63a 100755 --- a/gis-observation-map +++ b/gis-observation-map @@ -36,6 +36,7 @@ from qgis.core import ( QgsApplication, QgsCoordinateReferenceSystem, QgsLayerDefinition, + QgsLayerTreeLayer, QgsLayerTreeModel, QgsMapLayer, QgsPointXY, @@ -827,6 +828,59 @@ if not args.no_observations: getObservations(taxonLists, taxonRedlistCategories, searchFilter) +if args.project_home is not None and projectInstance is not None: + for item in config['QGIS'].get('NatureValue', []): + name = item['Name'].title() + srcPath = Path(item['Source']).expanduser() + dstPath = args.project_home.joinpath(srcPath.name) + + fmt = item.get('Format') + if fmt is not None: + drv = ogr.GetDriverByName(fmt) + if drv is None: + raise Exception(f'Invalid format {fmt}') + suffixes = drv.GetMetadataItem(gdal.DMD_EXTENSIONS).split(' ') + if dstPath.suffix[1:] not in suffixes: + dstPath = dstPath.with_suffix('.' + suffixes[0]) + + layerName = item.get('LayerName') + srcDs = gdal.OpenEx( + srcPath.as_posix(), + gdal.OF_VECTOR, + open_options=item.get('SourceOpenOptions', []) + ) + + dstPath = dstPath.as_posix() + gdal.VectorTranslate( + dstPath, srcDs, format=fmt, + accessMode='overwrite', + reproject=True, dstSRS=target_srs, + clipDst=clipGeometry.ExportToWkt() if item.get('Clip', True) else None, + datasetCreationOptions=item.get('DatasetCreationOptions', []), + layerCreationOptions=item.get('LayerCreationOptions', []), + geometryType=item.get('GeometryType'), + skipFailures=True, + layers=[layerName] if layerName is not None else None + ) + srcDs = None + + if layerName is not None: + dstPath = f'{dstPath}|layername={layerName}' + layer = QgsVectorLayer(dstPath, name, 'ogr') + if not layer.isValid(): + raise Exception(f'ERROR: {dstPath}: failed to load in QGIS') + projectInstance.addMapLayer(layer, False) + layerTreeRoot.insertChildNode(-1, QgsLayerTreeLayer(layer)) # last + layer.setReadOnly(True) + + isVisible = item.get('Visible', True) + layerTreeRoot.findLayer(layer.id()).setItemVisibilityChecked(isVisible) + + style = item.get('Style') + if style is not None: + style = Path(style).expanduser() + layer.loadNamedStyle(style.as_posix()) + topo_maps = ['Topografi 10', 'Topografi 50', 'Topografi 100'] if args.topo_basedir is not None and projectInstance is not None: idxContains = {} diff --git "a/h\303\266ga-skogliga-naturv\303\244rden.qml" "b/h\303\266ga-skogliga-naturv\303\244rden.qml" new file mode 100644 index 0000000..3e5deb3 --- /dev/null +++ "b/h\303\266ga-skogliga-naturv\303\244rden.qml" @@ -0,0 +1,505 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "NAMN" + + 2 + diff --git a/kontinuitetsskog.qml b/kontinuitetsskog.qml new file mode 100644 index 0000000..deca98a --- /dev/null +++ b/kontinuitetsskog.qml @@ -0,0 +1,711 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + "Klass" + + 2 + diff --git a/nyckelbiotoper.qml b/nyckelbiotoper.qml new file mode 100644 index 0000000..c780c78 --- /dev/null +++ b/nyckelbiotoper.qml @@ -0,0 +1,703 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + concat("Objnamn", ' (', "Beteckn", ')') + + 2 + diff --git "a/p\303\245g\303\245ende-reservatsbildning.qml" "b/p\303\245g\303\245ende-reservatsbildning.qml" new file mode 100644 index 0000000..e24850a --- /dev/null +++ "b/p\303\245g\303\245ende-reservatsbildning.qml" @@ -0,0 +1,502 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "NAMN" + + 2 + diff --git "a/skogliga-v\303\244rdek\303\244rnor.qml" "b/skogliga-v\303\244rdek\303\244rnor.qml" new file mode 100644 index 0000000..b4cf0f1 --- /dev/null +++ "b/skogliga-v\303\244rdek\303\244rnor.qml" @@ -0,0 +1,704 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + concat("OBJTYP", ' (', "BESKRIVNIN", ')') + + 2 + -- cgit v1.2.3