Questions tagged [nearest-neighbor]

A technique for resampling raster data in which the value of each cell in an output raster is calculated using the value of the nearest cell in an input raster.

Filter by
Sorted by
Tagged with
2
votes
0answers
355 views

Geo-hash finding nearest neighbour with massively variable distance to actual nearest neighbour

I have a series of points in lat-long space, ranging from having their nearest neighbour very close to 1000s of km away. Say I do a geo-hash of these to a high precision, my search of nearest ...
0
votes
1answer
286 views

Optimizing a nearest neighbor search in PostGIS for a large dataset

The below code is working well for smaller datasets, however I want to use this with a 30 GB table. Every time I run it using the larger table I run out of SSD space, the table gets to 127 GB in size! ...
2
votes
2answers
666 views

Nearest Neighbor

We've got a table of approximately 300,000 points and would like to find the nearest neighbor (within 10km) to each point in the same table. The most efficient query we've found so far is below, but ...
2
votes
0answers
306 views

Find the nearest neighbour for points in one layer to points in another, then measure the distance

USING QGIS 2.18.19 with python console (planning to upgrade to the newest QGIS after this piece of programming) I am struggling with finding the correct pyQGIS coding for this. I have a shapefile ...
1
vote
1answer
237 views

For each row of GPS coordinates, get value from nearest road to coordinates and copy to said row using PostGIS? [closed]

I have two tables in my database; one contains a set of GPS coordinates of a car which have been converted to geom, and another containing Open Street Map road data, including the speed limit for most ...
1
vote
1answer
425 views

Nearest point on line from a point in PostGIS and its attribute value

