2

We have a lot of coordinates generated by GPS and UWB devices for different users in our system. For a given user for a certain time range, when we tried to display their history trace(the yellow points in the image) on the map, the trace looks ugly because of the precision of the location device.

enter image description here

Generally, we can create the road network(the green line in the image) and use something like "snap to road" to correct the points to the center of the "road".

enter image description here

However, I'd like to know if it is possible to implement that without the road network.

Also, the trace may cut the wall when the location frequency is low:

enter image description here

Any idea to interpolate some points to bypass the wall and make sure the interpolated points match the map?

Taras
  • 32,823
  • 4
  • 66
  • 137
giser
  • 953
  • 1
  • 11
  • 31
  • This in fact are two questions. To the first question: connect the points, then smooth/generalize the line, snap the points to the simplified line – Babel May 14 '23 at 11:43
  • Other idea: create a line grid, delete all line segments intersecting the buildings, then snap points to the grid – Babel May 14 '23 at 11:45
  • 1
    Without more details or sample data it's difficult to give a precise answer. – Babel May 14 '23 at 11:46
  • "connect the points, then smooth/generalize the line", the point is how to smooth the line. "Other idea: create a line grid" I am not sure what does the line grid mean, can you provide more? – giser May 15 '23 at 12:25
  • Posted three different solutions, hope at least one helps you. – Babel May 15 '23 at 16:11
  • 1
    What GIS software are you using? – BERA May 16 '23 at 08:47

3 Answers3

4

Identify the point exactly in the middle of the two building polygons: Find the two closest polygon to each point and get the point on these polygons closest to the initial point. Connect these two points with a line and get the ceontroid of the line.

Use Geometry by Expression with the following expression to create the points, then create the line with Points to Path:

with_variable(
    'point',
    array_foreach(
        overlay_nearest ('polygon_layer', $geometry, limit:=2),
        closest_point (@element, $geometry)
    ),
    centroid (make_line (@point[0],@point[1]))
)

Blue: initial points; yellow: closest points on the two nearest polygons; black dotted line: connection of the yellow points (see thick black line on the upper right: line does not necessarily go through the initial points), red points: centroid; red line: line connecting red points: enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208
3
  1. Create a regular polygon grid with cell distance a bit smaller than the distance between the buildings (see screenshot).
  2. Check for each point within which cell it is and snap the point to the cell's centroid. Use Geometry by Expression with this expression: centroid(overlay_within('Grid',$geometry)[0])
  3. Connect the snapped points with Points to path and here your are:

Red: buildings; black: polygon grid; blue: initial points; yellow: points snapped to the cell's centroid; red line: connecting yellow points: enter image description here

Option: before step 2, you could delete all grid cells that intersect the buildings. Use select by expression with the expression overlay_intersects ('building_layer') and delete the selected cells:

enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208
  • How about interpolating points to bypass the building? – giser May 16 '23 at 11:33
  • Interpolating will not help you avoiding the buildings. If a line from one point to the next one passes through the building, each point in between will just reproduce this behaviour. – Babel May 16 '23 at 13:27
1

Connect the points, e.g. using points to path. Then simplify (generalize) the line, either using

A. Menu Processing > Toolbox > Simplify or

B. QGIS expressions with the function simplify() with Geometry by Expression (for actual geometries) or Geometry Generator (for visualization only). See here for details about both options. The expression to use: simplify( $geometry,100) - you can adapt the value of 100 to get different results.

Option B with Geometry generator variant: blue points connected to a path (black dottel line), simplified line in red:

enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208