New answers tagged

6

First, check if layer is an instance of QgsVectorLayer. layer = ... print(type(layer)) If so, then, you have to add the following method to your processing algorithm class to be able to add temporary layers to the "Layers Panel". def flags(self): return super().flags() | QgsProcessingAlgorithm.FlagNoThreading Then use this:: layer = ... ...


1

Try: QgsProject.instance().addMapLayer(layer, False) QgsProject.instance().layerTreeRoot()(0, layer) The first command registers the layer. The second adds it to the layer panel. I am not entirely sure why this works, but I always do it..


5

For 'START_POINT' parameter (and 'END_POINT' parameter if necessary), use this: 'START_POINT': f"{startlon},{startlat} [EPSG:4326]", 'END_POINT': f"{endlon},{endlat} [EPSG:4326]" I guess, processing.run should be located in for loop. import processing layer_anfang = QgsProject.instance().mapLayersByName("MVG_2016_Wetter_Januar"...


5

If you want to create this sort of thing, then there is a way. I am assuming you have already broken the transects at the river. Looks like you have. Convert the watershed polygon to a line. This creates a polyline boundary. You can use Vector - Geometry - Polygons to Lines Vector - Geoprocessing Tools - Buffer the boundary by a small amount so that the ...


1

I've made a recipe trying to reuse your variables zsj = QgsVectorLayer("/data/grassmaster/testVlado/zsj_ba_test.gpkg", "zsj", "or") si = QgsProject.instance().mapLayersByName("Vectorized")[0] # Dict to then get layer type when declaring in memory layer layerTypes = { getattr(QgsWkbTypes, i): i for i in [ '...


5

You can use "Split with lines", "Select by location" and "Extract selected features" tools respectively. Split with lines Select by location Extract selected features Result:


0

Not sure I understand your problem. If you want the path to the shapefile for use later in the script, then just declare it as a variable, and it will be available: i.e. library(sf) # This library contains all the st_* functions shape_dir <- "path/to/shapes" shape_path <- file.path(shape_dir, "shape.shp") Layer <- st_read(...


0

If you don't have the original dataset, just export the current out as a table and recreate the data using the unmodded lat lon attributes.


1

I understand you want to place your point based on a field containing lat and long. There are multiple ways to do it with code and editing direcly the layer. What I would suggest is to build a temporary new layer based on the field and then choose either to replace your layer or only replace some point on your layer. Steps : Open Menu > Processing > ...


2

By default the plot goes to a new RGL device window, which will die when the R process finishes. Instead you can direct RGL graphics to a web-based 3d viewer. To do that set a couple of rgl options so that you don't get the default viewer showing up, and then after doing the plot create a widget and print it: options(rgl.printRglwidget = FALSE) options(rgl....


-1

This answer might be slightly off-topic, but your question keeps coming up whilst searching for the graphical modeller answers. If you are using the graphical modeller, you can use the parameter function to retrieve a string of any inputs. Unfortunately, you can not use the shorthand @parameter way of accessing data if you want a string. The below code takes ...


1

The poblem here is that the Field calculator tool outputs a layer but the calculated attribute values are not exposed as a parameter to be used in subsquent steps of the model. A way to solve this issue is to use the tool Basic Statistics for fields. This tool will take a numeric attribute and extract stastitcal aggregations that can be used as a parameter ...


0

QgsProject.instance().reloadAllLayers() worked for me on QGIS 3.10.


1

If you want to save the output file on the processing output folder, please see this example: 1 - where is the processing output folder (QGis3)? Settings -> User Profiles -> Open Active Profile Folder -> "processing" folder -> "outputs" folder 2 - save the output of this processing algorithm on the above "output" ...


3

It's literally just a list of QgsVectorLayer objects, or a list of layer paths, @ndawson says. Accordingly, use this way: from qgis.processing import alg from qgis.core import * import processing @alg(name="ex_new", label=alg.tr("Example script (new style)"), group="examplescripts", group_label=alg.tr("Example Scripts"...


Top 50 recent answers are included