Commit bf2302b2 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

SCL to JSON

parent b23dd212
......@@ -130,7 +130,7 @@ This script count the total number of each of the 12 classes in a SCL image form
```json
{
"wkt":"POLYGON((-89.62955474853516 21.05230266883862,-89.55093383789061 21.05230266883862,-89.52930450439452 20.965126493194475,-89.6484375 20.873408465645696,-89.72877502441405 20.95294341625548,-89.65805053710938 21.056788298627097,-89.62955474853516 21.05230266883862))" ,
"filename":"/home/geoint/NAS/data/mergecrop/20180214SCL_20m_merged.tif"
"filename":"/home/geoint/NAS/data/mergecrop/20180214SCL_20m.tif"
}
```
```bash
......
......@@ -22,12 +22,12 @@ def L2ASCLtoDict(filename, wkt):
return dict(count)
#-------------------------------------------------------------------------------
def main(argv):
if len(sys.argv) != 2:
if len(sys.argv) != 3:
print("Usage: " + argv[0] + " <JSON File>")
else:
jsonFile=open(argv[1]).read()
jsonFile=open(argv[2]).read()
cfg = json.loads(jsonFile)
dataDict = L2ASCLtoDict(cfg["filename"], cfg['wkt'])
dataDict = L2ASCLtoDict(argv[1], cfg['wkt'])
print(dataDict)
#-------------------------------------------------------------------------------
if __name__ == "__main__":
......
#!/bin/sh
DIR=$1
CGF=$2
JOBS=${3:-1}
cd $DIR
ls *_SCL_20m.tif | parallel --jobs $JOBS L2ASCLtoJSON.py {} $2
......@@ -9,7 +9,7 @@ cd $DIR
DIRNAME=$(echo $DIR | cut -d"/" -f1)
echo $DIRNAME
##------------------------------------------------------------------------------
MERGEDIMAGE=$DIRNAME"TCI_10m_merged.tif"
MERGEDIMAGE=$DIRNAME"_TCI_10m_merged.tif"
if [ ! -e $MERGEDIMAGE ]; then
echo "gdal_merge.py -o "$MERGEDIMAGE $(ls *TCI_10m.jp2)
gdal_merge.py -o $MERGEDIMAGE $(ls *TCI_10m.jp2)
......@@ -17,14 +17,14 @@ else
echo PASSING $MERGEDIMAGE FOUND
fi
CROPEDIMAGE=../mergecrop/$DIRNAME"TCI_10m_mergedcroped.tif"
CROPEDIMAGE=../merged/$DIRNAME"_TCI_10m.tif"
if [ ! -e $CROPEDIMAGE ]; then
gdal_translate -projwin $BOX -projwin_srs WGS84 -ot Byte -of JPEG $MERGEDIMAGE $CROPEDIMAGE
else
echo PASSING $CROPEDIMAGE FOUND
fi
##------------------------------------------------------------------------------
MERGEDIMAGE=$DIRNAME"SCL_20m_merged.tif"
MERGEDIMAGE=$DIRNAME"_SCL_20m_merged.tif"
if [ ! -e $MERGEDIMAGE ]; then
echo "gdal_merge.py -o "$MERGEDIMAGE $(ls *SCL_20m.jp2)
gdal_merge.py -o $MERGEDIMAGE $(ls *SCL_20m.jp2)
......@@ -32,7 +32,7 @@ else
echo PASSING $MERGEDIMAGE FOUND
fi
CROPEDIMAGE=../mergecrop/$DIRNAME"SCL_20m_merged.tif"
CROPEDIMAGE=../merged/$DIRNAME"_SCL_20m.tif"
if [ ! -e $CROPEDIMAGE ]; then
gdal_translate -projwin $BOX -projwin_srs WGS84 -ot Byte -of JPEG $MERGEDIMAGE $CROPEDIMAGE
else
......
......@@ -11,8 +11,7 @@ if [ "$#" -le 1 ]; then
fi
cd $JP2DIR
mkdir mergecrop
mkdir cropmerge
mkdir merged
ls -d */ | parallel -q --jobs $JOBS mergeImages.sh {} "$POLYGON"
find . -name *.xml -type f -delete
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment