Stack Exchange Network

Stack Exchange network consists of 174 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
27 views

PostGIS DISTINCT ON clause

I have two tables essa -- thousands of polygons narrowed -- few hundred parcels My goal is to find the closest parcels to each essa polygon. it happens to be many of the parcels are the closest ...
0
votes
1answer
17 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 ...
2
votes
0answers
65 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 ...
0
votes
1answer
48 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 ...
0
votes
0answers
23 views

Correcting boundary effect on GIS spatial analysis?

I have 250 zones in ArcMap, and I calculated RNN for points of each zone with nearest neighbor analysis tools. How can I correct edge effects in GIS?
2
votes
1answer
27 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 ...
3
votes
1answer
46 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
vote
1answer
35 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 ...
-1
votes
1answer
54 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 ...
1
vote
1answer
62 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 ...
2
votes
1answer
72 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 ...
1
vote
2answers
62 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 ...
4
votes
2answers
87 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 ...
3
votes
1answer
85 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 ...
0
votes
1answer
25 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
60 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
0answers
43 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
46 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
1answer
85 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
73 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
48 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
152 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
95 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
68 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
168 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
42 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
84 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 ...
0
votes
0answers
65 views

Nearest neighbour raster values only in specific zone

This is a follow up question to my previous post and someone else's post: I would like to replace NA values in raster with average nearest neighbour values, but ONLY in specific zone of the raster: ...
3
votes
2answers
96 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
1answer
197 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
237 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
101 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
372 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
80 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
34 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 ...
4
votes
1answer
299 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 ...
2
votes
0answers
116 views

How to solve Python error for raster analysis interpolation nearest neighbor in QGIS [closed]

I am trying to interpolate temperature values into a raster using QGIS 2.18.15 in Windows. I need the output file as a GeoTIFF (.tif) file. I have my input for temperature already in a shapefile, but ...
0
votes
0answers
114 views

Neighborhood operation within raster using python

I want to perform a neighborhood operation on a raster which will take pixel values in 8*8 window and run through entire raster image (in .tif format). Can anyone suggest any useful python documents ...
5
votes
1answer
95 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(): ...
1
vote
0answers
68 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 ...
0
votes
0answers
52 views

When does nearest neighbor PostGIS query need to be measured in meters?

When you use geography type in postGIS, the default measurements are in degrees. There are numerous approaches and I cannot decide which one is the best. In "PostGIS in Action" book (ISBN: ...
1
vote
1answer
84 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
234 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 ...
2
votes
1answer
391 views

What function can I use in R to classify 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
99 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
276 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 = ...
0
votes
0answers
490 views

NNJoin distance output in metres instead of decimal degrees

I'm a beginner using QGIS 2.18. I have two vector layers, one consisting of multiple points identified by lat&lon (these are points marked at sea) and another consisting of a line feature (...
5
votes
3answers
339 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, ...
0
votes
2answers
69 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
218 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 ...