# What is the best plain text format for georeferenced raster data?

I have to translate satellite images in a file in .txt format or another, such as Excel or .csv, in which there are pixel values corresponding to (longitude,latitude) couples. What is the best file format to store this (in terms of dimension and limits of the file because pixels number is in the order of 10^5)?

In your experience, is a matrix format representation better or a columns representation (one column is for longitude, one for latitude and one for value, so every row of the text corresponds to a pixel)?

• "Best" here is kind of funny, it's not a good way to do it at all. xyz is inefficient and has no metadata, ESRI Ascii is more efficient and many software apps actually know it's a grid and how to use it, but still it has no projection metadata or extra efficiency. Use something good like GeoTIFF. – mdsumner Oct 15 '13 at 21:17

There are a number of text formats to choose from. However, if it must be text based the ESRI ASCII grid format (.asc) may be a good choice because it dispenses with recording the X and Y (lon and lat) coordinates. It does this by assuming a regular grid whose dimensions are stored in the header. Only the raster value at the center or lower left corner (specified in the header) is recorded.

Depending on what the satellite images represent, you may also be able to convert to an integer format (saving space) perhaps through classification. If the images are more akin to aerial photographs, then that will probably not be an option but you can still consider limiting the number of decimal places if saving space is important. Though, if space it that important, I wouldn't use a text-based format.

The easy way to convert your satellite image data into text (under a matrix form) consists into using the Arc/Info ASCII Grid format. For instance, it's a very simple task using GDAL:

gdal_translate -of AAIGrid -ot Int16 input.tif output.asc


Consult the gdal_translate related page for further optimizations.

If you are also interested into calculating the coordinates of each pixels and want to avoid to code, I suggest you to read this question: Creating Latitude Grid from DEM (see the @whuber's answer).

Instead, if you like to code and know a bit of Python, you can write a Python script using the GDAL Python bindings which exports the three columns (lon, lat, value) in a CSV file.

Hope this helps.