Jump to content

Insert georeferenced image with world file in AutoCAD LT


Recommended Posts

Posted

Hello,

 

 

I want to insert aerial photos that have world files (.JPG with the .JGW world file for example) in AutoCAD LT.

 

 

I'm hoping you can help me! I understand there are tools that can help do the above in the full version of AutoCAD (although it's not a built in feature). But is this possible in LT version? LT is perfect for my needs, except for this!

 

 

Thanks,

 

Alex

Posted

If lt is not able to load any thith party addons the only thing i can think of is to insert & align images manually... (?) What i, these days, do is export dwg to shp files and load this in google streetview kind of software. Is LT software able to export or import (pictures or gis)?

Posted

The jgw has the answers here is a lisp version of pick an image and rescale an relocate you should be able to say do a excel of the same thing and copy and paste the insertraster to the command line.

 

;;;Reads world tiff file (.jgw) to scale and place image correctly in autocad.
;;;First insert all tiff images into drawing at whatever scale and insertion point.
;;;If the jgw exists in same directory and is named the same as the image selected,
;;;it will automatically be found and the image will be scaled and placed. If it is
;;;not in the same directory, the user can browse for the file.
;;;03.23.2011 Added support to create jgw files as well as support rotated images 
;;;Needs a file with 6 lines (ScaleX Rotation -Rotation -ScaleY TopLeftXCoord TopLeftYCoord)
;  « Last Edit: April 12, 2011, 09:43:43 am by ronjonp »  

