Author Topic: Reducing the XYZ-points (of a DEM/DTM)  (Read 3073 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 650
Reducing the XYZ-points (of a DEM/DTM)
« on: December 11, 2020, 04:00:37 AM »
I have a lot of XYZ points which are the base of a DEM/DTM. Sometimes there are too many points so they should be reduced.

So I'm seeking for ideas / algorithms / solutions relating ..

- what to reduce? Better the points from raw data then the points from DTM - but is it possible (without TIN)?
- how to reduce? There are some ways to calculate - min, max, average, max. differences in height or slope or ..
- existing solutions? The best way - "take solution XY from here, it's great and it's free" ;-)

(I know the "lastools", but the pricing is not that funny ..)
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

d2010

  • Bull Frog
  • Posts: 326
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #1 on: December 11, 2020, 05:23:38 AM »
You must interpolate the Coordinate~s.
You re-mix all Coordinates with  Spline'Engine math.
 :brow:
« Last Edit: December 12, 2020, 05:19:30 AM by d2010 »

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #2 on: December 12, 2020, 04:03:50 AM »
There is no easy way other than like delete every 2nd point. But a Las file at 200MB is hard to handle, do you have access to Recap I think it does it.
A man who never made a mistake never made anything

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #3 on: December 12, 2020, 11:16:12 AM »
Although it's terribly slow, maybe it could help at least a bit... But I think that BCAD TIN command would create triangles faster then this routine would delete points... Still if you are confused with amount of points and you want to remove some, this untested snippet may work after all :

