Absolutely you can. And it can be quite fast. (The intensive computation bits can ALSO be distributed)
There are several ways, but one way that I've been working with is in using an ordered list of integer-based geohashes, and finding all the nearest neighbour geohash ranges for a specific geohash resolution (the resolution approximates your distance ...
As an alternative, you could:
Use the Convert Lines to Points tool from:
Processing Toolbox > SAGA > Shapes - Points > Convert Lines to Points
(Add points over small distances. E.g. add a point every 1m if the overall line is 100m)
Use the Distance to nearest hub from:
Processing Toolbox > QGIS geoalgorithms > Vector analysis tools > Distance to nearest ...
I can get you part of the way there by assuming you have figured out how to request (a) the easternmost half of a set of points and (b) the northernmost half of a set of points. From these you can, of course, easily obtain (c) the westernmost half or (d) the southernmost half. (I don't know QGIS, but one way to do (a) in general is to request the median x-...
Let's break this down into simple pieces. By doing so, all the work is accomplished in just a half dozen lines of easily tested code.
First, you will need to compute distances. Because the data are in geographic coordinates, here is a function to compute distances on a spherical datum (using the Haversine formula):
# Spherical distance.
# `x` and `y` ...
To illustrate a raster/image processing solution, I began with the posted image. It is of much lower quality than the original data, due to the superposition of blue dots, gray lines, colored regions, and text; and the thickening of the original red lines. As such it presents a challenge: nevertheless, we can still obtain Voronoi cells with high accuracy.
Here is a python solution, using arcpy to access the data and numpy to calculate the statistical values.
Using arcpy.da.SearchCursor() write the values to a list. Use python.numpy.percentile() to find the threshold percentile values that you want to use to identify outliers, lets take your example and drop the lowest 10% and highest 10% of values.
If you ...
If you want to select all features that are within 100 m of the selected "buffer" feature you can use next code:
layer = iface.activeLayer()
feats = [ feat for feat in layer.getFeatures() ]
#selected feature fid = 0
geom_buffer = feats.geometry().buffer(100, -1)
#erasing selected feature in original list
new_feats = [feat for feat in ...
No need for JOIN LATERAL (or do you really just want to use it?); an UPDATE will pass each processing row to the following query, which is the same concept as using a JOIN LATERAL.[*]Try
SET stop_id = (
ORDER BY gps.geom <-> stops.geom
You are a very experienced PostGIS user; still, let me ...
The question could be read in several ways. I interpret it to mean you have a large number of points and you intend to probe them repeatedly with arbitrary points, given as coordinate pairs, and wish to obtain the n nearest points to the probe, with n fixed beforehand. (In principle, if n will vary, you could set up a data structure for every possible n ...
the grass algorithm v.net.alloc can produce the subnets - you can call it from the Processing toolbox (tested in QGIS 2.16)
You'll need a point layer (for facilities) and a lines layer with costs (either time/length). It'll create a new line layer with a field called cat added, which will be the id of the nearest facility.
Here's an example based on ...
As I understand it, v.neighbors outputs a raster that can hold the number of points within a set distance from each cell, but does not identify whether or not the points themselves have any neighbours (see the manual page).
Anyway, instead you could try a clustering tool, for example DBSCAN clustering. Set the minimum cluster size to 2 and maximum distance ...
As @ziggy said in the comments,
"shouldnt it be asc if you trying to find the closest point?"
Your code is not correct (reproduced below),
SELECT point, strength
ORDER BY st_distance(st_makepoint(:lng, :lat)::geography, point) DESC
What you want is,
SELECT point, strength
ORDER BY st_distance(...
I guess it is the centre of triangle excircle with largest radius, that touches no more than 3 points. In the picture below first 11 such centeres shown. They are labelled by their ranking number.
It is enough to weed out ones that are outside triangles and define the champion, i.e. No3 in the picture.
UPDATE INSPIRED BY STEVEN FINDING:
Result above ...
The resampling method 'near' or 'nearest' is generally to be considered only for succinct/classified data, it attempts to assign a cell value based on the closest source pixel:
This is most commonly integer (int8, int32, int64) types but can be of type float (float32, float64) where each cell represnts classified values and generally values appear more than ...
Use proximity analysis with the near tool.
You could create a cursor in a script or a model to loop through the features.
I think you can:
Convert line vertices to points(line_points).
Make voronoi polygons using the points(line_points).
Dissolve the resulted polygons using either an id attribute which has been saved from line layer, or by a spatial join with line layer.
I hope I have really understood your question, if not can you provide a drawing to explain your needs more....
It turns out I need to use ST_DWithin to narrow down the scope of the search and prevent the query from performing a sequential scan on the entire bigger table on every iteration.
This is what I ended up using and takes only around 20 seconds to run on the entire table:
UPDATE nbi.testpoints SET closenbicount = (SELECT count(1) FROM nbi.bridges WHERE
ORDER BY ST_Distance(road_table.geom, 'gps-point in wkt')
Since PostGIS 1.5 you also have the option of using ST_ClosestPoint.
Some discussions of how to use it can be found here:
About ST_ClosestPoint you can ...
The FNN package has a function get.knnx which can compute the N-nearest neighbours in point patterns. For what you want, this should work:
nn = get.knnx(A,B,k=1)
Which should just return the nearest neighbors between the two datasets. You can also specify what nearest neighbor algorithm it will use, be it kd_tree, cover_tree, CR, or brute force.
Try Select by Location tool (menu > Selection > Select by Location).
set the target layer, the layer from which the selection to be
made (for example, the point feature)
set the source layer (polygon)
select are within a distance of the source layer feature from the Spatial selection method drop down
set the search distance (100) and unit (meter)
Assuming that you are searching for the closest line edge to your point, you can do a K-Nearest Neighbour (KNN, or 1NN in this case), based on this answer. However you want to use the <#> operator instead, since that operates on the edges of the bounding boxes, rather than the centroids.
FROM public.road_segments r
ORDER BY r.geom <-> ...
I did have the same the same research question as you. I wanted to calculate the distance from archaeological sites to rivers. I did have access to a hydrological layer by INEGI. I did have rivers as lines and as polygons. This is what I did. First I converted the polygons to lines using vector/ geometry tools/polygon to lines. Now I did have all my rivers ...
In order to calculate the nearest distance of polygon features to your points (not using QGIS or anything in the proximity toolbox), you could perform a spatial join. You should choose CLOSEST for your match option and add a descriptor for your distance field name which is what will be filled with your near distances.
This will work well for all of your ...
Buffer points - dissolve = none:
Notice that ArcGIS has added the first field in the list 'Join_Count'. This will record how many POIs intersect the Buffers. The attribute table of the spatial join output will have all your attributes from the points, as well as the join count.
Export the spatial join result to excel and clean up the table.
Here's a follow-up. Thanks to @FelixIP for pointing me in the right direction!
Using the OSM data from Australia, I was able to find the "point of inaccessibility" on the Australian Mainland - I make it around 260km equidistant from Akarnenehe, Bedourie, and Mount Dare, at POINT(137.234888 -24.966466)
I found a fairly easy workflow in QGIS which uses a ...
I don't know of any easy way to do this in QGIS, but it can be very quickly done in PostGIS. Say you install Postgres and PostGIS, and import your points layer as "centroid", and polygon layer as "neighbourhood". This is the query you'd then execute:
SELECT c.id AS centroid_id, n.id AS neighbourhood_id, k.dist AS distance
FROM centroid as c
JOIN LATERAL (...
You should use the Near command. It will create a Near_FID field which is the FID of the nearest Line Feature. Just join on this and you should be able to Calc your points with the closest Line Name. Should be a short script.
This is a bit old, but I was searching for solutions to this problem today (point --> line). The simplest solution I've come across for this related problem is:
>>> from shapely.geometry import Point, LineString
>>> line = LineString([(0, 0), (1, 1), (2, 2)])
>>> point = Point(0.3, 0.7)
POINT (0.3000000000000000 ...
I think you should use ST_Line_Interpolate_Point function for finding closest point on a polyline and ST_Distance function for calculating distances between the closest point and polyline.
what i understood from your question is that you meant something like this:
ST_Line_Locate_Point — Computes de fraction of a Line from the closest
point on the line ...
I'm going to credit @Geoist with the answer to this question, based on his comment above (NOTE: if you repost your comments as an answer, I will give you the "accepted mark").
As it turns out, the issue was in trying to run the NEAR analysis against the personal geodatabase on a network drive. As soon as I changed the source to an ArcSDE or file on the ...