Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
28 views

NearestNeighbor producing bad quality tiles

I have been using Bicubic interpolation to render some basemaps because this produced good results. This is what I get when using Bicubic: However, when using Nearest Neighbor interpolation, a white ...
0
votes
1answer
24 views

Seeking package/function in R that can help tag GPS coordinates of fauna sightings to nearest sampling point?

I have 1 dataset of animals sighted walking a survey, and I would like to tag them to the respective sampling points along a transect. Any idea what function/package in R can do that? Maybe ...
0
votes
1answer
38 views

Nearest Neighbor - return object ID in R

I have a csv file that contains the GPS coordinates of about 100 villages and their unique ID. I have an other csv file with the GPS coordinates of some potential destinations and their unique ID. I ...
0
votes
0answers
31 views

Finding nearest 10 observations that occurred 2 years before original observation using ArcGIS Pro ModelBuilder?

I have a point sample of house sales (~42k points over 9 year period) with a date field(integer), and for each point I want to find the 10 nearest houses within a year of sale and also which were sold ...
1
vote
1answer
44 views

Error creating DEM with Nearest Neighbour tool in QGIS?

I have an issue when I am creating a DEM with the tool natural neighbour on QGIS. When I extract my data directly on Qgis I have no issue creating a DEM. My points are coming from different sources ...
1
vote
1answer
16 views

How to get Memory layer dispalyed in Vector Panel List using Pyqgis?

I have two point layer in my Project Centroid.shp and Nodes.shp.I have used Distance Matrix to find nearest Nodes point from Centroid Point. I have saved the output in FinalDistance.csv. The ...
2
votes
1answer
23 views

Neighborhood Analysis with ArcGIS Spatial Analyst to Calculate Percentage

I have a raster file where the cells (1 meter) are classified as 1 (forest) and 0 (non-forest). I would like to create another raster (1 meter) where each cell is given the percentage of cells within ...
1
vote
2answers
84 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 ...
3
votes
1answer
161 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 ...
20
votes
4answers
23k 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 ...
2
votes
1answer
356 views

Matching two point clouds without loss (nearest neighbor, but more complicated) [closed]

I have two point clouds, one with demographic and one with electoral data. Points in both clouds represent the same empirical entity (say, a village, or an urban neighbourhood), but are not in the ...
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 ...
1
vote
1answer
180 views

KeyError: u'M' in Average Nearest Neighbour test

When I try and run the Average Nearest Neighbour test on my Shapefile I get the error: KeyError: u'M' Failed to Execute (AverageNearestNeighbour) On a "normal" Shapefile this works fine. However I'm ...
4
votes
1answer
185 views

Spatial Analysis - Identifying Regions with Common Boundaries

I have the shape file for DC PSA's as defined in 2012 (see below). I would like to be able to identify in semi-automatic fashion which PSA's are neighbors - that is, which PSA's are nearest neighbors ...
0
votes
1answer
90 views

Find the closest Point from a Point which contains the same attribute

I am trying to create python code to iterate through points on 1 layer and find the closest point on another layer (Road Chainages) based on attribute values. I need to limit the search to < 20m ...
0
votes
0answers
42 views

PostGIS - Nearest Neighbour Join to sum values

I have a table of polygons T1 and a second table of points P1 Each point has a value I want to sum the values of P1 for each T1, with P1 being the closest set of points to T1 At the moment the only ...
3
votes
1answer
507 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 ...
0
votes
1answer
248 views

Spatial join attributes based on closest point in PostGIS

I have two point tables from which I want to extract a value from one table to the other, based on the nearest distance of those two points. t1 t2 id | value id 1 | 100 1 ...
2
votes
2answers
160 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 ...
2
votes
0answers
351 views

Nearest Neighbor Analysis Results

I'm fairly new and entirely self-taught in using QGIS 3.4. I'm looking at turtle nest sites and trying to run a nearest neighbor analysis to analyze their distribution and establish whether or not ...
2
votes
1answer
42 views

How to find the closest stop point PostGIS

I have Point geometries created from lat,lon I loaded all the 10,000 stops in a certain city using gtfs i would like to query my db to find the closest stop reference to my point. the staypoint ...
1
vote
0answers
91 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 ...
5
votes
3answers
485 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, ...
5
votes
1answer
66 views

Getting the distance traveled across road segments

so I have a query that takes an encoded polyline, segmentizes that polyline into smaller pieces, and matches each point on that segmentized line to a "road segment" from a separate table in my ...
-1
votes
1answer
134 views

SRTM/DEM 1m resolution (batymetri) to point [closed]

I have bathymetry data (1 huge data) = SRTM/DEM/FGDBRaster (0,9818m resolution pixel, floating, 32 bit, 45 GB size) and an alternative data (split into small pieces data) = same data but with 1m ...
3
votes
1answer
404 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 = ...
3
votes
1answer
363 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 ...
2
votes
0answers
172 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 ...
1
vote
1answer
209 views

A line between point to nearest neighbour point using QGIS

I have a layer of points in QGIS which represent electric poles How do I create a polyline layer that would have lines running between the poles so it can represent the the electric cables that ...
1
vote
2answers
146 views

Excluding point from Nearest neighbor search once it's been matched using R?

I have two lists of addresses, List 1 and List 2. I want to find the nearest neighbors of the list--but without assigning more than one point to any point. So say point 1A is the nearest neighbor of ...
2
votes
1answer
234 views

Efficient way to find nearest feature between huge postgres tables

I have two tables (g1 and g2), both with around two million features. I need to know for each feature in g1, which is the closest feature from g2, with a condition. Since they are both so huge, I also ...
4
votes
2answers
135 views

Query takes very long time

I'm a newbie to POSTGIS and I wonder if someone could help me out. I have loaded all postal codes with their geographical coordinates (geography) and created an index on this coordinate. When I run ...
7
votes
2answers
722 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....
3
votes
1answer
118 views

Get closest road-segment to segmentized LineString points

So I have a table that stores a bunch of traffic counts for various road segments across the country. I'm regularly getting real-time location data from vehicles that are moving around a given region ...
8
votes
3answers
1k views

Calculating spatial lags per year in R

At the moment I am having some difficulties with calculating a spatial lag in R. I know how to calculate the lag in space-wide format but am unable to do it in long form, i.e. have repeated ...
0
votes
1answer
63 views

Query to return closest LineString given a Point [duplicate]

I have a road lines data in a table with field roads(id SERIAL ,the_line geometry(LineString,4326)) suppose an accident occurs in a middle or at any location in that waterline i want to stop the ...
1
vote
0answers
118 views

Interpolation in QGIS shows wrong output result [closed]

I have done interpolation (IDW and Nearest Neighbour) in QGIS. But interestingly the output shows the wrong result. The area where I have a huge number of points results in a lower Z value (it is ...
1
vote
1answer
54 views

No module named 'mmqgis'

I have two layers in my Project 1)Points Layers 2) Polygon Layer I need to apply nearest neighbour Analysis between point and Polygon, but i am unable to get . I tried the below code.I am using ...
1
vote
0answers
97 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 (...
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 ...
2
votes
0answers
175 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 ...
2
votes
3answers
523 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
102 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
140 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: "...
1
vote
1answer
225 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 ...
3
votes
1answer
554 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: ...
2
votes
2answers
418 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 ...
0
votes
1answer
134 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! ...
5
votes
1answer
143 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
156 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 ...