Sharing geotiff raster files

One of my favourite raster formats to share is the geotiff, mostly because I always thought it is one of the most portable formats. But yesterday I got an email from a colleague that the geotiffs I shared looked strange in ArcMap, with hardly any values to show and an apparent range of values of 1,79769e+308 to 2,22507e-308.

Strange, I exported the layer from GRASS GIS using r.out.gdal, and it looked fine in QGIS. So what was going on? The problem is actually described in the help file of r.out.gdal. As it turns out, ArcMap is converting the layers to a grayscale image and scaling the values to the full data range. The range is determined by the data type. For example, if the raster is of the integer type, ArcMap will scale the values to the full range of integer values (-32767 to 32767). For a double-precision floating-point raster (DCELL) the range is huge (1,79769e+308 and 2,22507e-308).

If you are working in ArcMap and you get such a geotiff, the solution is to use build Statistics. You can do this in ArcCatalog. Select the dataset, right click, and select Properties. Go down the list till you find the statistics property. There it will tell you statistics have not been build yet. Select ‘build statistics’ and accept the default values and hit OK. After that, you can open the data set in ArcMap and the correct values should be displayed.

QGIS creates the statistics automatically when opening the layer. And, very convenient if you want to share a geotif with others, it generates an ancillary aux.xml file when closing the layer. This layer contains the raster statistics, so next time you open the raster layer QGIS does not have to read the statistics from the raster (thus speeding up the process of opening the raster layer). If you share that file together with the raster layer, ArcMap should be able to read the minimum and maximum values from that xml file, so it will correctly display your values. In fact, ArcMap generates the same file when you run build statistics.

But, I will from now on avoid this problem altogether and simply export my layers as an ascii file :-/

About these ads

3 thoughts on “Sharing geotiff raster files

  1. Kay Warrie

    Also usefull in this regard: if you gdal_translate form the commandline, add the -stats option will create the statistics-file (.aux.xml) as well.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s