Hot answers tagged

9

If you want them for display purposes only, go to Settings --> Options --> General and check the box "Show group (thousands) separator": You need to restart QGIS before changes will have effect. For labelling purposes I suggest to use the expression format_number() directly in the label with or value field (name depends on the QGIS version) ...


7

If you use pure white over your shapefill then you can use "Multiply" to blend the layers which makes the white parts transparent. Adjusting widths gets me this: Here's the style properties for the two layers - the Simple Fill is just a thick dotted white line, and the shapefill is a gradient infill: Important thing is that "Multiply" ...


7

What you are telling the program to do is to draw gridlines every 5 units. The units for the grid projection you are using (Pseudomercator) are meters. So you are asking for a gridline every five meters. At the scale you are mapping a five meter inverval is extremely close, so all lines are bunched together. The grid on the map you are trying to replicate is ...


7

Try buffering your polygons with 0 distance, sometimes it fixes geometry errors. If you want to ignore the invalid geometries, you can set it Options - Processing - General:


6

Add the following lines to style.qss: QTableView::item, QListView::item, QTreeView::item { padding: 3ex; }


6

You assume that there is a feature for ids 0 and 1, but table.getFeature(0 or 1).attributes() tells us that it is not true. The following code prints existing feature ids. ids = [f.id() for f in table.getFeatures()] # list comprehension print(ids) # OUT: [2, 3, 4, 5] Then, continue using ids to be sure you use an existing ids. for i in ids: attributes =...


5

You can use QGIS expression with overlay functions: they work even with invalid geometries. To attach to each point the $id of the polygon, use this expression (poly is the name of the polygon layer): array_to_string(overlay_within('poly', $id)) Two polygons with intentionally invalid geometries. Points are correctly assigned to the polygons they are within,...


5

