Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A vector layer represents geographic data whose features are given by sequences of points. (Contrast with a raster, which is a grid of values.)
6
votes
Accepted
Getting only joined fields using PyQGIS
One can detect which fields have been joined by means of the QgsFields class and its method fieldOrigin:
Returns the field's origin (value from an enumeration).
from qgis.core import QgsProject
lay …
1
vote
Maximum value of field of vector layer using PyQGIS
There are also several other approaches available:
Approach 1 : QgsAggregateCalculator with Max
Available aggregates to calculate.
Not all aggregates are available for all field types.
This approach …
5
votes
Rotating by 90° one and more polygons in QGIS
Try the "Rotate" tool.
Rotates feature geometries by the specified angle clockwise. The
rotation occurs around each feature’s centroid, or optionally around a
unique preset point.
Also possible by m …
5
votes
Replica of point layer data from attribute value in QGIS
Let's assume there is a point layer called 'Centroids' with three features in it, see the image below. The field "Number" will be used for producing copies of each feature.
Step 1. Apply the "Array o …
4
votes
Adding field in vector layer from attribute table in QGIS
Another solution implies the usage of a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer....
With the following query, it is possible to update 'pop.shp' and add the fields "value1", …
3
votes
Difference between features in the same vector layer using PyQGIS
Another option is to use the materialize() method.
from qgis import processing
layer = QgsProject.instance().mapLayersByName('Langham_SPZs_v1_diss')[0]
outfn2 = "Langham_SPZs_final.shp"
layer.selec …
3
votes
Accepted
Applying cross join or cartesian product (database table join) for GeoDataFrames using GeoPa...
This worked for me:
# imports
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
# creates a DataFrame
df = pd.DataFrame({
'id': [1, 2, 3, 4, 5, 6, 7],
'Longitude': …
5
votes
Creating temporary layer out of selection in QGIS
One can try using the materialize() method of the QgsFeatureSource class.
Note: this is available since QGIS 3.0
from qgis.utils import iface
from qgis.core import QgsProject
layer = iface.activeLaye …
3
votes
Verifying if layer is filtered using PyQGIS
PyQGIS 3
Adopted version of @Detlev's answer:
from qgis.core import QgsProject, QgsVectorLayer
layers = QgsProject.instance().mapLayers()
for layer in layers.values():
if isinstance(layer, QgsVe …
1
vote
Avoiding buffer exceeds layer boundaries in QGIS
There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have five features in 'poly_test' (purplish) and ten in 'random_points_test' (orang …
2
votes
Avoiding buffer exceeds layer boundaries in QGIS
This is a combination of the "Buffer" and "Intersection" within the "Geometry by expression" from the Processing Toolbox (Ctrl+Alt+T).
Let's assume we have five features in 'poly_test' (purplish) and …
9
votes
Exporting several layers as GeoPackages at the same time in QGIS
Another solution is to use the "Package layers" tool as a Batch Process.
3
votes
Accepted
'NameError: name 'importos' is not defined' when loading GeoJSON file QGIS
I could get the same error:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS32~1.5\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in < …
1
vote
Using ogrinfo in Python script
Another option is to employ the Python subprocess package.
Also, one needs to know where the ogrinfo.exe file is located.
After executing one of the following commands:
import subprocess
command = "C …
6
votes
Accepted
Getting all shapefile layers in project using PyQGIS
The shapefile format is a geospatial Vector data format, therefore on a first stage I suggest to catch all of vector layers with the QgsVectorLayer class.
There are several approaches to achieve it wi …