Thursday, October 13, 2016

Some differences when opening georeferenced imagery between QGIS and ArcGIS

Just did some minor testing after trying the Georeferencing toolbar in ArcGIS to create some world files (.jpgw, .pngw, .ecww, .tfw, etc.) and wanted to see how these two GIS suites treat the result. Normally I use MapWindow GIS to georeference aerial photos but its Image to Map Image Registration Plug-in is very slow and has some strange bugs that might deserve another blog post.

The aerial photos were received from the provincial agency as MrSID files and were converted to ecw using IrfanView. Neither the original SID files or the ECW files had embedded projection information. In ArcGIS, I used the georeferencing toolbar and added five control points then chose Projective Transformation rather than the default Affine 1st Order Polynomial method to transform the raster. Upon clicking Update Georeferencing (Save the current warp to the dataset) from the toolbar, two files are created with the same name prefix as the .ecw file but with different extensions. They are photoname.ecw.aux.xml, and photoname.ewwx. The .ewwx file contains the image-to-world file transformation parameters using 1st Order Polynomial. The original ecw image file was untouched by this process.

I also made a copy of the photoname.ewwx file and renamed the extension to ecww so there was a file named photoname.ecww that QGIS and MapWindow can use.

It seems that although QGIS can read the ecw.aux.xml for the projection information (so it doesn't need a .prj file), it can not read this auxiliary file's contents for the higher order polynomial transformation. Thus there is a difference in the accuracy of the georeferenced raster when loaded, between ArcGIS and QGIS. In ArcGIS, if a more complex transform higher than 1st order polynomial was used to create the aux.xml and ewwx files, then it will show the raster with the higher order transformation method applied. If one decides to load the raster into QGIS, then QGIS will only use the world file (.ecww) and perform affine transformation on it.

Post addition:

From a little more experimentation with the QGIS Georeferencer tool plugin which has been available since at least v1.8, I've discovered that the linear transformation type in this plugin does not seem to do any rotation as the parameters B and D are always 0 and 0 in the world file generated. This is one of the reasons I use MapWindow GIS for georeferencing when I don't want my imagery resampled, though of course I don't get the benefits of warping that come with higher order polynomial transformations.

When I prefer warping or "rubber sheeting" of the imagery, then QGIS does a fine job, however it will only output to GeoTIFF files. So it might be useful to compress this file by converting it to a wavelet based format such as ECW (lossy) or JPEG2000 (lossless or lossy). The GDAL translate raster utility can be used but the ECW driver in QGIS is not compiled with creation capabilities. IrfanView could be used to convert file formats but the ER Mapper (ERDAS/Hexagon Geospatial) plugin has a size limitation of 500 MB maximum uncompressed image under the free use license. Even if you do go that route, you'd want to extract the world file parameters from the warped-transformed GeoTIFF using the -co WORLDFILE=YES creation option in the gdal_translate command.

So I attempted to convert my warped imagery to JPEG2000 and encountered a couple problems when running gdal_translate in QGIS and selecting save as type *.jp2 in the dialog boxes. It seems there is a bug when JP2 file type is selected: the output filename gets an extra .jp after the .jp2, which makes the command fail. If you delete the .jp then you get ERROR 1: JP2ECW driver has no creation capabilities. However, through the documentation, I learned that the output format is guessed from the extension, and another common extension for JPEG2000 is .j2k. The solution is to replace the extension at the end of the filename in the Converted textbox with ".j2k". You'll see that the -of parameter in the GDAL console call changes to JP2OpenJPEG when you do this. You can add the creation option QUALITY=value by using the + button once you expand the Advanced parameters by clicking the arrow.

blog comments powered by Disqus