34
votes
Accepted
Creating buffer circle x kilometers from point using Python?
Use a spatial projection library to do the hard work. Adapting from a previous answer, use a dynamic azimuthal equidistant projection to do a geodesic buffer.
Updated solution with PyProj 2.1+
from ...
17
votes
Accepted
Finding algorithms of QGIS commands?
The "minimum bounding geometry" and "clip polygon" algorithms in QGIS are implemented in /python/plugins/processing/algs/qgis/MinimumBoundingGeometry.py and /src/analysis/processing/qgsalgorithmclip....
14
votes
Accepted
Seeking Algorithm to detect circling and beginning and end of circle?
I couldn't stop thinking about this... I was able to come up with a Stored Procedure to do the loop counting. The example path contains 109 loops!
Here are the flight points shown with the loop ...
14
votes
Accepted
Investigating PostGIS functions to see what they are doing?
Not sure if this is helpful, let's go down the rabbit hole. First we need to know what's happening when you call the function in SQL. To do this we reference the output of \dS+. \dS+ shows the ...
14
votes
Accepted
Listing multiple fields to be dropped at once in QGIS modeler?
You need to separate them via semi-colons:
field1;field2;field3
13
votes
Finding minimum-area-rectangle for given points?
I just implemented this myself and posted my answer over on StackOverflow, but I figured I'd drop my version here for others to view:
import numpy as np
from scipy.spatial import ConvexHull
def ...
13
votes
Detecting branched polygon shape?
You could have a look at the following method : skeletonize your polygons and rather work on line type features related to your original polygon with a unique source polygon ID. I guess there's some ...
12
votes
Accepted
Get progression bar into PyQGIS 3 standalone script
Yes - processing.run accepts a "feedback" argument, which must be an instance of a QgsProcessingFeedback subclass.
If you construct your own feedback object to pass to this function, you can connect ...
11
votes
Accepted
Clustering undirected lines
If I understand you right you want to cluster lines that is about the same without respect to direction.
Here is an idea that I think could work.
split the lines in start point and end point
Cluster ...
9
votes
What are Definition, Algorithms and Practical Solutions for Concave Hull?
QGIS does have Concave hull algorithm.
Parameters
Input point layer [vector: point]
put parameter description here
Threshold (0-1, where 1 is equivalent with Convex Hull) [number]
put parameter ...
9
votes
Accepted
Is there an optimal algorithm to find the longest shortest path in a network?
I think you may be looking for the Graph Diameter of your network. There are a couple of questions on stackexchange that mention this topic, e.g.:
The time complexity of finding the diameter of a ...
8
votes
Generalization algorithms
You can have a look at the following python versions of those algorithms:
Visvalingam–Whyatt
Reumann–Witkam
Opheim simplification
Lang simplification
Couldn't find an example for Zhao-Saalfeld (yet)....
8
votes
Is there an optimal algorithm to find the longest shortest path in a network?
According to the Wikipedia page Longest path problem, this problem
... is NP-hard, meaning that it cannot be solved in polynomial time
for arbitrary graphs unless P = NP. Stronger hardness ...
8
votes
QGIS algorithm to copy vector layer with only selected fields
The export / save layer as dialog provides a list of fields where users can chose which fields should be included in the export.
To reproduce this in a Processing model, you can use the "Drop ...
7
votes
Minimising number of dynamic pages to map scattered points using ArcGIS Desktop?
This is not the answer, I just thought I post Python solution for those who interested:
# ---------------------------------------------------------------------------
# PAGE MAKER
#
# ----------------...
7
votes
What algorithm does QGIS use to calculate Nearest Neighbor Index?
You can check the source code for the Nearest Neighbour Analysis tool from GitHub. More specifically, the following lines of code which shows how the different parameters are calculated:
do = float(...
7
votes
Accepted
Finding Similar Map Paths
Map matching is different from what you are looking for. Map matching is the proper way of matching an erroneous GPS observation to the linear street network. Your question has nothing to do with GPS ...
7
votes
Accepted
Creating line between two points with same value using QGIS?
On the sensor layer, go to symbology and change the symbol to a "Geometry Generator". Choose "Line" as type.
Enter the following expression
make_line(
-- the current feature's geometry (point from ...
7
votes
Accepted
Let QGIS 3.0 Processing algorithm output a VectorLayer loaded via the delimited text provider
Because your output here is effectively hard-coded, you don't need to define it as a input parameter. Instead declare it as an output that your algorithm generates:
self.addOutput(
...
7
votes
Accepted
PyQGIS Processing: "memory: not found"
The grass provider does not support QGIS memory layers, so you'll need to give it a path to a real location it can store the temporary result as.
7
votes
What is algorithm name for "Count Points in Polygon" using PyQGIS?
In case you do not know a name or id, you can use:
searchstring = 'count' # to get all algorithms just leave this empty
for alg in QgsApplication.processingRegistry().algorithms():
if searchstring ...
6
votes
Free implementation of Polynomial Approximation with Exponential Kernel (PAEK) algorithm
I came across a thread Smoothing a 2-D figure. The answers make reference to this paper Chaikin's algorithm for curves
For a given polygon with vertices as P0, P1, ...P(N-1), the corner cutting ...
6
votes
How to find the concave hull for a cloud of points in 3D space?
A convex hull is unique, whereas there are many possible concave hulls. So you cannot say "the concave hull" but "a concave hull".
There is possibly a minimal volume concave hull, but this is not the ...
6
votes
Clustering undirected lines
Do you really want to cluster solely by direction, without any consideration of origin or destination? If so, there are some very simple ways. Perhaps the easiest is to compute the bearing of each ...
6
votes
Accepted
Calculating the earth radius at latitude
You made an error in the line defining the radius in your function. Instead of f3 / f4 it should be f3 + f4. The corrected line should be as follows -
var radius = Math.sqrt((f1 + f2) / (f3 + f4));
...
6
votes
Accepted
How to use a Processing Algorithm in a expression function used in a Geometry Generator (Points Along Lines "on the fly")
You can use the following expression to create the points along the line every n distance (here 5000 considering the layer use meters)
collect_geometries(array_foreach(
generate_series(0, length($...
6
votes
Accepted
What is the algorithm that Shapely used to check if two polygons intersect?
A quick search of the Shapely code base leads to impl.py which:
"""Implementation of the intermediary layer between Shapely and GEOS
This is layer number 2 from the list below.
...
6
votes
Accepted
What is algorithm name for "Count Points in Polygon" using PyQGIS?
It is "native:countpointsinpolygon".
I usually execute the tools manually in QGIS then Ctrl+Alt+H to copy paste the syntax to use in PyQGIS.
6
votes
Detecting and making all connected lines in the same direction in QGIS
Compare the azimuth of each line to the line group mean, and reverse the line in each group that deviate the most from the group mean:
Refactor fields (or use two field calculators) to calculate:
...
6
votes
Accepted
Algorithms for finding nearest road
You can use Hausdorff distance:
Two sets are close in the Hausdorff distance if every point of either
set is close to some point of the other set.
Here I cross join the table to itself to compare ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
algorithm × 567qgis × 71
polygon × 51
python × 44
postgis × 38
geometry × 36
arcgis-desktop × 31
coordinate-system × 28
distance × 26
pyqgis × 25
qgis-processing × 21
spherical-geometry × 21
routing × 19
point × 17
gps × 17
line × 15
raster × 14
r × 14
qgis-3 × 14
clustering × 14
gis-principle × 14
javascript × 13
qgis-modeler × 12
dem × 11
vector × 11