[Gdal-dev] IPCC raster format
Norman Vine
nhv at cape.com
Sat Jun 17 05:07:53 EDT 2006
Frank Warmerdam writes:
> Ivan Lucena wrote:
> >
> > The “Intergovernmental Panel on Climate Change” (IPCC) offers data on
> > the web in a format described by this Fortran source code:
> >
> > http://ipcc-ddc.cru.uea.ac.uk/obs/observed_fileformat.html
> >
> >
> > - It’s an ASCII format;
> >
> > - There are two lines of reader (easy to read)
> >
> > - Each cell is 5 characters wide;
> >
> > - The no-data is “-9999”;
> >
> > - There is no separator between cells (what makes my task difficult);
> >
> > - It’s a multi-band raster dataset with 12 bands; (720x360x12 cells)
> >
> > - I am not sure if positive values can go beyond 9999 (that reminds me
> > COBOL)
> >
>
> I think a Python script would be the right approach since there is no
> generic ascii driver that could be used for this format. Since there is
> no field separator, I guess you will need to loop through the strings you
> read cutting out 5 character chunks of data as substrings.
>
> eg.
> for item_i in range(12):
> item = line[item_i:item_i+5]
> ...
>
> I imagine it would make sense to assemble the data in a Numeric array,
> and then push that back with band.WriteArray() or something simmilar.
> I was going to point at the gdal2grd.py script as an example, but it
> goes the other way ... from gdal format to ascii file. Perhaps it will
> help a bit. (gdal/pymod/samples/gdal2grd.py)
Sounds like you might want to look at Scientific.IO.FortranFormat:
http://starship.python.net/~hinsen/ScientificPython/
HTH
Norman
More information about the Gdal-dev
mailing list