What To Do With an ECW File (Convert It 😏)

 


A Note on ECW before I start

Because it's a proprietary  format, it has a very strict license, which means you can't create or publish it without buying the proper license, this post should help you with what to do when you don't have the license and don't want to do anything illegal (or complicated).

The Story, and what to do

A few days ago a friend asked me for help because she got a raster in with a .ecw extension and her ArcMap can't read it (she works at a local council and wouldn't be getting ArcPro soon).
First thing I asked, do you have QGIS installed? This isn't because you need all of QGIS for this, but it's an easy way to deploy GDAL with a GUI for users that dread using CLI tools.

The ECW raster format should be supported in ArcMap, but for some reason hers didn't recognize it as a raster format. I see this as an opportunity, both to help her use an open format, and get her to use QGIS to do that.

Changing the format for a raster layer is easy in QGIS, but it helps if you know what you're doing.
Now, I'm not an expert on raster data, but I get the basic concepts of a matrix of pixels that can have multiple bands. So whenever I need to convert a raster and keep it small and functional, I turn to the excellent post by Paul Ramsey "GeoTiff Compression for Dummies" which uses two simple GDAL commands to convert a 515MB raster to a 37MB (Yes, 7% of the original size!).

Now I could have told her how to define the PATH environment variable to include GDAL and how to type the commands, but I thought that having her load the raster into QGIS and simply export it a bit easier for someone that used QGIS once or twice (we took the same courses during our bachelor's).

So loading raster data into QGIS is as simple as can be, use the browser drag it (or double click it) to the canvas, you can also check out the basic import data guide on arc2qgis.

For this example I used an .ecw file I downloaded from Estonian open data, you might ask why Estonia, because they have an open .ecw file, the format isn't widely used for open data. You can access their open ortophotos here.




So you opened the file in QGIS, now what?

Simply right click the layer in the layers panel, Export and then Save As. In the new menu, we select where to save the new file, your default file format should be GeoTiff, I'm not gonna change anything in the Extent or Resolution parts of the new menu so they're already minimized, instead I enable Create Options where I'll specify all the parameters we read about in Paul's post. The Save As menu can be used basically as a UI for using the GDAL commands.



 

Now let's add Create Options and create a new GeoTiff from the original data. Before having to write them down ourselves, we can simply select the JPEG Compression profile option. This will set two creation options:

1. COMPRESS -> JPEG ( Wether to compress, and if so, which compression algorithm to use)

2. QUALITY -> 75 ( Set the JPEG quality when using JPEG compression. A value of 100 is best quality (least compression, bigger file), and 1 is worst quality (best compression, smaller file). The default is 75.)


 Now we'll add two more parameters with the green plus icon.

3. PHOTOMETRIC -> YCBCR (color, for even smaller size)

4. TILED -> YES (internal tiling, for fast access of random squares of data)



 

This will make our new compressed GeoTiff  small and fast.
We'll also add pyramids which are overviews, for fast access of zoomed out views of the data.

 


We can now save our GeoTiff, with all of these creation options, our new file should be around 164 MB which is barely larger then the original .ecw file which was 153 MB. Without the extra compression parameters, resaving our original .ecw file into tiff gets us a 1.8GB GeoTiff.


Now let's do a test, this is a picture of the original ecw in 1:500 scale.

and this is an image of the same location, at the same scale of the compressed YCBCR GeoTiff.




If you can't see a difference, that means it should be good enough for your purposes, if you can, you can redo the conversion with a higher quality and get a bigger GeoTiff, but with better resolution. The rule of thumb here is that 75% is usually good enough quality for JPEG compression so that the human eye won't be able to tell the difference.

Comments