Code Red > AutoLISP (Vanilla / Visual)

Insert image GeoTiff

(1/4) > >>

FELIX:
How to get the coordinates of a TIF (Geotiff) file. These coordinates are defined within the same Tif file because AutoCAD C3D with the MAPIINSERT command gets this information.
With these coordinates it is easy to insert inside AutoCAD.

Attached is a georeferenced TIF file and a file with the values of its coordinates ob- tained in AutoCAD C3D.

VovKa:
the coordinates are stored as Exif data in 'Model Tie Point' key

FELIX:
Thanks Vovka but it does not help me anything because I need to first read the file and I do not know if I should do with Autolisp or if I should do with VB.NET

Rod:
This could be done with lisp (i think). My method uses the "Windows Image Aquisition" object so would only work with windows. You would also need to dig further into cracking open to Ivector Object.
The "Model tie point" is 33922 but again it is an Ivector object and you will need to work out how to extract the coordinates.
BTW 34737 is the coordinate system and 33550 is the pixel scale.

Here is the info I get

(("ImageWidth" . 1645)
("ImageHeight" . 4096)
("BitsPerSample" . #<VLA-OBJECT IVector 00000215fc6b81c0>)
("Compression" . 7)
("PhotometricInterp" . 2)
("SamplesPerPixel" . 3)
("PlanarConfig" . 1)
("TileWidth" . 256)
("TileLength" . 256)
("TileOffset" . #<VLA-OBJECT IVector 00000215fc6b8a10>)
("TileByteCounts" . #<VLA-OBJECT IVector 00000215fc6b8af0>)
("SampleFormat" . #<VLA-OBJECT IVector 00000215fc6b8d20>)
("347" . #<VLA-OBJECT IVector 00000215fc6b8ee0>)
("33550" . #<VLA-OBJECT IVector 00000215fc6b8c40>)
("33922" . #<VLA-OBJECT IVector 00000215fc6b8460>)
("34735" . #<VLA-OBJECT IVector 00000215fc6b8e00>)
("34736" . #<VLA-OBJECT IVector 00000215fc6b8150>)
("34737" . "SIRGAS-ROU98|SIRGAS-ROU98 / UTM zone 22S|"))


--- Code - Auto/Visual Lisp: ---(defun exifdata (file / idata)  ;;/ err idata iprop imgObj )  (if (and (setq file (findfile file))           (setq imgObj (vlax-create-object "WIA.Imagefile"))      ) ;_ end of and    (progn      (setq        err (vl-catch-all-apply              (function                (lambda nil                  (vlax-invoke-method imgObj 'loadfile file)                  (setq iprop (vlax-get-property imgObj 'properties))                  (princ "\nProperties")                ) ;_ end of lambda              ) ;_ end of function            ) ;_ end of vl-catch-all-apply      ) ;_ end of setq      (if (null (vl-catch-all-error-p err))        (progn          ;;(dumpall iprop)          (setq idata (getall iprop))          (princ "\nData")          ;;(dumpall idata)        ) ;_ end of progn      ) ;_ end of if ;_ end of if    ) ;_ end of progn  ) ;_ end of if(rel)idata) ;_ end of defun (defun getall (collection / err x valuelist name prop)  (vlax-for x collection    (setq name (vl-catch-all-apply '(lambda nil (vlax-get-property x 'name))))    (setq prop (vl-catch-all-apply '(lambda nil (vlax-variant-value (vlax-get-property x 'value)))))    (if (and (null (vl-catch-all-error-p name)) (null (vl-catch-all-error-p prop)))      (setq valuelist (cons (cons name prop) valuelist))    ) ;_ end of if    ;;(vlax-dump-object x T) ;_ end of setq  ) ;_ end of vlax-for  (if (listp valuelist)    ;;(null (vl-catch-all-error-p err))    (reverse valuelist)  ) ;_ end of if) ;_ end of defun(defun rel ()  (foreach obj (list iprop imgObj)    (if (= 'vla-object (type obj))      (vlax-release-object obj)    ) ;_ end of if  ) ;_ end of foreach)  

FELIX:
Excellent, I was able to generate the list.

I researched but could not find how to convert: "VLA-OBJECT IVector", can you inform me how?

Navigation

[0] Message Index

[#] Next page

Go to full version