This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layer = QgsProject.instance().mapLayersByName('LIMITES_ADMINISTRATIVES_EXPRESS.LATEST')[0] | |
url = 'https://www.geoportail.gouv.fr/depot/layers/LIMITES_ADMINISTRATIVES_EXPRESS.LATEST/legendes/LIMITES_ADMINISTRATIVES_EXPRESS.LATEST-legend.png' | |
layer.setLegendPlaceholderImage(url) | |
props = QgsRasterLayerProperties(layer, self.iface.mapCanvas())# Note use of self.iface object if this is in a plugin | |
props.apply() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SnappingMapTool(QgsMapToolEmitPoint): | |
def __init__(self, canvas): | |
self.canvas = canvas | |
self.project = QgsProject.instance() | |
QgsMapToolEmitPoint.__init__(self, self.canvas) | |
self.layer = iface.activeLayer() | |
# set up snapping settings | |
self.snap_config = QgsSnappingConfig(self.project) | |
self.snap_config.setEnabled(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestDialog(QDialog): | |
def __init__(self, iface): | |
QDialog.__init__(self) | |
self.iface = iface | |
self.mlcb = QgsMapLayerComboBox(self) | |
self.exp_widget = QgsFieldExpressionWidget(self) | |
self.line_edit = QLineEdit(self) | |
self.btn = QPushButton('Run', self) | |
self.list_widget = QListWidget(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestDialog(QDialog): | |
def __init__(self, iface): | |
QDialog.__init__(self) | |
self.iface = iface | |
self.exp_widget = QgsFieldExpressionWidget(self) | |
self.line_edit = QLineEdit(self) | |
self.btn = QPushButton('Run', self) | |
self.list_widget = QListWidget(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------------------------------------- | |
# Copyright (C) June 2022 Ben Wirf | |
#----------------------------------------------------------- | |
# Licensed under the terms of GNU GPL 2 | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
#--------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------------------------------------- | |
# Copyright (C) June 2022 Ben Wirf | |
#----------------------------------------------------------- | |
# Licensed under the terms of GNU GPL 2 | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
#--------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------------------------------------- | |
# Copyright (C) 2022 Ben Wirf | |
#----------------------------------------------------------- | |
# Licensed under the terms of GNU GPL 2 | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
#--------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Model exported as python. | |
Name : Point_within_polygon | |
Group : Examples | |
With QGIS : 32003 | |
*************************************************************************** | |
Point_inside_polygon.py | |
--------------------- | |
Date : December 2021 | |
Copyright : (C) 2021 by Ben Wirf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this code in QGIS Python console | |
class MyPointTool(QgsMapToolEmitPoint): | |
def __init__(self, canvas): | |
self.canvas = canvas | |
QgsMapToolEmitPoint.__init__(self, self.canvas) | |
def canvasReleaseEvent(self, e): | |
pnt = e.mapPoint() | |
r_layers = [l for l in QgsProject.instance().mapLayers().values() if l.type() == QgsMapLayerType.RasterLayer] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Model exported as python. | |
Name : clipped_points_buffered | |
Group : Models | |
With QGIS : 31415 | |
""" | |
from qgis.core import QgsProcessing | |
from qgis.core import QgsProcessingAlgorithm | |
from qgis.core import QgsProcessingMultiStepFeedback |