Nearest point on line

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Nearest point on line

Christoph Jung
Hello list,

Does QGIS has a function to calculate the nearest point on a line layer by a given point layer? In PostGIS i could query it with min(st_distance(...)) or st_closestpoint(...).  But I miss such a function directly in QGIS (I just found the plugin Cloest Point, but it has some issues...).

Sincerely,
Christoph
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Nearest point on line

magerlin
Not sure I understand your question completely - but the NNJoin plugin can be
used to join features from one layer to nearest feature in another layer



-----
Regards Morten

Currently using Qgis 2.18.23 (OSGeo4) and Qgis 3.8.0 in parallel
Windows 7, 64bit
--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Regards Morten

Currently using Qgis 3.10.0
Windows 10, 64bit
Reply | Threaded
Open this post in threaded view
|

Re: Nearest point on line

Andrew McAninch-2
In reply to this post by Christoph Jung
You can do this in the field calculator with the refFunctions plugin.   It gives you a function, geomnearest(), which will return the WKT geometry of the nearest line(or geomdistance() if you want to limit your search radius).  Then use the closest_point() function to find the nearest point on that line.  something like:

closest_point(geom_from_wkt(geomdistance('lines','$geometry',10)) , $geometry)


Andrew



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, October 17, 2019 11:51 PM, Christoph Jung <[hidden email]> wrote:

> Hello list,
>
> Does QGIS has a function to calculate the nearest point on a line layer by a given point layer? In PostGIS i could query it with min(st_distance(...)) or st_closestpoint(...). But I miss such a function directly in QGIS (I just found the plugin Cloest Point, but it has some issues...).
>
> Sincerely,
> Christoph
>
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Nearest point on line

Christoph Jung
Thank you all for your answers. I played a bit with the nnjoins plugin, but Andrews‘ answer is exactly what I was looking for :)

Sincerely,
Christoph

> Am 18.10.2019 um 20:50 schrieb Andrew McAninch <[hidden email]>:
>
> You can do this in the field calculator with the refFunctions plugin.   It gives you a function, geomnearest(), which will return the WKT geometry of the nearest line(or geomdistance() if you want to limit your search radius).  Then use the closest_point() function to find the nearest point on that line.  something like:
>
> closest_point(geom_from_wkt(geomdistance('lines','$geometry',10)) , $geometry)
>
>
> Andrew
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Thursday, October 17, 2019 11:51 PM, Christoph Jung <[hidden email]> wrote:
>>
>> Hello list,
>>
>> Does QGIS has a function to calculate the nearest point on a line layer by a given point layer? In PostGIS i could query it with min(st_distance(...)) or st_closestpoint(...). But I miss such a function directly in QGIS (I just found the plugin Cloest Point, but it has some issues...).
>>
>> Sincerely,
>> Christoph
>>
>> Qgis-user mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Nearest point on line

Falk Huettmann
Hi there, Christoph,

generally speaking: I have another perspective about it and would approach your problem it in a different way:

Instead of pre-defined cut-offs (which are circular reasoning and are often surprising when checked in real world and GIS)
I would simply run a 'proximity to' points vs line first. And then in the resulting proximity table set a cut-off, select accordingly and see whether
this achieves the outcome wanted.

For pre-defined cut-offs, we call it usually 'geographic racism'. 
Instead, we try to celebrate the gradient theory; when tested it often works better in real life.
Worth a test.

Just an alternative thought to the problem at hand. 

Thanks, best
     Falk Huettmann











On Tue, Oct 22, 2019 at 3:26 AM Christoph Jung <[hidden email]> wrote:
Thank you all for your answers. I played a bit with the nnjoins plugin, but Andrews‘ answer is exactly what I was looking for :)

Sincerely,
Christoph

> Am 18.10.2019 um 20:50 schrieb Andrew McAninch <[hidden email]>:
>
> You can do this in the field calculator with the refFunctions plugin.   It gives you a function, geomnearest(), which will return the WKT geometry of the nearest line(or geomdistance() if you want to limit your search radius).  Then use the closest_point() function to find the nearest point on that line.  something like:
>
> closest_point(geom_from_wkt(geomdistance('lines','$geometry',10)) , $geometry)
>
>
> Andrew
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Thursday, October 17, 2019 11:51 PM, Christoph Jung <[hidden email]> wrote:
>>
>> Hello list,
>>
>> Does QGIS has a function to calculate the nearest point on a line layer by a given point layer? In PostGIS i could query it with min(st_distance(...)) or st_closestpoint(...). But I miss such a function directly in QGIS (I just found the plugin Cloest Point, but it has some issues...).
>>
>> Sincerely,
>> Christoph
>>
>> Qgis-user mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Nearest point on line

blammo
All,

Just some additional info/thoughts, I tried doing this a bunch of different times over the years, and the best method I’ve come up with for this type of processing is to dump into postgres/postgis and do everything via SQL.  I actually needed to be able to dynamically run a stepped analysis with varied cut-off distances to a line, and this worked out very well, and was easy to reuse for other projects over time, since all the functionality ended up being stored as a View into the souce DB table data.

bobb



On Oct 22, 2019, at 11:35 AM, Falk Huettmann <[hidden email]> wrote:

Think Before You Click: This email originated outside our organization.


Hi there, Christoph,

generally speaking: I have another perspective about it and would approach your problem it in a different way:

Instead of pre-defined cut-offs (which are circular reasoning and are often surprising when checked in real world and GIS)
I would simply run a 'proximity to' points vs line first. And then in the resulting proximity table set a cut-off, select accordingly and see whether
this achieves the outcome wanted.

For pre-defined cut-offs, we call it usually 'geographic racism'. 
Instead, we try to celebrate the gradient theory; when tested it often works better in real life.
Worth a test.

Just an alternative thought to the problem at hand. 

Thanks, best
     Falk Huettmann











On Tue, Oct 22, 2019 at 3:26 AM Christoph Jung <[hidden email]> wrote:
Thank you all for your answers. I played a bit with the nnjoins plugin, but Andrews‘ answer is exactly what I was looking for :)

Sincerely,
Christoph 

> Am 18.10.2019 um 20:50 schrieb Andrew McAninch <[hidden email]>:
> 
> You can do this in the field calculator with the refFunctions plugin.   It gives you a function, geomnearest(), which will return the WKT geometry of the nearest line(or geomdistance() if you want to limit your search radius).  Then use the closest_point() function to find the nearest point on that line.  something like:
> 
> closest_point(geom_from_wkt(geomdistance('lines','$geometry',10)) , $geometry)
> 
> 
> Andrew
> 
> 
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Thursday, October 17, 2019 11:51 PM, Christoph Jung <[hidden email]> wrote:
>> 
>> Hello list,
>> 
>> Does QGIS has a function to calculate the nearest point on a line layer by a given point layer? In PostGIS i could query it with min(st_distance(...)) or st_closestpoint(...). But I miss such a function directly in QGIS (I just found the plugin Cloest Point, but it has some issues...).
>> 
>> Sincerely,
>> Christoph
>> 
>> Qgis-user mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> 
> 
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user