You have to use like this: QgsVectorFileWriter.writeAsVectorFormatV2(#layer#, #file_path#, #transform_context#, #options#) file_path= "/Path/To/File.shp" transform_context = QgsCoordinateTransformContext() options = QgsVectorFileWriter.SaveVectorOptions() options.driverName = "ESRI Shapefile" QgsVectorFileWriter....


5

Adding as file is not a problem in QGIS 3.22.2. Obviously there is a problem in QGIS 3.16.14. I found a solution which doesn't add from file, but folder, in v3.16. Copy all CSVs to a folder. Select "Directory" in "Data Source Manage | Vector" window.


4

Basic idea Create an attribute that counts the no. of nearby points, than scale these values exponentially to reduce the range between min/max values so that you can set gradient stops properly. Be aware of the colors you use and reflet if the heatmap you create can be understood and interpreted in an appropriate way (details below). How you can solve the ...


4

Try the code snippet below: map_layer = QgsProject.instance().mapLayersByName('Soil cover')[0] manager = QgsProject.instance().layoutManager() layout = manager.layoutByName("Test Layout") legend = layout.itemById("legend") layer_node = legend.model().rootGroup().findLayer(map_layer) legend.setAutoUpdateModel(True) layer_node....


4

The trick is to use Geometry generator to create a geometry where label placement is allowed. You are free to define the geometry in a way to fit your needs. Adapt it as you want: Go to label settings, placement tab and activate Geometry generator. Use QGIS expressions to define an area (polygon) where placement is allowed: a buffer around the lake, but ...


4

A point has no 2D area or "range" so if there is a distance between it and another geometry, they are disjunct. A point has to lie exactly on the line for any of the geometry predicates you mention to evaluate to True. As you mention in your comment, there is a distance of >0 between your point and the line so they do not intersect. The image ...


3

You can create a temporary layer based on your Postgis layer. You can either filter features of the layer wich intersect the canvas extent, or filter the features wich are completly within the canvas extent. On the example below, I have a layer (red), a canvas extent (red line) zoomed on the green feature, features intersecting the extent (pink features) and ...


3

This might not be what you need, but do you know of PostgreSQL execute and load SQL? This algorithm performs a SQL database query on a PostGIS database connected to QGIS and loads the query results as a new layer. e = iface.mapCanvas().extent() xmin = e.xMinimum() xmax = e.xMaximum() ymin = e.yMinimum() ymax = e.yMaximum() sqlquery = 'select * from public....


3

Use this expression for the Value field of the label dialog, where cars is the name of the attribute field: represent_value( "cars") See documentation: Returns the configured representation value for a field value. It depends on the configured widget type. Often, this is useful for ‘Value Map’ widgets.


3

A bit of theory The NTv2 (National Transformation version 2) shift intended to facilitate the transformation between datums. It can be achieved by means of a grid file (encapsulates the shift values that are stored in a regular arrangement of geographic coordinates) which comes in two formats: .gsa : a readable (ASCII) format (GSA) .gsb : a binary format (...


3

The default settings can be edited and saved permanently through menu option Settings-Options-GDAL-Raster driver options-GTiff Preset options can be changed also when an image is saved with Save as... but those changes are not permanent.


3

I concur that there seems to be an issue with disconnecting the save() and resetValues() slots from the accepted and rejected signals of the QDialogButtonBox of QgsAttributeForm. Indeed, perusing the docs, I saw that the QgsAttributeForm class has a method disconnectButtonBox() which should take care of this nicely. Inspecting the c++ source code you can see ...


3

This is a projection issue: your wedge buffers are not symmetric. You very likely have: The layer in a geographic CRS like WGS84, EPSG:4326 - that's why you have to divide the distance as units are in degrees The project set to another (projected?) CRS like WebMercator, EPSG:3857. If so: EPSG:3857 ist not ideal for many tasks, so think about which CRS to ...


3

This is a known bug in 3.22, see https://github.com/qgis/QGIS/issues/45470 and https://github.com/qgis/QGIS/issues/44061, that is caused by PROJ. One workaround could be to build the project from beginning in 3.22. Or wait for the next Version (hopefully 3.22.4) since it looks like the bug is found and fixed.


2

I've had good luck cleaning geometry with the "Fix Geometries" tool found within the QGIS Processing Toolbox (Ctrl+Alt+T).


2

If you are familiar with pytest, you could try using pytest-qgis plugin to write unit tests for QGIS. You don't need any of the boilerplate of starting the QGIS since it does it automatically. Here is a sample test that checks that a layer has been added to the project: def test_plugin(qgis_countries_layer): project = QgsProject.instance() project....


2

I'm not sure to have well understood what you are trying to do here but I guess you shall have a look at the "join attributes by location" tool or the intersection tool: -input layer: polylines -intersect layer: Africa shapefile Once you will have run the tool you will get a new polyline layer where every polyline features will be duplicated based ...


2

Try to use raise Exception('Error because of reasons!') rather than or in addition to feedback.reportError('') to prevent output layer from being created and returned.


2

An alternation using processing tools and expressions (I know it's OT, but it might be useful) Aggregate algorithm, set as below: your layer field to group expression to use expression used: concatenate_unique( group_by:="area", concatenator:=',', expression:="species", order_by:="species") output:


1

The first communication with WMS server is done with GetCapabilities. The URL is for example https://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities GetCapabilities includes OnlineResources for other WMS requests. In this example the OnlineResource for GetMap is <GetMap> ... <OnlineResource xmlns:xlink="...


1

The script DistantBear.py does have a syntax error. As it is in your processing directory which is tied a profile, you receive an error when starting QGIS with this profile (default). Solutions: Fix the sytnax error in script DistantBear.py Delete script DistantBear.py if unused


1

@Sangster answered to his own question: The following has recovered the project so has been noted to help others, but it does not identify or repair the original problem so I am not marking it as the answer. Note that simply duplicating the affected layer resulted in duplicating the problem too. To recover from this problem: Right click the affected layer ...


1

You can do it without raster calculator, using Fill NoData cells. Input is Raster B, Fill value is 9999.


Only top voted, non community-wiki answers of a minimum length are eligible