Author Topic: Convert coordinate files to x,y  (Read 6154 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Convert coordinate files to x,y
« on: August 30, 2017, 04:15:27 AM »
hI. I am searching for a lisp to convert coordinate files files to x,y  (*.txt)

1) p,x,y,z --->x,y
2) p,x,y ---->x,y
3) p x y z ---> x,y
4) p x y ----> x,y


i know that i can do it with excel but i need something faster.

Thanks





pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #1 on: August 30, 2017, 05:41:52 AM »
any ideas ?

Pad

  • Bull Frog
  • Posts: 342
Re: Convert coordinate files to x,y
« Reply #2 on: August 30, 2017, 07:14:24 AM »
you could try this
http://www.lancaster.ac.uk/~steveb/cpaap/pfe/default.htm
and make yourself a macro for each variation.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Re: Convert coordinate files to x,y
« Reply #3 on: August 30, 2017, 08:04:44 AM »
TheSwamp.org  (serving the CAD community since 2003)

pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #4 on: August 30, 2017, 10:22:22 AM »
i can not understand it can you give me an example for    p x y ----> x,y  ?

thanks

pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #5 on: August 30, 2017, 11:10:41 AM »
i am thinking something like this

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ )
  2.              
  3.   (setq title "select file"
  4.         fname (getfiled title path "txt" 0)
  5.         path  (if (setq tmp (vl-filename-directory fname))
  6.                 (strcat tmp "\\")
  7.                 ""
  8.               )
  9.   (setq f (open (strcat path
  10.                         ""
  11.                         (vl-filename-base fname)
  12.                         ".pl"
  13.                 )
  14.                 "w"
  15.           )
  16.  
  17.     (write-line (strcat (rtos (cadr i) 2 3)    
  18.                         ","
  19.                          (rtos (caddr i) 2 3)    
  20.  
  21.  
  22.                 )
  23.                 f
  24.     )
  25.   )
  26. )
  27.  )
  28.  
  29.  

but is not working. Any ideas?

Thanks

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Convert coordinate files to x,y
« Reply #6 on: August 30, 2017, 11:16:27 AM »
can you post a sample of the  " coordinate files files"  to x,y you are starting with?
And what you want them to look like when done?

It might be possible to use QGIS or similar to do this.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Re: Convert coordinate files to x,y
« Reply #7 on: August 30, 2017, 11:24:27 AM »
i can not understand it can you give me an example for    p x y ----> x,y  ?
something like this
Code: [Select]
gawk "{print $2 $3 }" input-file.txt > output-file.txt
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Re: Convert coordinate files to x,y
« Reply #8 on: August 30, 2017, 11:38:13 AM »
i can not understand it can you give me an example for    p x y ----> x,y  ?
It would actually be ...

Code: [Select]
gawk "{print $2\",\" $3 }" data.txt > outputfile.txt
Its all in that link i posted earlier.
TheSwamp.org  (serving the CAD community since 2003)

fools

  • Newt
  • Posts: 72
  • China
Re: Convert coordinate files to x,y
« Reply #9 on: August 30, 2017, 11:39:34 AM »
i can not understand it can you give me an example for    p x y ----> x,y  ?

thanks

Code - Auto/Visual Lisp: [Select]
  1. (DEFUN c:test (/ FF FFN TXT TXTS)
  2.   (SETQ ffn  (GETFILED "Select file" "" "txt" 0)
  3.         ff   (OPEN ffn "r")
  4.         txts nil
  5.   )
  6.   (WHILE (SETQ txt (READ-LINE ff)) (SETQ txts (CONS txt txts)))
  7.   (CLOSE ff)
  8.   ;;(VL-FILE-RENAME ffn (STRCAT (SUBSTR ffn 1 (- (STRLEN ffn) 3)) "bak"))
  9.   (SETQ txts (MAPCAR 'CDR (MAPCAR 'F_Str2Lst (MAPCAR 'F_NoExtraSpaces (REVERSE txts)))))
  10.   (SETQ ff (OPEN (STRCAT (SUBSTR ffn 1 (- (STRLEN ffn) 3)) "pl") "w"))
  11.   (FOREACH item txts (WRITE-LINE (STRCAT (CAR item) "," (CADR item)) ff))
  12.   (CLOSE ff)
  13. )
  14.  
  15. (DEFUN F_NoExtraSpaces (str / pos)
  16.   (SETQ str (VL-STRING-TRIM " " str))
  17.   (WHILE (SETQ pos (VL-STRING-SEARCH "  " str pos)) (SETQ str (VL-STRING-SUBST " " "  " str pos)))
  18.   str
  19. )
  20.  
  21. (DEFUN F_Str2Lst (str / pos)
  22.   (IF (SETQ pos (VL-STRING-SEARCH " " str))
  23.     (CONS (SUBSTR str 1 pos) (F_Str2Lst (SUBSTR str (+ (STRLEN " ") pos 1))))
  24.     (LIST str)
  25.   )
  26. )
Good good study , day day up . Sorry about my Chinglish .

pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #10 on: August 30, 2017, 12:47:38 PM »
I attach a *.txt file with the coordinates.I try fools code but the *.pl file is empty

pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #11 on: August 30, 2017, 12:58:33 PM »
i want the export file to be like this

Quote
318349.74,4231547.73
318445.61,4231568.79
318446.37,4231561.59
318443.36,4231549.82
318438.82,4231539.87
318428.56,4231532.33
318425.25,4231523.57
318428.55,4231513.05
318442.57,4231516.64
318455.87,4231506.94
318473.12,4231495.81
318473.84,4231490.78
318468.81,4231486.11
318468.45,4231473.18
318464.85,4231451.63
318460.90,4231446.96
318447.24,4231446.60
318439.70,4231458.45
318431.79,4231475.34
318424.60,4231475.34
318399.26,4231473.08
318390.21,4231473.39
318382.97,4231477.91
318379.64,4231487.26
318376.02,4231521.35
318372.99,4231537.20
318368.15,4231541.13
318354.88,4231545.65
318349.74,4231547.73



thanks

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Re: Convert coordinate files to x,y
« Reply #12 on: August 30, 2017, 01:24:44 PM »
You're not even trying are you?

Code: [Select]
gawk "{print $2\",\" $3 }" 1.txt
318349.74,4231547.73
318445.61,4231568.79
318446.37,4231561.59
318443.36,4231549.82
318438.82,4231539.87
318428.56,4231532.33
318425.25,4231523.57
318428.55,4231513.05
318442.57,4231516.64
318455.87,4231506.94
318473.12,4231495.81
318473.84,4231490.78
318468.81,4231486.11
TheSwamp.org  (serving the CAD community since 2003)

pedroantonio

  • Guest
Re: Convert coordinate files to x,y
« Reply #13 on: August 30, 2017, 01:35:49 PM »
Mark i am not using scripts.I use only lisp codes

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Convert coordinate files to x,y
« Reply #14 on: August 30, 2017, 02:37:32 PM »
yes you could read that file into QGIS (its free GIS software)

new layer from delimited file...
have it read your desired columns from that file

then export it as comma delimited file or shp file...or lots of formats.

no list/code/ or scripts required
Be your Best


Michael Farrell
http://primeservicesglobal.com/