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
20
votes
4answers
24k views

PostGIS nearest points with ST_Distance, kNN

I need to obtain on each element on one table the closest point of another table. The first table contains traffic signs and the second one the Entrance Halls of the town. The thing is that I can't ...
8
votes
1answer
2k views

Nearest Neighbor calculation in PostGIS?

I'm learning how to use PostGIS and spatial databases for analysis. What I am trying to do is perform a calculation to get the distance for the nearest polygon in a file, using the edge calculation, ...
16
votes
1answer
6k views

Finding Nearest Line Segments to Point using shapely?

Background From a known Point, I require to establish the nearest surrounding "visible perimeter" against a table of MultiLineStrings, as shown on the diagram. I've searched this site with a number ...
3
votes
2answers
622 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: ...
7
votes
2answers
740 views

Why does QgsSpatialIndex.nearestNeighbor(point, 1) sometimes return 2 lines?

I'm trying to get the closest line to a point using PyQGIS in a plugin. The active code file is this: http://pastebin.com/TDzmsKVM When I request the closest line (only 1) nearestIds = self.spIndex....
5
votes
3answers
502 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, ...
10
votes
4answers
13k views

Finding nearest neighbors between two tables with point locations in SpatiaLite?

I have started playing with SpatiaLite today and already stumbled upon a problem. For each point location stored in tableOne I would like to select one, nearest (linear distance) point from tableTwo. ...
25
votes
1answer
2k views

Nearest Neighbor problem in Postgis 2.0 using GIST Index (<-> function)

I'm trying to use Postgis 2.0 new function <-> (Geometry Distance Centroid) in order to calculate, for each row of my table (cosn1), the distance to the nearest polygon of the same class. I was ...
4
votes
2answers
1k views

Using nearest neighbor query in SpatiaLite?

I am trying to find the nearest line to each point in a layer, and I have over 1 million points. I want to be able to associated the closest unique line ID with the point unique IDs. I have tried to ...
1
vote
1answer
52 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)....
1
vote
1answer
201 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 ...
13
votes
3answers
4k views

Optimizing a nearest neighbor calculation using PostGIS

I'm using PostGIS to calculate the nearest neighbors of polygons. What I want to calculate is the minimum distance from each polygon, to the nearest polygon. Thus far I have got great help from Mike ...
18
votes
3answers
15k views

Algorithm to find nearest point

I've a list of a few hundred cities with their latitude/longitude. Given another location (also in lat/long) I need to find the nearest city. As I don't use any GIS, by now the obvious algorithm is ...
7
votes
4answers
3k views

Calculate polygon field based on neigboring polygon attribute

I have a vector shape with many different sized polygons each possessing an own class name (for instance "houses", "houses with offices", etc ...) I want to assign a new field to each polygon ...
8
votes
1answer
4k views

Distance to nearest point for every point same SpatialPointsDataFrame in R

I have a SpatialPointsDataFrame that I'm working with in R. I want to add a new vector to the dataframe that contains, for every point, the distance to the nearest other point in the ...
6
votes
2answers
1k 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 ...
2
votes
2answers
448 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 ...
1
vote
1answer
99 views

Constructing Voronoi Polgon and Applying Nearest neigbour in it

I am learning QGIS 3.XX and currently working on Voronoi Polygons. I have three layers Point layer Building Layer Population CSV file. These points layer are basically water tanks and building ...
10
votes
2answers
24k views

Find closest lat long to an input lat long (SQL Server 2008)

I have a point cloud in my database (SQL Server 2008 spatial). That is about 6 million records. There are 3 columns: id, value, geom. What is the optimal way of getting the 'value' at input lat long?? ...
15
votes
6answers
1k views

PostGIS: Assign ID of point in layer A to closest point in Layer B

This should have been an obvious precursor (that I didn't ask) to my other question: How to create spider diagrams (hub lines) in PostGIS? If I do not know the relationship between a point in layer A ...
10
votes
1answer
670 views

How to efficiently find the closest point over the dateline?

I have a PostgreSQL 9.1 table with hundreds of thousands of PostGIS POINTs. For each of these I'd like to find the closest point in another table of POINTs. The points in the second table represent a ...
3
votes
1answer
1k views

Find nearest neighbours faster in PostGIS

I currently have a query that calculates the number of useful amenities within a certain radius of each town, using OSM data: create table places as select town.name, place, town.way, ( select ...
3
votes
1answer
178 views

PostGIS -> LineString + PointZ = LineStringZ

DATA I have 2 tables in PostGIS: linestable with MultiLineString geom surveypointtable with Point + elevation attribute GOAL The goal is to rebuild the lines as 3D replacing line's vertices with ...
3
votes
1answer
420 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 = ...
2
votes
1answer
588 views

Efficiently check for equal adjacent values in raster calculator

I have a raster consisting of integer values in each cell. I want to check every adjacent cell in a 3x3 grid to see if any one of the adjacent cells has a value EQUAL to the center cell, and if so, ...
2
votes
0answers
144 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
2answers
138 views

Combining st_join with st_nn to include all points within, as well as within a given distance of a polygon

This is a follow up to my earlier question (Spatial join in R - Adding points to polygons with multiple corresponding points). I have successfully joined a spatial points file to a polygon file in R ...
1
vote
0answers
109 views

Nearest Neighbour Analysis Or NN join

I have two Layer in my Project 1) Voronoi Layer which is constructed on point Layer 2) Building Layers which is represented as Polygon. The goal is to find the nearest node for every polygon (...
0
votes
1answer
921 views

Nearest neighbor analysis not showing results

I'm trying to do a nearest neighbour analysis on fish shoals distribution. I go to Vector > Analysis Tools > Nearest neighbour analysis. I choose the appropriate layer and when I hit ok the black ...
0
votes
2answers
225 views

Spatial join geotagged images to preexisting point shapefile? [closed]

I have a layer of geotagged images (points with jpg thumbnail attachment), and another layer of different points (shapefile with various attributes). I would like to perform a spatial operation in ...