Pages

Monday, January 21, 2019

Shifting web imagery with world files for HEC-RAS


Written by Krey Price  |  Surface Water Solutions
Copyright © The RAS Solution 2019.  All rights reserved. 

Using RAS Mapper as a GIS tool Part 2:
Shifting Web Imagery with World Files



Have you ever tried pulling web imagery into RAS Mapper only to find that it doesn't line up with your existing shape files, terrain surfaces, or other geospatial data?  In this second of a three-part series on using RAS Mapper as a GIS tool we'll cover the modification of world files for georeferencing.

Photo by Franck V. on Unsplash

In some cases, the misalignment of web imagery may result from an incorrectly applied projection file. If needed, projection files can be downloaded for free from spatialreference.org and other online data sources. You can check the projection of your terrain file by double-clicking on it in RAS Mapper, then select the "Source Files" tab and view the metadata using the Info column. 



If you have confirmed that the correct projection file is being used and you are still having issues, there are a few additional workarounds you may wish to try. One option is to select the "Alternate HEC-RAS Raster Warping Method" under "Tools | Options" in RAS Mapper. This method applies the gDAL OGR vector reprojection. I have found this method useful for resolving discrepancies in European data sets in particular.





In some cases, the alternate method doesn't do the trick either. RAS Mapper uses the ESRI projection file format, which as I understand it does not recognize TOWGS84 parameters and in some cases improperly applies the proj.4 projection parameters. In any case, you may find yourself stuck with misaligned web imagery.


One workaround is to save static images of your web imagery and then shift the image to the correct location by making adjustments to the world file (Wikipedia has a good summary of the six lines of code comprising a world file here).


Here's a video walk-through of the process:


https://youtu.be/5REWQ8Z_08I


The "World File Calculator" spreadsheet referenced in the video can be downloaded here:


http://www.surfacewater.biz/wp-content/uploads/2018/12/Surface-Water-Solutions-World-File-Calculator.xlsx


Here are the steps covered in the video:


1. Adjust transparency as needed so that you can see a known point in both the web imagery and in the survey or LiDAR data.
2. Using the measure tool in RAS Mapper, click on a known point from the web imagery (with incorrect location), then double-click on the the same known point based on the correct location.
3. Select "Copy coordinates to clipboard".
4. Zoom to preferred extents for results and save view (click here for further details on saved views and static imagery).
5. Right-click on web imagery and select "export layer". Note: RAS Mapper currently has two export options: tif and jpg. The tif format will embed the metadata and georeferencing information into the encoded text of a geotif file without generating a separate world file. A tfw file can still be created to override the embedded georeferencing, but I suggest using the jpg format so that the world file is automatically generated. Save the image (I suggest creating an "aerial imagery" subfolder within the current project's directory structure to store static images).
6. Open the world file calculator spreadsheet.
7. Paste the coordinates from RAS Mapper into the blue cell.
8. Open the newly created jgw file (jpg format world file) in a text editor and copy the values.
9. Paste the values into the "Original World File" column of the spreadsheet.
10. Copy the "New World File" values over the original values in the jgw file, save, and close.  
11. Under Map Layers in RAS Mapper, right-click and select "Add Existing Layer". Be sure to drag down file types to show all image files and browse to the newly created file.
12. Adjust transparency as needed to confirm common points are now co-located.

The process can be repeated to fine-tune the positioning. Because a static image won't be pyramided like web imagery, you will unfortunately need to complete these steps at every desired zoom level and view extent, the but the process of saving static images allows you to control the appearance of your figures without having to worry about losing your internet connection while presenting or viewing results.


Note that these steps assume the units and north alignment are the same (or close enough) between the data sets and that the static image can be simply shifted without scaling or rotation factors, which we'll cover in more detail in our next post.
Please let us know any feedback or suggestions for improvements or additional efficiencies in adjusting web imagery.


1 comment:

  1. Hi Krey,

    I'm from Germany and i have the following issue with a projection.
    I have a project in the coordinate system 'DHDN 3-Degree Gauss Zone 4' (EPSG: 31468). Using the Default Raster Warping Method, the RAS Mapper show an offset of about 180m between the vector data an the web imagery. When using the Alternate HEC-RAS Raster Warping Method it fits perfectly. However, the alternate method does not work in the geometric data window. Here the default method is still used an the shift appears again.
    Is the problem known and is there a solution? Is it possible to set the alternative method as default?

    A conversion of the horizontal coordinate system (in ETRS 89) with HECRAS did not solve the problem.

    Any Idea? Thanks, Mathias

    ReplyDelete

Note: Only a member of this blog may post a comment.