New answers tagged

0

Thank you for all your suggestions. I tried them all and I certainly shall be taking all your advice moving forwards. After trial and error to sort this issue out I had to go back to basics. I reprojected every individual raster to WGS_84. Resampled each raster to the same pixel size as the DEM. Merged it all and it sorted the issue out. Seems like a really ...


2

Regarding the layer becoming uneditable after selecting and applying an SQL query via "Update SQL Layer" on the layer context menu, I discovered selecting "Change Data Source" from the same context menu and then just reselecting the original data source returns the table to editable. I haven't tested this but my guess is the problem ...


2

I finally figured it out, from other parts of the documentation the correct arguments that should be provided to fromPolygonXY is a [[QgsPointsXY_obj1, QgsPointsXY_obj2, ...]] link: https://docs.qgis.org/3.16/en/docs/pyqgis_developer_cookbook/geometry.html?highlight=polygonxy#geometry-construction and the documentation at https://qgis.org/pyqgis/master/core/...


0

Since the cross-hatching seems to occur mostly in areas of high slope, it would appear that the coarser glacier DEM is being resampled using nearest neighbor. Have you tried some other resampling algorithm which actually interpolates between cell centers (EG, bilinear/cubic)?


0

Below is a complete, minimal, working plugin script which shows how to do what you what. I saved this file as __init__.py, placed it in a folder with an appropriate metadata.txt file and copied the folder into the QGIS plugins directory. Note that to populate the line edit in the plugin dialog with the coordinates from mouse clicks on the map canvas, we need ...


2

QgsLineSymbol inherits the method setColor() from the QgsSymbol base class. And QgsManhattanLineCallout inherits setLineSymbol() from QgsSimpleLineCallout. So just do: line_symbol = QgsLineSymbol() line_symbol.setColor(QColor('Yellow')) callouts.setLineSymbol(line_symbol)


1

I looked a bit more into the documentation, and apart for QgsProject, there are also QgisInterface signals: newProjectCreated Emitted when starting an entirely new project note This is similar to projectRead(); plug-ins might want to be notified that they’re in a new project. projectRead Emitted when a project file is successfully read note This is ...


8

Create a new point using Geometry by expression, than Merge vector layers to merge this newly created point layer with the inital points layer. Here you can download the model for this workflow. For manual input of x- and y-coordinate values that create the point, create two numbers. In geometry by expression, you can access these numbers (they are available ...


2

I suggest you use join attributes by nearest instead of location, since points seldomly match completely. It works similarly to join by location, but instead of the intersection-type you define how many neighbours you want to join (in your case one) and how large the distance to the next neighbour should be in the worst case (e.g. 10 m). Another solution ...


6

Open "Layer Properties -> Attribute Form" Delete aliases. This works just in the project and doesn't change the layer source.


1

I ended up using the "pre-calculated value" field and this format; @project_home || '/Files' || '/Style-Project-AOI-v2.qml' Maybe not so pretty, but hard-coded and works if you want to take the project home and subfolders with you on the road.


3

Assuming the plugin crashes QGIS because the computations need too much memory, it will help to move to a computer with more RAM. (QGIS Server is a web map server application. It is not focused on the kind of task described in this thread.)


4

Try something like that: n=0 for f1 in layer1: p1 = f1.geometry().asPoint() x1, y1 = p1.x(), p1.y() coord1= f"{x1},{y1}" for f2 in layer2: p2 = f2.geometry().asPoint() x2, y2 = p2.x(), p2.y() coord2= f"{x2},{y2}" n += 1 try: processing.run("native:...


0

The Clipper plugin will work, though it's pretty temperamental. In my case I usually have to merge the layers (then display them rule-based so I can confirm they're all present). Then I hide the large enclosing polygon in the merged layer and select all the smaller polygons I want to cut out. Then I run Clipper>Clipper Clip with multiple selection. ...


1

The following works for me. intersects($geometry, @current_geometry ) See the example "PROBLEM 2: RESTRICT THE CHOICE OF STREET NAME TO STREETS CLOSE TO THE DIGITIZED PARCEL" at https://spatialthoughts.com/2019/04/12/summary-aggregation-qgis/


2

Try the "Difference" that will do exactly what you want: Extracts features from the input layer that don’t fall within the boundaries of the overlay layer. 'Input layer': gray 'Overlay layer': yellow and get the desired output


1

I'm afraid that I can't really provide an intelligent or scientific explanation of the problem here, because I tried modifying your code and I was not able to get a satisfactory result. But it works for me with the following code snippet which I tested on a similar data set to what you have shown. project = QgsProject.instance() layout = QgsPrintLayout(...


3

You can use a custom function in the label expression editor Assuming your parcels attribute table is structured like this: from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom', referenced_columns=[]) def concat_field_values(feature, parent, context): ## get field names of layer using 'context' argument fields = ...


8

To calculate the distance between two points along a line geometry, you can use QGIS expressions based on the following functions (see below how to combine these elements). Points not even have to be exactly on the line, it works even if the point is slightly away: it then automatically takes the nearest point on the line. line_substring to get the part of ...


3

There a two places where the opacity can be defined: A) for the entire layer (as shown in your screenshot) and B) per symbol. You can set the "default" opacity of each symbol by clicking on the categorizer symbol color (before adding categories) or by clicking on the existing categories color.


