[GRASS-dev] MODIS Metadata information kept after GDALimport/warp into GRASS

Markus Neteler neteler at osgeo.org
Thu Feb 18 09:01:34 EST 2010


2010/2/18 António Rocha <antonio.rocha at deimos.com.pt>:
> If you put it like that it seems easy :). How are you parsing metadata to an
> XML file?

With brute-force shell scripting (yes, I would better lear Python and use an XML
parser):

RangeBeginningDate=`cat $HDFXML   | grep RangeBeginningDate  | cut
-d'>' -f2 | cut -d'<' -f1`
RangeBeginningTime=`cat $HDFXML   | grep RangeBeginningTime  | cut
-d'>' -f2 | cut -d'<' -f1`
RangeEndingTime=`cat $HDFXML      | grep RangeEndingTime     |cut
-d'>' -f2 | cut -d'<' -f1`
QAPercentCloudCover=`cat $HDFXML  | grep QAPercentCloudCover | cut
-d'>' -f2 | cut -d'<' -f1`
QAPercentMissingData=`cat $HDFXML | grep QAPercentMissingData | cut
-d'>' -f2 | cut -d'<' -f1`
DayNightFlag=`cat $HDFXML | grep  DayNightFlag | cut -d'>' -f2 | cut -d'<' -f1`
PGEVersion=`cat $HDFXML   | grep PGEVersion | cut -d'>' -f2 | cut -d'<' -f1`
PGEVersionComposed=`echo $PGEVersion | sed 's/\.//g'`
ObservationDate=`echo $RangeBeginningDate | sed 's/\-//g'`

METASTRING="Date:$RangeBeginningDate;BeginningTime:$RangeBeginningTime;EndingTime:$RangeEndingTime;DayNightFlag:$DayNightFlag;QAPercentCloudCover:$QAPercentCloudCover;QAPercentMissingData:$QAPercentMissingData;PGEVersion:$PGEVersion"
echo $METASTRING

r.support map history="$METASTRING"

Ciao
Markus


More information about the grass-dev mailing list