Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I said it's a Multi Linestring), The problem is that ST_Line_Locate_Point still returns the error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS pluginLRS plugin - seems not relevant for this use case.

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I said it's a Multi Linestring), The problem is that ST_Line_Locate_Point still returns the error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS plugin - seems not relevant for this use case.

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I said it's a Multi Linestring), The problem is that ST_Line_Locate_Point still returns the error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS plugin - seems not relevant for this use case.
added 7 characters in body
Source Link
John Powell
  • 13.7k
  • 5
  • 48
  • 62

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I toldsaid it's a Multi Linestring), The problem is that still ST_Line_Locate_Point still returns the error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS plugin - seems not relevant for this use case.

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I told it's Multi Linestring), The problem is that still ST_Line_Locate_Point returns error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS plugin - seems not relevant for this use case.

Input:

  1. Points layer points spread around some route
  2. Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type Multi Linestring using Qgis GUI Merge Lines tool (I haven't succeed to merge to single feature of type Linestring-this is important later on)

What I want to calculate:

Snap each point to the route with a length field indicating length distance along the route from the beginning of the route (and not beginning of the nearest route link etc.).

What I tried:

  1. Using PostGis I tried

    ST_Line_Locate_Point(ST_MakeLine(route.geom), points.geom)

I need ST_MakeLine to form single LineString (as I said it's a Multi Linestring), The problem is that ST_Line_Locate_Point still returns the error "first argument isn't Line", so I don't know whats going on here.

  1. Searched in all Qgis tool box for appropriate methods - haven't found one.
  2. Tried LRS plugin - seems not relevant for this use case.
Removed tag prefix from question title as per Jeff Atwood style preference
Link
underdark
  • 84.5k
  • 22
  • 233
  • 415

QGIS/Pyqgis/PostGis: Snap points to route and calculate relative length from start

Source Link
michael
  • 1.8k
  • 3
  • 21
  • 43
Loading