0

In QGIS 3.16 I did it in a simple way. I created a plugin-button. After clicking oin that (1) I can click in the map and get the coordinate as a self.iface.messageBar().pushMessage. from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtWidgets import QAction from qgis.PyQt.QtWidgets import * ...


2

With my test image with a comparable file size and resoultion (65 MB, see below), it takes max. a few seconds to reload in the georeferencer. So probably your problem has more to do with the performance of your machine then with QGIS. Changing to a faster computer could solve the problem. The other solution would be: save a copy of your image with a reduced ...


0

right-click on layer >> Properties >> click "Auxillary Storage" on the left you can then just delete everything. you might be able to just remove the ones that create the problem individually.


0

For GeoPackage, try: QSettings().setValue("providers/ogr/GPKG/connections/%s/path" %(con[0]),con[1])


4

There is missing a *.prj file that contains the projection (see also When are .prj files included with Shapefiles?). Go back to the data source to get this file. If that is not possible, manually set the layer CRS (one of the few cases you actually should do that...): right-click layer/ Layer CRS / Set Layer CRS…. You have to guess, based on the nature of ...


5

Looks like your brackets are no good. You can try: IF("maxspeed" is null AND "highway" = 'primary', 90, IF("maxspeed" is null AND "highway" = 'secondary', 50, "maxspeed") ) But the CASE WHEN answer is more clear.


7

As Erik suggests, a CASE WHEN statement works fine. CASE WHEN "maxspeed" IS null AND "highway" = 'primary' THEN 90 WHEN "maxspeed" IS null AND "highway" = 'secondary' THEN 50 ELSE "maxspeed" END


0

After rerunning the algorithm I need to respond to my own core question which was why the algorithm took so long. As I originally run the algorithm on the given data as a selection of a larger data set I suspected I was doing something wrong. I then exported the selected features (my small example in the area of Melilla) and published it here. Yet the root ...


2

For me, it works in less then a second (without spatial index: less than 3 secs.), using the data you provided. Create a spatial index: Right click layer / Properties / Source tab / Create spatial index. Then run Join by location. Be sure to select Take attributes of the first matching feature only (one-to-one): See the result:


7

You can define a method for this. def select_layer(layer_name, group_name): root = QgsProject.instance().layerTreeRoot() group = root.findGroup(group_name) if group is not None: for child in group.children(): if child.name() == layer_name: iface.setActiveLayer(child.layer()) select_layer("...


1

Use the following expression (works since QGIS 3.16) on layer polygon_2 that generates a list of the $id (or any attribute value you introduce here) of all intersecting features of layer polygon_1: array_to_string (overlay_intersects('polygon_1', $id)) Screenshot: layer polygon_2 is labeled with the $id-value of the features from layer polygon_1 that it ...


0

On QGIS 3.20 Odense the same settings seem to work as expected: Also, in QGIS tables you can define virtual fields, which get calulcated at runtime, therefore also before exporting: Attribute Table (F6) -> click on the Open Field Calculator icon (the abacus), then:


2

Open the folder that stores your user profile. You can find it clicking Menu Settings / User Profiles / Open Active Profile Folder (see screenshot) - or see the documentation for the default location on different operating systems. Go to the parent directory (profiles) to see all profiles. Copy the folder with the profile you want to use. Than paste it in ...


2

Use Raster calculator. If an expression is true it evalutes to one, else zero so: ("nmd_bas_sub@1"=111)*1+("nmd_bas_sub@1"=112)*1+("nmd_bas_sub@1"=113)*1+0 will be 1 for class 111, 112 and 113, else it will be 0:


2

For some unknown reason your QGIS cannot interpret that .prj file. As a workaround you can use the EPSG authority code that appears in the .prj AUTHORITY["EPSG","31287"]. Another option is to try if the gdalsrsinfo https://gdal.org/programs/gdalsrsinfo.html utility could convert the WKT definition into something that works better. ...


2

What you are looking for, is the processint tool "Reclassify by Table". You find it in the Processing Toolbox (Processing -> Toolbox). Then just surch for "Reclassify by Table" or you will find it under the menu "Raster analysis".


3

Head for the raster calculator and enter the following: (CLC@1=311) OR (CLC@1=312) OR (CLC@1=313) This assigns your CLC-layer a 1 where it is forest, and a 0 where the conditions aren't met. Be sure to replace CLC@1 with the actual name of your CLC-layer. It will be listed in the raster calculator.


1

The solution You can use a QGIS expression to number the polygons from 1 to N with a simple (well - a single, even if scary looking, but rather easy) expression that creates a new attribute with field calculator. See below for the expression. Explanation The expression is based on the x and y-coordinate values of the centroid of each polygon and evaluates ...


3

Create Grid, point type Rectangles, ovals, diamonds. Create rectangles smaller than the grid spacing Add a field new id field, adjust first two lines and execute this in python console: layername = 'Polygon' #Change to your layername idfield = 'newid' #Change to match the name of your field layer = QgsProject.instance().mapLayersByName(layername)[0] ...


Top 50 recent answers are included