[gdal-dev] Convert to temperature in degrees C in MODIS Ocean Color?

Jose Gomez-Dans jgomezdans at gmail.com
Thu Jul 19 12:03:19 PDT 2012


On 19 July 2012 15:25, Jose Gomez-Dans <jgomezdans at gmail.com> wrote:

> Hi,
>
>
> On 19 July 2012 04:46, sigologo <dlopezaspe at gmail.com> wrote:
>
>> I'm trying import A20030012003008.L3m_8D_NSST_4, with gdal with this
>> script:
>>
>> for file in A*L3m_8D_NSST_4 ; do
>>   echo "map: $file"
>>
>>   gdal_translate -a_srs "+init=epsg:4326" -a_nodata 65535 \
>>     -a_ullr -180 90 180 -90 -co "COMPRESS=PACKBITS" \
>>     HDF4_SDS:UNKNOWN:"$file":0  ${file}_out.tif
>>
>> done
>>
>> all good, but the data not be in degree C............. I find for it
>> another
>> script but no found in gdal...
>>
>
> The problem is that the data are linearly scaled (from the GRASS script
> you quoted). I am unfamiliar with the ocean products (that's the bit of the
> data I blank out ;-D), and you know the linear scaling (either because it's
> constant, or beause you can read it out from the files's metadata), I think
> you can use gdal_translates 'scale' option: -scale [src_min src_max
> [dst_min dst_max]]. Note that hte syntax will be slightly different to the
> slope/intercept one in your GRASS script.
>

Here is your script modified to take the linear correction into account.
Note that the destination spread (-2 to 45) was read from the metadata.
Also note that you need to make the output format Float, otherwise, you get
a quantised version.

*for file in A*L3m_8D_NSST_4 ; *
*do*
*  echo "map: $file"*
*  gdal_translate -of GTiff -ot Float32 \*
*                      -scale 0 65535 -2. 45. \*
*                      -a_srs "EPSG:4326" \*
*                      -a_nodata 65535  \*
*                      -a_ullr -180 90 180 -90 \*
*                      -co "COMPRESS=PACKBITS" \*
*                      'HDF4_SDS:UNKNOWN:"A20030012003008.L3m_8D_NSST_4":0'
\*
*                      A20030012003008.L3m_8D_NSST_4.tif*
*done*


Jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120719/ba6921bc/attachment.html>


More information about the gdal-dev mailing list