Code - Auto/Visual Lisp: [Select]
  1. (defun c:reduceptsamount ( / mindist-eea-MR adoc ss n dd ti i pl l pp )
  2.  
  3.  
  4.   (defun mindist-eea-MR ( l / f d q )
  5.  
  6.     (defun f ( p l / di )
  7.       (while l
  8.         (if (equal p (car l) (+ d 1e-8))
  9.           (cond ( (= (setq di (distance p (car l))) d) (setq q (list p (car l))) )
  10.                 ( (< di d)
  11.                   (setq d di
  12.                         q (list p (car l))
  13.                   )
  14.                 )
  15.           )
  16.         )
  17.         (setq l (cdr l))
  18.       )
  19.     )
  20.  
  21.     (setq d (distance (car l) (cadr l)))
  22.     (foreach a l
  23.       (f a (cdr l))
  24.       (setq l (cdr l))
  25.     )
  26.     q
  27.   )
  28.  
  29.   (prompt "\nSelect points on unlocked layer(s)...")
  30.   (if (setq ss (ssget "_:L" '((0 . "POINT"))))
  31.     (progn
  32.       (initget 6)
  33.       (setq n (getint "\nSpecify amount of points to be left after - for only fuzz distance checking use 0 <0> : "))
  34.       (if (null n)
  35.         (setq n 0)
  36.       )
  37.       (initget 7)
  38.       (setq dd (getdist "\nPick or specify fuzz distance for reducing points : "))
  39.       (setq ti (car (_vl-times)))
  40.       (if (< (sslength ss) n)
  41.         (progn
  42.           (prompt "\nSelected number of points smaller then amount you specified... Quitting...")
  43.           (exit)
  44.         )
  45.         (progn
  46.           (repeat (setq i (sslength ss))
  47.             (setq pl (cons (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) pl))
  48.           )
  49.           (setq l t)
  50.           (while (and l (> (length pl) n))
  51.             (setq pp (mindist-eea-MR pl))
  52.             (if (and pp (< (distance (car pp) (cadr pp)) dd))
  53.               (setq pl (vl-remove (car pp) pl))
  54.               (setq l nil)
  55.             )
  56.           )
  57.           (repeat (setq i (sslength ss))
  58.             (if (not (vl-position (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) pl))
  59.               (entdel (ssname ss i))
  60.             )
  61.           )
  62.         )
  63.       )
  64.       (prompt "\nElapsed time : ") (princ (rtos (- (car (_vl-times)) ti) 2 20)) (prompt " milliseconds...")
  65.     )
  66.   )
  67.   (vla-endundomark adoc)
  68.   (princ)
  69. )
  70.  
« Last Edit: December 13, 2020, 11:54:09 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Peter2

  • Swamp Rat
  • Posts: 650
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #4 on: December 13, 2020, 11:48:52 AM »
You must interpolate the Coordinate~s.
You re-mix all Coordinates with  Spline'Engine math.
 :brow:
What? Where? How?
Please add more details ..

There is no easy way other than like delete every 2nd point. But a Las file at 200MB is hard to handle, do you have access to Recap I think it does it.
It seem that "Recap Simple" is not available any more - on Autodesk page I found only "ReCap Pro Test". I have to look at older software packages - or do you know another original source?

Although it's terribly slow, maybe it could help at least a bit... But I think that BCAD TIN command would create triangles faster then this routine would delete points... Still if you are confused with amount of points and you want to remove some, this untested snippet may work after all :
- You mean Bricscad (Pro?) has a TIN command? Or do you mean another software?
- Which idea is behind your code? "Remove the nearest one" or something else?
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #5 on: December 13, 2020, 12:02:17 PM »
Although it's terribly slow, maybe it could help at least a bit... But I think that BCAD TIN command would create triangles faster then this routine would delete points... Still if you are confused with amount of points and you want to remove some, this untested snippet may work after all :
- You mean Bricscad (Pro?) has a TIN command? Or do you mean another software?
- Which idea is behind your code? "Remove the nearest one" or something else?

- Yes, BricsCAD V20 has TIN command...
- Idea behind my code is to remove point that forms shortest line between other point from point list... Now I've updated my code not to search for smallest lines and remove all until desired amount of point is reached, but to search also for length of line and if it falls smaller than specified fuzz distance then remove point - if smallest line length that follows is bigger than fuzz distance then routine terminates and if amount of points specified is less than remaining points in list routine terminates leaving points that can't form line smaller than fuzz, if otherwise specified amount of point is reached first and there still exist points with smaller line length, routine also terminates leaving specified amount of points not removed...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

d2010

  • Bull Frog
  • Posts: 326
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #6 on: December 13, 2020, 12:41:54 PM »
Quote
You re-mix all Coordinates with  Spline'Engine math.
 :brow:
What? Where? How?
You make  user account of the forum
https://youtu.be/7FFyfOkl5Oc?t=415
« Last Edit: December 13, 2020, 12:55:13 PM by d2010 »

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #7 on: December 13, 2020, 02:24:27 PM »
Just slightly faster, but every improvement is welcome...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:reduceptsamount-new ( / mindist-eea-MR-mod adoc ss n dd ti i pl l pp )
  2.  
  3.  
  4.   (defun mindist-eea-MR-mod ( l dd / f d q ll )
  5.  
  6.     (defun f ( p l dd / q )
  7.       (vl-some (function (lambda ( x ) (if (equal p x dd) (if (< (distance p x) dd) (setq q (list p x)))))) l)
  8.       q
  9.     )
  10.  
  11.     (setq d (distance (car l) (cadr l)))
  12.     (if (< d dd)
  13.       (setq q (list (car l) (cadr l)))
  14.       (while (and l (null (vl-some (function (lambda ( a ) (if (null ll) (setq ll l)) (setq q (f a (setq ll (cdr ll)) dd)))) l)))
  15.         (setq l (cdr l) ll nil)
  16.       )
  17.     )
  18.     q
  19.   )
  20.  
  21.   (prompt "\nSelect points on unlocked layer(s)...")
  22.   (if (setq ss (ssget "_:L" '((0 . "POINT"))))
  23.     (progn
  24.       (initget 6)
  25.       (setq n (getint "\nSpecify amount of points to be left after - for only fuzz distance checking use 0 <0> : "))
  26.       (if (null n)
  27.         (setq n 0)
  28.       )
  29.       (initget 7)
  30.       (setq dd (getdist "\nPick or specify fuzz distance for reducing points : "))
  31.       (setq ti (car (_vl-times)))
  32.       (if (< (sslength ss) n)
  33.         (progn
  34.           (prompt "\nSelected number of points smaller then amount you specified... Quitting...")
  35.           (exit)
  36.         )
  37.         (progn
  38.           (repeat (setq i (sslength ss))
  39.             (setq pl (cons (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) pl))
  40.           )
  41.           (setq l t)
  42.           (while (and l (> (length pl) n))
  43.             (setq pp (mindist-eea-MR-mod pl dd))
  44.             (if pp
  45.               (setq pl (vl-remove (car pp) pl))
  46.               (setq l nil)
  47.             )
  48.           )
  49.           (repeat (setq i (sslength ss))
  50.             (if (not (vl-position (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) pl))
  51.               (entdel (ssname ss i))
  52.             )
  53.           )
  54.         )
  55.       )
  56.       (prompt "\nElapsed time : ") (princ (rtos (- (car (_vl-times)) ti) 2 20)) (prompt " milliseconds...")
  57.     )
  58.   )
  59.   (vla-endundomark adoc)
  60.   (princ)
  61. )
  62.  

HTH.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Peter2

  • Swamp Rat
  • Posts: 650
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #8 on: December 14, 2020, 03:42:27 AM »
- Yes, BricsCAD V20 has TIN command...
I see - but only for Platinum, Mech and BIM licences ...

For the tools:
Thanks to both, but at the moment I have to finish other stuffs. So it will take time to test and to answer.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

lamarn

  • Swamp Rat
  • Posts: 636
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #9 on: January 02, 2021, 04:55:31 PM »
It runs in Pro as well. not in Lite (2D) and Shape (Free)
https://help.bricsys.com/hc/en-us/articles/360011845493-Tin
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Peter2

  • Swamp Rat
  • Posts: 650
Re: Reducing the XYZ-points (of a DEM/DTM)
« Reply #10 on: January 03, 2021, 07:16:55 AM »
It runs in Pro as well. not in Lite (2D) and Shape (Free)
https://help.bricsys.com/hc/en-us/articles/360011845493-Tin
Thanks, a colleague already started testing.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23