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 [knn]

use this tag when dealing with questions related to kNN(K-Nearest Neighbors) a spatial property.

3
votes
1answer
119 views

MongoDB - fast & accurate k-NN

We have been testing the effectiveness of the k-NN query in MongoDB and Postgis on New Year City's taxi dataset on two aspects: run-time and accuracy. The staggering outcome is that MongoDB detects ...
0
votes
1answer
215 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 ...
5
votes
1answer
64 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 ...
3
votes
1answer
153 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 ...
2
votes
1answer
216 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 ...
3
votes
1answer
112 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
57 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
1answer
214 views

How to display a popup in the marker?

I have a displayed markers for the leaflet-knn on the map and the name of marker is displayed on the div at right-panel. When I click on this list, I want to show the popup on the associated marker. I ...
8
votes
3answers
2k views

How to make use of indexes with inner join in Postgis?

I got 2 sets of points in 2 separate tables. Table_a got 100k points and table_b got 300k of points. I trying to find nearest points in relation find me any point from table_b that is within 50 meters ...
2
votes
2answers
379 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
70 views

Supervised Classification using Remote Sensing data?

Is there a correlation between the time that supervised classification takes to execute and the training areas that we choose? Perhaps if we take larger areas for classification will the ...
1
vote
1answer
212 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
50 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
130 views

Finding nearest point for each distinct category in performant way usig big PostGIS table?

I have a table, etablissements with millions of rows, and a geom (st_point) column , spatially indexed (using gist). Those features may have a different category, activite_principale. I want to find ...
3
votes
1answer
510 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: ...
1
vote
2answers
133 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
501 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
100 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....
6
votes
1answer
159 views

Spatialite KNN view in QGIS

My task is to calculate the average ground survey level for each tree in my dataset, using the 3 closest survey points (optionally within a 3m radius of the tree). I want to write this in a Spatial ...
0
votes
1answer
128 views

Optimizing my script; taking too long; distance between many objects PostGIS

I have many many points and want to calculate the shortest distance from each point to the closest line of a table with many many lines. I think my underneath code is correct, I however never get an ...
5
votes
1answer
94 views

ST_DistanceSphere and KNN discrepancy

I have a table containing thousands of data points around London. I'm trying to write a query to find the closest data points to a given latitude and longitude. I'm getting different results based ...
3
votes
0answers
304 views

PostGIS <-> operator does not return true distance

I want to find the closest polygon to a point. My idea was to use the <-> operator for it. According to the docs it says: For PostgreSQL below 9.5 only gives centroid distance of bounding ...
0
votes
2answers
444 views

shortest distance between road and lake with PostGIS

I have a country-wide dataset with lakes (polygons) and streets (lines). For each lake I want to know the shortest distance to the closest street. (I do not necessarily need the closest street itself ....
1
vote
0answers
162 views

Point to Polygon nearest distance DS_distance is not using geography index & knn <-> or <#> does not give result in order [closed]

The below query gives result in wrong order. SELECT *, ST_Distance_Sphere(ST_SetSRID(ST_MakePoint(-75.66,45.33), 4326 ) , geometry ) / 1609.34 AS distance FROM myTable ORDER BY geometry <#>...
3
votes
1answer
848 views

Postgis KNN vs ST_DWithin for nearest neighbour search with a radius

We are trying to get nearest neighbors within a user given radius. As far as I understand ST_DWithin degrades as distances are increased. The problem with using KNN is that it keeps on searching even ...
2
votes
1answer
587 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 ...