Consider the following image; I have points (shown in blue circles) stored in my database with their geometry and an attribute value. Additionally, I have another table with User Points (yellow ...
1
vote
1answer
77 views

Get barrier edge id

I have a table of POINTs that represent barriers. I would like to be able to find the closest edge id on the edge graph so that I can have the routing algorithm ignore that edge (thus route around it)....
2
votes
1answer
205 views

QGIS 3.0.2 NNJoin doesn't complete. Crashes when close status bar

I have run a large spatial point to polygon join of 2 million points to 657 polygons. I used NNJoin so that the closest polygon will be assigned to a point if the point does not lie within one. The ...
3
votes
2answers
190 views

Nearest Neighbor search in PostGIS using cases

I am using the following PostGIS nearest neighbor query to determine how close a point is to an area (polygon) that has been flooded and it's working well: SELECT ST_AsText(ST_SetSRID(...
3
votes
2answers
1k views

How to UPDATE with LATERAL Nearest-Neighbour query?

Say I have table gps like: CREATE TABLE gps( gps_id serial primary key, measured_timestamp timestamp, geom Geometry(Point,4326), stop_id int --Null ); And I have a table of stops like: ...
3
votes
1answer
689 views

Merging overlapping polygons with original polygons in QGIS

I have a large vector shapefile dataset containing polygons, many of which overlap. I want to assign each overlapping section to one of the original overlapping polygons. E.g. if polygon A overlaps ...
1
vote
2answers
240 views

ST_ClosestPoint usage in QGIS 3.0

I try to use ST_ClosestPoint function to find the closest point to find the MultiLineString layer. My line layer (Reach) has 42 attributes and point layer (Stations) has 7 attributes. My code is: "...
2
votes
3answers
859 views

Projecting GPS point to point in closest pgrouting road (map matching)?

I'm quite new to PostGIS and pgRouting. I'm interested in doing a simple map matching. Precisely, finding the closest point in a given OSM road network. I’ve successfully imported the OSM network ...
1
vote
1answer
144 views

Intersection with closest point using PostGIS?

I'm trying to update the field of a point table with a value from a linestring one : update object_elevation set contour_elevation = c.contour from contours c where st_intersects(st_ClosestPoint(c....
1
vote
2answers
37 views

elevation difference along the border of two categories GRASS

Consider the following raster with two categories and a DEM (numeric raster), I'd like to compute the elevation difference along the border (closest pixel) of those two categories, it doesn't matter ...
5
votes
2answers
785 views

Returning Multiple Nearest Neighbors

I'm trying to replicate a nearest-neighbor analysis that returns X (one OR more than one) neighbors in either QGIS or PyQGIS. For example: In this output, I have a set of locations (Red Stars) that ...
5
votes
1answer
227 views

QgsSpatialIndex.nearestNeigbor() unexpected result

I have a Linestring layer for which I have build a QgsSpatialIndex with the following code: my_linestrings_lyr_idx = QgsSpatialindex() for f in my_linetraings_lyr.getFeatures(): ...
2
votes
0answers
127 views

create neighborhood list in R with large dataset

I want to create a weight matrix based on distance. My code for the moment looks as follows and functions for a smaller sample of the data. However, with the large dataset (569424 individuals in 24077 ...
1
vote
1answer
191 views

Nearest Neighbor Analysis returning 0 for Observed Mean Distance

I am working in QGIS 2.18.14 to which i am fairly new. I am trying to perform a nearest neighbor analysis, however it returns 0 for the observed mean distance. the expected distance is also an ...
1
vote
1answer
468 views

Nearest Neighbour Pixel Value Google Earth Engine

I want to attach the values from one raster to another raster. Using simple band math I can multiply the value of the base raster which is the presence of mangroves and therefore 1 or masked by the ...
3
votes
1answer
665 views

Classifying raster that takes neighbours into account?

I am working on classifying forest types using Sentinel-2 satellite imagery (10-m resolution; band-2, band-3, band-4 & band-8). I have ground-truthed field data as a training set. I want to set a ...
4
votes
1answer
177 views

Faster way to find nearest neighbors with LASlib?

I'm using LASlib to find the nearest neighbors of a subset of points in a point cloud. I'm using brute force to find nearest neighbors, which is extremely slow (my code below). Is there a better way,...
3
votes
1answer
622 views

Finding the nearest line to a point in QGIS,but Not Work

I saw Finding the nearest line to a point in QGIS? I wanted to create a program to get the line closest to the selected point. Here is the code. dPos = mouseEvent.pos() qpoint = ...
5
votes
3answers
690 views

Clustering neighboring points inside ArcGIS Desktop?

I am using ArcGIS Desktop 10x. I have a shapefile of 300 points which I need to make groups, each of which will contain exactly 9 points which are closest neighbors. I tried the 'near' tool, which ...
0
votes
2answers
167 views

Loop to caculate NNI with spatialEco

In R, I need to calculate the nearest neighbour index between the relocations of a single animal, for several different individuals. I want to determine whether the relocations of certain individuals ...
1
vote
0answers
300 views

QGIS Nearest Neighbor Analysis on Layer Subsets with User Defined Area

I have a data set of developments of various types in a single US City. My aim is to run a nearest neighbor analysis for each of the various development types to explore how clustered, random or ...
9
votes
1answer
240 views

Finding closest line given 2 points using PostGIS?

I have a table t that contains a column line_positions which is of type line. Given 2 points I want to find the closest line that is close enough (less than 10km) and that does not pass too close to a ...
0
votes
0answers
63 views

Sampling Points and Areas around them

I have some coordinates in QGIS. I want to sample the values corresponding to those coordinates on a layer. I know that I can do that for the exact point using 'Point Sampling Tool'. Is there also a ...
1
vote
1answer
390 views

Slow execution of request for searching nearest street to GPS point

I use OSM data. I need to find nearest street for GPS point. I wrote next SQL query: SELECT osm_id, name, ST_DISTANCE(geometry, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true)...
2
votes
0answers
186 views

k nearest neighbour with count limit

I have a set a points, and I want to create 10 clusters. I used attribute based clustering plugin, which worked well for creating the clusters, but the points count isn't perfect, some clusters have ...
1
vote
1answer
179 views

Finding the side of a square that a point intersects with R (sp)

I have a point and a square polygon. Both are sp classes. The point intersects one side of the polygon, and I need to know which side of the square it intersects (i.e. north, east, south, or west). ...
2
votes
0answers
216 views

Finding the closest points to a line with only one point from each subset of points

I have a set of data points that represent many paths for different journeys, where each journey has its own identifier (Operation No). The data for all journeys is in a single table but in effect has ...
2
votes
2answers
210 views

Classifying neighbors AND neighbors of neighbors using ArcGIS Desktop?

In ArcGIS 10.2, I'm trying to identify the neighbors AND neighbors of neighbors for counties in the United States. Although I can identify which counties are neighbors to each county using either a ...
1
vote
1answer
369 views

ArcMap Calculate Average Nearest Neighbor - failed

I am trying to determine the mean and standard deviation from a subset of point features. Once I determine the standard deviation I want to exclude any points that are more than twice the standard ...
2
votes
1answer
852 views

How to get distance values from nearest neighbor query for 5 closest features to multiple records in PostGIS?

I found this query on this blog https://geeohspatial.blogspot.com/2013/05/k-nearest-neighbor-search-in-postgis.html?showComment=1480796271673#c3250651227513965563 which returns the 5 closest records ...
2
votes
0answers
58 views

Postgis query for nearest neighbor returns distant coordinates [closed]

I have schema for a table called "places" that looks like this with about 6000 rows: name | county| long | lat | the_geom | id Tuthilltown | Ulster | -74.1789 | 41.6843271513 | ...
1
vote
0answers
815 views

NNJoin returns incorrect distances

Bottom Line Issue: The distances I get from NNJoin for the shortest distance from a point to the nearest polygon are several hundreds or even thousands of meters shorter than the distance I calculate ...
5
votes
1answer
272 views

Postgis Distance calculation on huge datasets

We have 7,512,694 records in our table, Columns: id, name, lat (numeric), lon (numeric), location (geometry(Point,4326)) Indexes we created: create index on table using gist(location); and of ...
1
vote
2answers
257 views

Simulating a point pattern under Complete Spatial Randomness in R

As per title, I am trying to figure out how to simulate such point pattern without the use of the 'spatstat' package (which I cannot install due to the old version of R which I am using, which in turn ...
7
votes
1answer
1k views

PostGIS / OSM: Faster query to find nearest line of points

Following scenario: I have a table roads, which basically contains the road network of a whole country extracted from the OSM line table and a table points containing millions of GPS tracked points ...
7
votes
2answers
2k views

distance matrix with a linear feature

I would like to use the distance matrix tool (or a similar function) to look at distances between sites (displayed as point data) and large rivers (displayed as linear). I have been following this ...
1
vote
1answer
174 views

Nearest Neighbor distance frequency distribution

I have a dataset of 6455 points. Is there a way to produce the frequency distribution of nearest neighbour distances in the data set in ArcGIS 10.3? The Average Nearest Neighbor tool only produces the ...
1
vote
0answers
46 views

max sum within a 200mt radius

I have a SpatialPointData Frame in R. Each point represents lat long and InsuredValue amount. I would like to find the maximum sum of insured value in a radius of 200 mt. How I can do in R
7
votes
2answers
4k views

Calculating distance between points of same layer using QGIS?

I am using QGIS 2.13 and a layer with hundreds of points. I need to calculate the distance to the nearest point... in the same layer. I tried the distance matrix but I get 0m since the "closest" point ...
2
votes
1answer
195 views

Nearest neighbors

I have a point shapefile overlayed over a grid-based polygon shapefile. I would like to select the nearest neighbor grid cells of a given grid cell that contains any of the given point(s). So let's ...
1
vote
1answer
113 views

Finding nearest point using point dataset using QGIS?

I have created Geocode for some area and I couldn't find accurate Geocode's for few address. so I want to find the nearest POI for non accurated locations using accurated geocodes as referece in QGIS. ...
1
vote
1answer
610 views

Optimizing PostGIS k-nearest neighbour function for large amount of polygons?

I created a function for identifying the K nearest neighbours for every municipality, which works fine, but when I use this function for a large amount of municipalities (over 2900) it takes over 2 ...
0
votes
1answer
727 views

Finding neighbors for non adjacent polygons in R [closed]

I'm looking for a method or function in r-project that create a neighborhood matrix from a group of polygons that don't touch each other, like polygons of set of blocks separated by streets in a town. ...
1
vote
1answer
247 views

Nearest Neighbor Analysis for route events

I have events that are on routes. You can think of it as accidents on a highway. I want to do some spatial statistics on it. The road is an M enabled feature class and decision makers want logical ...
1
vote
0answers
108 views

Applying Edge Correction in ArcGIS Average Nearest Neighbor?

I am using ArcGIS 10.3 with the tool Average Nearest Neighbor from the Spatial Statistics toolbox to describe the data. I want to avoid mistakes caused by Edge Effect. In the Ripleys K Function tool ...