Hot answers tagged

8

Once your classes are applied, you can activate <layer context menu> | Show feature count in the main Layer panel to see the feature count for each class:


8

In the Layer pannel, there is an icon in form of an eye : Manage Map Themes (documentation) : By clicking on it, you can see the option for display / mask the selected layers. You can also go to the Settings menu > Shortcuts, find these options (one for display selected, one for mask selected) and affect the shortcut you want. PyQGIS code : Copy and ...


7

In my case, I have a DEM with continue values, going from 100 to 103 meters. The spatial resolution is 0.25 x 0.25 degrees, defined in EPSG:4326. The DEM is styled with a discrete color ramp with three classes: To smooth it, first I will make a raster algebra. Because I want a raster with only three values. I am using the following formula: ("...


5

You can turn off the whole Marker line if it is too short using built in data driven symbology. For example my data: I want to remove the arrows from the smaller islands. These are all line features, so looking at the length of the line is good. I am working in British National Grid, so my units are in meters. So to switch off the markers from all lines ...


4

In the model environment, some variables are created for each input parameter, which can be used by algorithms. The name of those variables is automatically assigned from the description of the parameter when it is created. For instance, in this model: New variables are being created with the names of the inputs, converted to lowercase and removed ...


4

There are several tools that exist in qgis to smooth contour lines as opposed to smoothing the raster itself , including vector->geometry->simplify, the vector geometry tool "smooth", and the GRASS function v.generalize. Personally, I like the results of the SAGA module line smoothing ("http://www.saga-gis.org/saga_tool_doc/2.2.2/shapes_lines_7.html), and ...


4

Try this modified code from your previous question below. I have reworked it a bit- creating a spatial index on the postcode layer and running the outer for loop on the parent region layer and the inner loop on the postcode layer. One effect of the changes is you will get many fewer of the 'No intersection' rows in the resulting csv file. This is because ...


4

You won't make a error if you load the extension mod_spatialite. Look at the following code : import sqlite3 con = sqlite3.connect(dbname) con.enable_load_extension(True) cur = con.cursor() cur.execute("PRAGMA foreign_keys = ON") con.execute("SELECT load_extension('mod_spatialite')") -- add this line cur.execute("SELECT InitSpatialMetaData(1);")


4

Try the natively supported SpatiaLite SQL, either via Virtual Layer, or the DB Manager; run SELECT "AreaChar", ST_Centroid(ST_Collect(geometry)) AS geometry FROM <your_layer> GROUP BY "AreaChar" ; to simply get the centroid as geometry, or SELECT "AreaChar", ST_X(geometry) AS x, ST_Y(geometry) AS y, geometry FROM ...


4

Solving this particular question The attachment widget is of type 'ExternalResource'. This is an example for you to configure it: FIELD = "field_name" editor_widget_setup = QgsEditorWidgetSetup( 'ExternalResource', { 'FileWidget': True, 'DocumentViewer': 0, 'RelativeStorage': 0, 'StorageMode': 0, '...


4

You can use field_names = [field.name() for field in layer.fields()] to get field names or other field properties (length, type, comment, ...). If you just need names, it's sufficient to use field_names = layer.fields().names()


3

Yes it is possible and you need to execute a desired QAction. For "identify feature tool", you can trigger "mActionIdentify" action. A list of most of the available actions can be found by going to "Settings->Interface Customization". Here you will find reference to the most of the possible customization e.g. Actions, buttons, toolbars, docking widgets and ...


3

It requires a string list as input: ['sekcja', 'numer_inwe'] But if you're going to use it through the modeler, might I suggest using the Vector field input parameter which can be set to accept multiple fields. You can connect this parameter to the "Add autoincremental field" tool. Then when you run the model, you can simply choose the fields you want ...


3

I suspect that the cause of the unexpected result may be coming from the line where you calculate and print the percentage: print ("Percent in Parent Region: ", (intersection_area/d.measureArea(POA_Geom)*100)) The intersection_area object has been converted to km2, but you are dividing it by d.measureArea(POA_Geom) which has not been converted to km2. You ...


3

Since Mollweide does not accept a latitude shift, what we can do is transform the coordinates of the geometries to a new geographic CRS with the Poles shift. For that, I will register a custom geographic CRS in the PROJ database, and associate to it a Helmert Transformation. PROJ registers all data in a SQLite database. I will edit it with DB Brower ...


3

You are missing the pyrsgis python module, which must be required by that plugin. Please execute either CMD, PowerShell, or Windows Terminal as Admininstrator. Ensure QGIS is completely closed. CD into the OSGeo4W python environment (C:\OSGEO4W\apps\Python37\) CD C:\OSGeo4W\apps\Python37 Issue the following python/pip command to install pyrsgis: .\...


3

The following minimal example is in a somewhat similar format to the post you linked to which should work for QGIS 3: # Interpolate points using QgsTinInterpolator pathToFile = "path/to/input.shp" layer = QgsVectorLayer(pathToFile, 'input','ogr') layer_data = QgsInterpolator.LayerData() layer_data.source = layer layer_data.zCoordInterpolation = False index ...


3

When the topology checker highlights a feature in red, it means that feature violates one of the rules. Since your only rule is "must not overlap," when a polygon is red it means that polygon overlaps with another polygon. It's up to you to find the exact place where it overlaps. I suggest using the Clip tool (from the Vector menu > Geoprocessing tools) ...


2

One way of many: install refFunctions plugin with your greens layer active open Field Calculator Create a new field choose Output field name (e.g. 'city_part') choose Output field type to match that of the city parts layers id column (ì.e. Text) use expression: geomintersects( '<city_parts_layer_name>', '<city_parts_id_column_name>') and ...


2

At the bottom of the layer properties window there's a small dropdown menu called style. When choosing save style you may save symbology, labelling, and e.g. data forms - short, any customization you did - to a .qml file. This file may also be used to add the customization to any other layer of the same feature type, though some things like data forms only ...


2

One way of adding paint effects is to add another symbol layer for it. Here is a code snippet to produce following polygon. #Add layer coords = [(20, 60), (32, 60), (32, 70), (20, 70), (20, 60)] polygon = QgsGeometry.fromPolygonXY( [[ QgsPointXY( pair[0], pair[1] ) for pair in coords ]] ) layer = QgsVectorLayer("Polygon?crs=EPSG:4326", "polygon_0", "...


2

1) Add two fields to the points layer. One which represent the desired angle, and one representing the distance from the point to the extent of the polygon layer (to ensure the line is long enough to intersect all polygons). 2) Using QGIS plugin Shape Tools, create a Line of Bearing which begins at the point of interest, (choose the corresponding distance/...


2

Use the special value QgsProcessing.TEMPORARY_OUTPUT as the output parameter value, and the rest will all be taken care of for you. e.g. clipped_layer = processing.run("gdal:clipvectorbyextent", {'INPUT': id, 'EXTENT': canvasExtent, 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT})['OUTPUT']


2

Yes, it is possible! The following is a very short and effective example (that I'll explain below): toolbar = iface.addToolBar("My ToolBar") # Add QGIS action from iface toolbar.addAction(iface.actionIdentify()) # Add 'Digitizing tools' plugin action (e.g., Merge) dt = qgis.utils.plugins['DigitizingTools'] toolbar.addAction(dt.merger.act) Which gives you ...


2

You can customize the QGIS GUI via Settings --> Interface Customization... However, since you are looking for a Python solution: Iterate iface.fileToolBar().actions() Ask for each action's objectName() and compare to those you want to preserve And, finally, for those actions that don't match, use iface.fileToolBar().removeAction(action).


2

QGIS Bookmarks are saved in qgis.db (SQLite Database) under your profile folder. You can view this folder by clicking on "Settings->Open Active Profile Folder" as show below On windows you will find it in C:\Users\Me\AppData\Roaming\QGIS\QGIS3\profiles\default Please include this folder in your backup so that you can retrieve all profile related settings ...


2

To export multiple layers to separate spreadsheets You can run any tool from the Processing Toolbox in Batch Mode by right clicking on the tool name > Execute as Batch Process... > Choose all your layers, and save them XLSX format. Pick a processing algorithm that doesn't change your layer, for example: If your layers are all in the same CRS, use the ...


2

This is one option: If you have a feature you want to manually move then you would need to enable the advanced digitizing toolbar and use the move feature tool. You can then view the distance in the X and Y plane as well as the bearing. To do this follow the steps taken in the GIF below:


2

You need to use the eval() function in your expression to get the actual value of the vector field variable instead of the variable name, like this: eval(@field1) + ', ' + eval(@field2) More details in the docs: https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/expression.html#general-functions


2

List field names - .dataProvider() method layer = qgis.utils.iface.activeLayer() # get active layer if not already set prov = layer.dataProvider() field_names = [field.name() for field in prov.fields()] for count, f in enumerate(field_names): print("{} {}".format(count, f)) Note: using layer.pendingFields() doesn't seem to work in QGIS 3 This fails: ...


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