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 ...
Mike T's user avatar
  • 41.8k
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....
Candy Gumdrop's user avatar
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 ...
kttii's user avatar
  • 3,600
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 ...
Evan Carroll's user avatar
  • 7,031
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
ndawson's user avatar
  • 27.4k
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 ...
JesseBuesking's user avatar
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 ...
gisnside's user avatar
  • 7,798
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 ...
ndawson's user avatar
  • 27.4k
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 ...
Nicklas Avén's user avatar
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 ...
whyzar's user avatar
  • 12k
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 ...
mkadunc's user avatar
  • 2,041
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)....
Joseph's user avatar
  • 75.3k
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 ...
Alex Tereshenkov's user avatar
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 ...
underdark's user avatar
  • 83.8k
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 # # ----------------...
FelixIP's user avatar
  • 22.6k
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(...
Joseph's user avatar
  • 75.3k
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 ...
Farid Cheraghi's user avatar
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 ...
Matthias Kuhn's user avatar
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( ...
ndawson's user avatar
  • 27.4k
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.
ndawson's user avatar
  • 27.4k
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 ...
MrXsquared's user avatar
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 ...
whyzar's user avatar
  • 12k
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 ...
galinette's user avatar
  • 161
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 ...
whuber's user avatar
  • 69.5k
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)); ...
nash's user avatar
  • 1,976
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($...
ThomasG77's user avatar
  • 30.3k
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. ...
Ian Turton's user avatar
  • 80.4k
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.
BERA's user avatar
  • 68.8k
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: ...
BERA's user avatar
  • 68.8k
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 ...
BERA's user avatar
  • 68.8k

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