(vl-load-com)
 (defun ss->lst (ss / e n out)
   (setq n -1)
   (while (setq e (ssname ss (setq n (1+ n)))) (setq out (cons (vlax-ename->vla-object e) out)))
 )
 (defun _writefile (filename lst / file result)
   (cond ((and (eq 'str (type filename)) (setq file (open filename "w")))
   (foreach x lst
     (write-line
       (cond ((= (type x) 'str) x)
	     ((= (type x) 'int) (itoa x))
	     ((= (type x) 'real) (rtos x 2 6))
	     ((vl-prin1-to-string x))
       )
       file
     )
   )
   (close file)
   filename
  )
   )
 )
 (defun _readfile (filename / file result)
   (cond
     ((and (eq 'str (type filename)) (setq file (open filename "r")))
      (while (setq line (read-line file)) (setq result (cons (vl-string-trim " " line) result)))
      (close file)
      (reverse result)
     )
   )
 )
 (setq opt "ReadIt")
;  (initget 0 "ReadIt WriteIt")
;  (setq	opt (cond ((getkword (strcat "\nImage World File [ReadIt/WriteIt] <" opt ">: ")))
;		  (opt)
;	    )
; )
 (princ "\nSelect image(s): ")
 (setq pre (getvar 'dwgprefix))
 (if (and (setq ss (ssget '((0 . "image")))) (setq ss (ss->lst ss)))
   (foreach image ss
     (setq name    (vlax-get image 'name)
    hgt	    (vlax-get image 'height)
    wdth    (vlax-get image 'width)
    imhgt   (vlax-get image 'imageheight)
    imwdth  (vlax-get image 'imagewidth)
    rot	    (vlax-get image 'rotation)
    bpt	    (vlax-get image 'origin)
    imgpath (vl-filename-directory (vlax-get image 'imagefile))
    jgw	    (strcat imgpath "\\" name ".jgw")
     )
     (if (= opt "ReadIt")
(progn
  (if (and (or (setq jgw (findfile (strcat pre name ".jgw")))
	       (setq jgw (findfile (strcat imgpath "\\" name ".jgw")))
	       (setq jgw (getfiled (strcat "***Select <<" name ".jgw>>***") pre "jgw" 16))
	   )
	   (setq pre (strcat (vl-filename-directory jgw) "\\"))
	   (setq data (mapcar 'atof (_readfile jgw)))
	   (> (length data) 5)
	   (setq l1 (car data))
	   (setq mvpt (list (nth 4 data) (nth 5 data) 0.0))
      )
    (progn (vla-put-imageheight image (* hgt l1))
	   (vla-put-imagewidth image (* wdth l1))
	   (vla-put-rotation image (cadr data))
	   (setq rot (vlax-get image 'rotation))
	   (setq bpt (polar bpt (+ (/ pi 2.) rot) (* hgt l1)))
	   (vlax-invoke image 'move bpt mvpt)
	   (princ (strcat "\njgw File Read - " jgw))
    )
    (princ "\njgw file NOT found or not correctly formatted!")
  )
)
(progn (setq bpt (polar bpt (+ (/ pi 2.) rot) imhgt))
       (if (setq jgw (_writefile
		       (strcat imgpath "\\" name ".jgw")
		       (list (/ imhgt hgt)
			     rot
			     (strcat "-" (rtos (abs rot) 2 6))
			     (strcat "-" (rtos (abs (/ imwdth wdth)) 2 6))
			     (rtos (car bpt) 2 6)
			     (rtos (cadr bpt) 2 6)
		       )
		     )
	   )
	(print jgw)
	(princ "\nError writing file...")
       )
)
     )
   )
 )
 (princ)
;(command "layer" "n" "Image" "")
;(command "chprop" "L" "" "la" "IMAGE" "")
;(setq obj (entlast))
;(command "draworder" obj "" "B") 



;  « Last Edit: Dec 16 2011 send to back added by alan »

Posted

Have you tried the IMAGEATTACH command? LT can attach jpg, png, bmp and such, as a cross reference file. Not sure about jgw though. Once attached you can SCALE it to fit or to a specific scale factor.

 

Autocad LT does not do LISP.

Posted

Thank you for your replies. Unfortunately I don't think LT can work with GIS files, or lisps?

 

 

I do use the image attach command, and can manually align the photos. But I'd like to be able to fine a way of aligning them as per the world file.

 

 

I'm aware there are some third party add-ons which can help with the full version of AutoCAD, but not LT. Unless anyone is able to suggest one?

 

 

I'm beginning to wonder if I need to upgrade to the full version of AutoCAD, but it seems an expensive thing to do if this is the only extra thing I need from it.

Posted (edited)

do you buy or rent AutoCAD LT ?

BricsCAD could be an option

Lots of development going on there..

Edited by halam
  • Like 1
Posted

Thanks Halam.

 

 

I have an old perpetual liscence for LT, and also subscribe to get the new versions. But also I think I'm tied to it really, because of other reasons.

 

 

The supplier I get the aerial photos from have given me a guide to inserting them manually, which is a bit long winded but I think it will probably do me fine!

 

 

Here is a link in case it's helpful to anyone else: http://www.historicaerials.com/images/autocad_images.pdf

Posted

Hi all

 

 

I tested the tool called GeoRefimg.

Works really easy, which i would like to share

 

Sorry that this doen not for this LT discussion ....

 

GeoRefImg is a LISP utility for AutoCAD 2004, 2005, 2006,

2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017

(plus Architecture, Mechanical, MEP) which can automatically

reposition raster images used in a drawing to the position defined

in the images' World files.

World files define geo-position and other parameters of a

raster image (TIF, CIT, JPG, JP2, PNG, GIF, BMP, ECW, SID...).

 

Load this utility with _APPLOAD or use the automatic installer

from Autodesk Exchange Apps.

Posted

The reason I posted about the JGW it holds all the magic have a look inside one. Its the real world co-ords plus scale factor there is only 6 variables in the file so could be put into excel. I have never bothered to actually work out what the lisp I posted does, I just use it. Once you know how a jgw works then in LT it would be insert at x,y and use scale factor Z. I don't have one on this pc or would have posted comparing the image values.

 

All this info is available from the "properties" of an image

 

I will try to do a excel/manual version and post.

 

(setq name    (vlax-get image 'name)
    hgt	    (vlax-get image 'height)
    wdth    (vlax-get image 'width)
    imhgt   (vlax-get image 'imageheight)
    imwdth  (vlax-get image 'imagewidth)
    rot	    (vlax-get image 'rotation)
    bpt	    (vlax-get image 'origin)
    imgpath (vl-filename-directory (vlax-get image 'imagefile))
    jgw	    (strcat imgpath "\\" name ".jgw")
     )

Posted

Here is a jgw example look at the lisp code above and you should be able to do the same manually or using excel.

 

1.257783054623

0.0

0.0

-1.257783054623

268778.678341288800

5767942.202623139000

 

Once matching image is inserted the top left corner matches the co-ordinates

  • 3 years later...
Posted

I'm a bit late to this thread but hoping someone can help me. I've got the same query as the OP. I have successfully brought a GEOTiff into AutoCAD Map 3D using the 'insert image' tool under the 'Map Drafting' tab. However I primarily use AutoCAD LT and only need this one tool for my new workflow. I cant afford the extra £1,500 for this one tool it just doesn't make sense. Finding this thread gave me some hope that I could just open the .TFW file and manually perform the commands on the .TIFF image to position and scale it correctly. I wont have to do this very often. So my question is how to make sense of the scale data....

 

.TFW Data:

0.24569252795201821                      
0
0
-0.24569252795201821
452894.09198662388371304
522928.99285373603925109

 

My understanding from this wiki is that QGIS has given me the most straight forward of world formats where the second and third values are both zero (i.e. no rotation of the image file). All that needs doing is positioning the top left image with the last two coordinate values of the TFW and then scaling...... but just cant figure out the scale values or how the coordinates relate to my autocad coordinates???? @BIGAL is this something you understand?

 

Posted

ok figured it out, my file units were in inches which was totally throwing me. If anyone else has this issue, here is the solution:

 

  • Ideally you would use AutoCAD Map 3D to correctly position a geo image.
    (Map Drafting Tab > Insert Image > select image [ensure world file .TFW etc is in the same directory as image])
  • If you don't have AutoCAD Map 3D you can use AutoCAD and download the GeoRefImg widget/add-on 
  • If like me it doesn't make sense to purchase AutoCAD Map 3D or autocad just for this function then you can do it manually. If your source software has given you a true north image and doesn't require any rotation then its quite straight forward:
  1.  open your world file in notepad (should look like something in the previous post). Check lines 2 & 3 are both zero i.e. no rotation.
  2. lines 5 & 6 are the x & y coordinates of the top left of the image. 
  3. check the pixel dimensions of the image file (in windows right click on the file and go to properties)
  4. multiply the x pixel dimension by the value of the first line of the world file. Add this resultant value to the fifth line of the world file and this will give you the coordinate of the top right corner of the image.
  5. repeat for y value. 
  6. scale image to match these coordinates.
Posted

Hi Mikey,

 

I've been using the attached PDF guide, which was made by my supplier. It only works if the world files are in the right format (it looks like yours are). Following this guide seems to be spot on when I compare it against OS mastermap data. It's a bit laborious but having done it many times now it probably takes me about 10m to do.

 

Alex

Guide to inserting georeferenced images.pdf

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...