Ad-free. Non-profit. Pure love.

Friday, January 29, 2010

How to put a background image from AutoCAD into HEC-RAS

You can use a background image from AutoCAD as a world coordinate background for HEC-RAS. To do it, you print to an image from AutoCAD, create a coordinate World File, and Add the Background Picture in HEC-RAS. This is a follow-up to How to put a background from AutoCAD into SWMMM or EPANET. Where that post showed how to import a vector file, this one shows how to import an image (raster) file.

PRINT FROM AUTOCAD



  1. Decide on the desired background view extents in model space (the Model tab). For simplicity, choose even tens or hundreds for your corner coordinates. Note the corner coordinates of that view.

  2. In a Layout tab, create an mview with the corner coordinates from step 1. Zoom it in model space to the same coordinates, which puts the zoom factor of the viewport at 1

  3. Decide how many world units you want to print onto each image pixel. For simplicity, you probably will want to choose an even number and keep in mind that about 70 pixels make 1 inch of normal quality on-screen viewing, 150 pixels per inch is suitable for newspaper quality printing, and 300 ppi for magazine quality printing. For example, your view corner coordinates are 628000(x), 856900(y) to 630600(x), 858800(y). By subtracting the x's and the y's, you calculate view size is 2600(x), 1900(y). If you printed 100 units on every pixel, you would get a 26 pixel by 19 pixel image, which would not have near the required resolution. If you printed 10 units per pixel, you would get a 260x190 image, which would look good on-screen only as a 4" image. If you printed 1 unit per pixel, you get a 2600x1900 image, which would plot on-screen as large as 36 inches. You decide to use that even though it is on the big size, since it seems not too much larger than modern screen pixel sizes.

  4. Open the AutoCAD print dialog and choose the (Publish To Web) JPG (best for photographs) printer (HEC-RAS can't currently use PNG (best for line drawings)). Select the Properties button next to the printer. Select Custom Paper Sizes and Add or Edit a size with your resulting image size from step 3. Example: 2600 width, 1900 height. Close the properties, saving to the PC3 file.

  5. Select the paper size (image size) you just created. Print a Window using the corner coordinates from step 1. Change or note the name and location of the plotted image file AutoCAD creates. Check the finished plot by viewing it outside AutoCAD from Windows Explorer.

CREATE A WORLD FILE


ESRI created the World File format to provide a way to reference image files to world coordinates. HEC-RAS uses that format.
To create a world file format, you need to know how to create and edit plain text files in Windows Explorer (the files and folders view of Windows). This is easiest if you use ALT+T (Tools menu) > Folder Options > View tab and uncheck the "Hide extensions for known file types" option.

  1. Use File > New or Right-click New to create a new Text Document file in the same folder with the background image file you plotted from AutoCAD.

  2. Open the New Text Document.txt and type into it on line 1 the width of a pixel in world units, on line two 0 rotation, on line 3 0 rotation, on line 4 the NEGATIVE height of a pixel in world units, on line 5 the x-coordinate of the center of upper left pixel, and on line 6 the y-coordinate of the center of upper left pixel. Don't forget to calculate the CENTER coordinates of the upper left pixel. Our example file is given below this list. Save and exit the file.

  3. Change the world file name to match the name of the background image file, but with the extension changed to these three characters: the same first letter, the same last letter, and a "w". For example, map.jpg uses map.jgw, map.tif uses map.tfw, and map.png uses map.pgw.


Example world file:
1
0
0
-1
628000.5
858799.5

ADD BACKGROUND PICTURE


In the HEC-RAS Geometric Data window, follow this procedure from the HEC-RAS help file: Open the Geometric Data editor and create a New Geometry File. Add the background data by clicking on the Add Background Data button. If the image does not come in correctly, select the View, Set Schematic Plot Extents menu item and press the Set to Computed Plot Extents button in the Geometry Extents window. This will zoom out the bounds of the image.

If you have any trouble, just leave a comment below.

5 comments:

Noble said...

It worked just well. Thanks for the help...i've been struggling to find a solution to this problem for over 3days

Anonymous said...

thank you so much for your help..i've been struggling to do this for over a week.

Guillermo Velázquez said...

Thank u, man! U really help me with this blog!

Thomas Gail Haws said...

Heh. Yeah. It works! I just visited in need for help myself at least 4 years later. Hurrah!

Anonymous said...

That was easy! Thank you some much, Tom

Facebook Share