[Swift-commit] r5457 - in SwiftApps/modis: . bin
davidk at ci.uchicago.edu
davidk at ci.uchicago.edu
Wed Dec 21 10:52:08 CST 2011
Author: davidk
Date: 2011-12-21 10:52:08 -0600 (Wed, 21 Dec 2011)
New Revision: 5457
Added:
SwiftApps/modis/bin/
SwiftApps/modis/bin/analyzelanduse.sh
SwiftApps/modis/bin/analyzelanduse.sh.orig
SwiftApps/modis/bin/analyzelanduse2.sh
SwiftApps/modis/bin/analyzelandusep1.sh
SwiftApps/modis/bin/assemble.sh
SwiftApps/modis/bin/assemble.sh.orig
SwiftApps/modis/bin/assemble.sh.v2
SwiftApps/modis/bin/assemble2.sh
SwiftApps/modis/bin/colormodis.sh
SwiftApps/modis/bin/erasewater.sh
SwiftApps/modis/bin/getlanduse.sh
SwiftApps/modis/bin/gray.png
SwiftApps/modis/bin/grid.gif
SwiftApps/modis/bin/imagehist.sh
SwiftApps/modis/bin/markmap.sh
SwiftApps/modis/bin/setborder.sh
SwiftApps/modis/bin/setglobushost.sh
Log:
Missing bin directory
Added: SwiftApps/modis/bin/analyzelanduse.sh
===================================================================
--- SwiftApps/modis/bin/analyzelanduse.sh (rev 0)
+++ SwiftApps/modis/bin/analyzelanduse.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,45 @@
+#
+# Return (simple) stats and filenames for the tiles with the $num highest values of $field
+#
+
+stats=$1
+tilelist=$2
+field=$3
+num=$4
+shift 4
+
+grep " $field" $* |
+sed -e 's/:/ /' |
+sort -n -k +2 |
+tail -${num} >$stats
+
+( awk '{print $1}' |
+ sed -e 's/landuse.//' -e 's/\..*/.tif/' -e 's,^,/home/wilde/bigdata/data/modis/2002/,' \
+) <$stats >$tilelist
+
+exit
+
+login1$ cat topurban.txt
+landuse/h20v04.landuse.byfreq 67312 13 0d
+landuse/h28v06.landuse.byfreq 82267 13 0d
+landuse/h08v05.landuse.byfreq 92674 13 0d
+landuse/h11v04.landuse.byfreq 93702 13 0d
+landuse/h13v11.landuse.byfreq 104302 13 0d
+landuse/h12v04.landuse.byfreq 110772 13 0d
+landuse/h19v04.landuse.byfreq 120908 13 0d
+landuse/h27v05.landuse.byfreq 128794 13 0d
+landuse/h18v03.landuse.byfreq 142756 13 0d
+landuse/h18v04.landuse.byfreq 146486 13 0d
+
+login1$ cat urbantiles.txt
+/home/wilde/bigdata/data/modis/2002landuse/h20v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h28v06.tif
+/home/wilde/bigdata/data/modis/2002landuse/h08v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h11v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h13v11.tif
+/home/wilde/bigdata/data/modis/2002landuse/h12v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h19v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h27v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v03.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v04.tif
+login1$ fg
Property changes on: SwiftApps/modis/bin/analyzelanduse.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/analyzelanduse.sh.orig
===================================================================
--- SwiftApps/modis/bin/analyzelanduse.sh.orig (rev 0)
+++ SwiftApps/modis/bin/analyzelanduse.sh.orig 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,17 @@
+#
+# Return (simple) stats and filenames for the tiles with the $num highest values of $field
+#
+
+stats=$1
+tilelist=$2
+field=$3
+num=$4
+shift 4
+
+grep " $field" $* |
+sed -e 's/:/ /' |
+sort -n -k +2 |
+tail -${num} >$stats
+
+awk '{print $1}' |
+sed -e 's/\..*/.tif/' -e 's,^,/home/wilde/bigdata/data/modis/,' <$stats >$tilelist
Property changes on: SwiftApps/modis/bin/analyzelanduse.sh.orig
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/analyzelanduse2.sh
===================================================================
--- SwiftApps/modis/bin/analyzelanduse2.sh (rev 0)
+++ SwiftApps/modis/bin/analyzelanduse2.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,173 @@
+#
+# Return (simple) stats and filenames for the tiles with the $num highest values of $wanteduses
+#
+
+stats=$1
+tilelist=$2
+wanteduses=$3
+num=$4
+shift 4
+
+awk -v wanteduses="$wanteduses" '
+ BEGIN {
+ sum = 0;
+ filename = "";
+
+ use["water"]=0
+ use["evergreen needleleaf forest"]=1
+ use["evergreen broadleaf forest"]=2
+ use["deciduous needleleaf forest"]=3
+ use["deciduous broadleaf forest"]=4
+ use["mixed forests"]=5
+ use["closed shrubland"]=6
+ use["open shrublands"]=7
+ use["woody savannas"]=8
+ use["savannas"]=9
+ use["grasslands"]=10
+ use["permanent wetlands"]=11
+ use["croplands"]=12
+ use["urban and built-up"]=13
+ use["cropland/natural vegetation mosaic"]=14
+ use["snow and ice"]=15
+ use["barren or sparsely vegetated"]=16
+ use["unclassified"]=254
+
+ split(wanteduses,wants,"[ ,]+")
+ for (w in wants) {
+ for (u in use) {
+ if (index(u, wants[w])) {
+ wantuse[use[u]] = 1
+ }
+ }
+ }
+ }
+ {
+ if (FNR==1) {
+ if(filename != "") { print filename, sum}
+ filename = FILENAME
+ sum = 0
+ }
+ }
+
+ wantuse[$2] {
+ sum += $1
+ }
+ END { print filename, sum} ' $* |
+sort -n -k +2 |
+tail -${num} >$stats
+
+( awk '{print $1}' |
+ sed -e 's,^.*/,/,' -e 's/\..*/.tif/' -e 's,^,/home/wilde/bigdata/data/modis/2002/,' \
+# FIXME: dont hardcode dir path above
+# sed -e 's/landuse.//' -e 's/\..*/.tif/' -e 's,^,/home/wilde/bigdata/data/modis/2002/,' \
+) <$stats >$tilelist
+
+exit
+
+login1$ cat topselected.txt
+modis-2011.0102.1636-urban-50-9/h09v07.landuse.byfreq 5312
+modis-2011.0102.1636-urban-50-9/h08v07.landuse.byfreq 12555
+modis-2011.0102.1636-urban-50-9/h08v06.landuse.byfreq 14824
+modis-2011.0102.1636-urban-50-9/h10v04.landuse.byfreq 14852
+modis-2011.0102.1636-urban-50-9/h09v06.landuse.byfreq 21432
+modis-2011.0102.1636-urban-50-9/h09v04.landuse.byfreq 32954
+modis-2011.0102.1636-urban-50-9/h09v05.landuse.byfreq 38591
+modis-2011.0102.1636-urban-50-9/h10v05.landuse.byfreq 66613
+modis-2011.0102.1636-urban-50-9/h08v05.landuse.byfreq 92674
+
+login1$ cat selectedtiles.txt
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+/home/wilde/bigdata/data/modis/2002/modis-2011.tif
+login1$
+
+---
+
+login1$ cat topurban.txt
+landuse/h20v04.landuse.byfreq 67312 13 0d
+landuse/h28v06.landuse.byfreq 82267 13 0d
+landuse/h08v05.landuse.byfreq 92674 13 0d
+landuse/h11v04.landuse.byfreq 93702 13 0d
+landuse/h13v11.landuse.byfreq 104302 13 0d
+landuse/h12v04.landuse.byfreq 110772 13 0d
+landuse/h19v04.landuse.byfreq 120908 13 0d
+landuse/h27v05.landuse.byfreq 128794 13 0d
+landuse/h18v03.landuse.byfreq 142756 13 0d
+landuse/h18v04.landuse.byfreq 146486 13 0d
+
+login1$ cat urbantiles.txt
+/home/wilde/bigdata/data/modis/2002landuse/h20v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h28v06.tif
+/home/wilde/bigdata/data/modis/2002landuse/h08v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h11v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h13v11.tif
+/home/wilde/bigdata/data/modis/2002landuse/h12v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h19v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h27v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v03.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v04.tif
+login1$
+
+ 0 water
+ 1 evergreen needleleaf forest
+ 2 evergreen broadleaf forest
+ 3 deciduous needleleaf forest
+ 4 deciduous broadleaf forest
+ 5 mixed forests
+ 6 closed shrubland
+ 7 open shrublands
+ 8 woody savannas
+ 9 savannas
+ 10 grasslands
+ 11 permanent wetlands
+ 12 croplands
+ 13 urban and built-up
+ 14 cropland/natural vegetation mosaic
+ 15 snow and ice
+ 16 barren or sparsely vegetated
+ 254 unclassified
+
+ use["water"]=0
+ use["evergreen needleleaf forest"]=1
+ use["evergreen broadleaf forest"]=2
+ use["deciduous needleleaf forest"]=3
+ use["deciduous broadleaf forest"]=4
+ use["mixed forests"]=5
+ use["closed shrubland"]=6
+ use["open shrublands"]=7
+ use["woody savannas"]=8
+ use["savannas"]=9
+ use["grasslands"]=10
+ use["permanent wetlands"]=11
+ use["croplands"]=12
+ use["urban and built-up"]=13
+ use["cropland/natural vegetation mosaic"]=14
+ use["snow and ice"]=15
+ use["barren or sparsely vegetated"]=16
+ use["unclassified"]=254
+
+
+use["water"]=0
+use["evergreenneedle"]=1
+use["evergreenleaf"]=2
+use["deciduousneedle"]=3
+use["deciduousleaf"]=4
+use["mixedforest"]=5
+use["closedshrub"]=6
+use["openshrub"]=7
+use["woody"]=8
+use["savanna"]=9
+use["grassland"]=10
+use["wetland"]=11
+use["cropland"]=12
+use["urban"]=13
+use["vegetation"]=14
+use["ice"]=15
+use["barren"]=16
+use["unclassified"]=17
Property changes on: SwiftApps/modis/bin/analyzelanduse2.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/analyzelandusep1.sh
===================================================================
--- SwiftApps/modis/bin/analyzelandusep1.sh (rev 0)
+++ SwiftApps/modis/bin/analyzelandusep1.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,146 @@
+#
+# Return (simple) stats and filenames for the tiles with the $num highest values of $wanteduses
+#
+
+stats=$1
+tilelist=$2
+wanteduses=$3
+num=$4
+shift 4
+
+awk -v wanteduses="$wanteduses" '
+ BEGIN {
+ sum = 0;
+ filename = "";
+
+ use["water"]=0
+ use["evergreen needleleaf forest"]=1
+ use["evergreen broadleaf forest"]=2
+ use["deciduous needleleaf forest"]=3
+ use["deciduous broadleaf forest"]=4
+ use["mixed forests"]=5
+ use["closed shrubland"]=6
+ use["open shrublands"]=7
+ use["woody savannas"]=8
+ use["savannas"]=9
+ use["grasslands"]=10
+ use["permanent wetlands"]=11
+ use["croplands"]=12
+ use["urban and built-up"]=13
+ use["cropland/natural vegetation mosaic"]=14
+ use["snow and ice"]=15
+ use["barren or sparsely vegetated"]=16
+ use["unclassified"]=254
+
+ split(wanteduses,wants,"[ ,]+")
+ for (w in wants) {
+ for (u in use) {
+ if (index(u, wants[w])) {
+ wantuse[use[u]] = 1
+ }
+ }
+ }
+ }
+ {
+ if (FNR==1) {
+ if(filename != "") { print filename, sum}
+ filename = FILENAME
+ sum = 0
+ }
+ }
+
+ wantuse[$2] {
+ sum += $1
+ }
+ END { print filename, sum} ' $* |
+sort -n -k +2 |
+tail -${num} >$stats
+
+( awk '{print $1}' |
+ sed -e 's/landuse.//' -e 's/\..*/.tif/' -e 's,^,/home/wilde/bigdata/data/modis/2002/,' \
+) <$stats >$tilelist
+
+exit
+
+login1$ cat topurban.txt
+landuse/h20v04.landuse.byfreq 67312 13 0d
+landuse/h28v06.landuse.byfreq 82267 13 0d
+landuse/h08v05.landuse.byfreq 92674 13 0d
+landuse/h11v04.landuse.byfreq 93702 13 0d
+landuse/h13v11.landuse.byfreq 104302 13 0d
+landuse/h12v04.landuse.byfreq 110772 13 0d
+landuse/h19v04.landuse.byfreq 120908 13 0d
+landuse/h27v05.landuse.byfreq 128794 13 0d
+landuse/h18v03.landuse.byfreq 142756 13 0d
+landuse/h18v04.landuse.byfreq 146486 13 0d
+
+login1$ cat urbantiles.txt
+/home/wilde/bigdata/data/modis/2002landuse/h20v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h28v06.tif
+/home/wilde/bigdata/data/modis/2002landuse/h08v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h11v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h13v11.tif
+/home/wilde/bigdata/data/modis/2002landuse/h12v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h19v04.tif
+/home/wilde/bigdata/data/modis/2002landuse/h27v05.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v03.tif
+/home/wilde/bigdata/data/modis/2002landuse/h18v04.tif
+login1$
+
+ 0 water
+ 1 evergreen needleleaf forest
+ 2 evergreen broadleaf forest
+ 3 deciduous needleleaf forest
+ 4 deciduous broadleaf forest
+ 5 mixed forests
+ 6 closed shrubland
+ 7 open shrublands
+ 8 woody savannas
+ 9 savannas
+ 10 grasslands
+ 11 permanent wetlands
+ 12 croplands
+ 13 urban and built-up
+ 14 cropland/natural vegetation mosaic
+ 15 snow and ice
+ 16 barren or sparsely vegetated
+ 254 unclassified
+
+ use["water"]=0
+ use["evergreen needleleaf forest"]=1
+ use["evergreen broadleaf forest"]=2
+ use["deciduous needleleaf forest"]=3
+ use["deciduous broadleaf forest"]=4
+ use["mixed forests"]=5
+ use["closed shrubland"]=6
+ use["open shrublands"]=7
+ use["woody savannas"]=8
+ use["savannas"]=9
+ use["grasslands"]=10
+ use["permanent wetlands"]=11
+ use["croplands"]=12
+ use["urban and built-up"]=13
+ use["cropland/natural vegetation mosaic"]=14
+ use["snow and ice"]=15
+ use["barren or sparsely vegetated"]=16
+ use["unclassified"]=254
+
+
+use["water"]=0
+use["evergreenneedle"]=1
+use["evergreenleaf"]=2
+use["deciduousneedle"]=3
+use["deciduousleaf"]=4
+use["mixedforest"]=5
+use["closedshrub"]=6
+use["openshrub"]=7
+use["woody"]=8
+use["savanna"]=9
+use["grassland"]=10
+use["wetland"]=11
+use["cropland"]=12
+use["urban"]=13
+use["vegetation"]=14
+use["ice"]=15
+use["barren"]=16
+use["unclassified"]=17
Property changes on: SwiftApps/modis/bin/analyzelandusep1.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/assemble.sh
===================================================================
--- SwiftApps/modis/bin/assemble.sh (rev 0)
+++ SwiftApps/modis/bin/assemble.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,13 @@
+output=$1
+shift
+inputs=$(ls -1 $*)
+labels=""
+for f in $inputs; do
+ labels="$labels -label $(echo $f | sed -e 's/^.*\(h..v..\).*/\1/') $f"
+done
+
+echo doing:
+echo montage $labels -font Courier-Regular $inputs $output
+
+montage $labels -font Courier-Regular $output
+
Property changes on: SwiftApps/modis/bin/assemble.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/assemble.sh.orig
===================================================================
--- SwiftApps/modis/bin/assemble.sh.orig (rev 0)
+++ SwiftApps/modis/bin/assemble.sh.orig 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,4 @@
+output=$1
+shift
+inputs=$(ls -1 $*)
+montage -label '%f' -font Courier-Regular $inputs $output
\ No newline at end of file
Property changes on: SwiftApps/modis/bin/assemble.sh.orig
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/assemble.sh.v2
===================================================================
--- SwiftApps/modis/bin/assemble.sh.v2 (rev 0)
+++ SwiftApps/modis/bin/assemble.sh.v2 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,10 @@
+output=$1
+shift
+inputs=$(ls -1 $*)
+labels=""
+for f in $inputs; do
+ labels="$labels -label $(echo $f | sed -e 's/^.*\(h..v..\).*/\1/') $f"
+done
+
+montage $label -font Courier-Regular $inputs $output
+
Property changes on: SwiftApps/modis/bin/assemble.sh.v2
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/assemble2.sh
===================================================================
--- SwiftApps/modis/bin/assemble2.sh (rev 0)
+++ SwiftApps/modis/bin/assemble2.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,54 @@
+#! /bin/bash
+
+output=$(cd $(dirname $1); echo $(pwd)/$(basename $1)) # get full pathname of output file
+selected=$(cd $(dirname $2); echo $(pwd)/$(basename $2)) # get full pathname of input file "selected"
+indir=$(cd $(dirname $3); pwd) # get full pathname of input dir "geos"
+webdir=$4
+
+tmp=$(mktemp -d /tmp/modis.assemble.XXXX)
+bindir=$(cd $(dirname $0); pwd)
+graytile=$bindir/gray.png
+
+# input files are expected to start with hNNvNN.
+# we reverse this to form the final image
+
+cd $indir
+for h in `seq -w 00 35`; do
+ for v in `seq -w 00 17`; do
+ hv=h${h}v${v}
+ vh=v${v}h${h}
+ if [ ! -f $hv*png ]; then
+ cp $graytile $tmp/$vh.png
+ elif grep $hv $selected >&/dev/null; then
+echo "adding border to $hv"
+ # add red border
+ convert $hv*png -resize 290x290 $tmp/t.png
+ convert $tmp/t.png -bordercolor red -border 5x5 $tmp/$vh.png
+ else
+ cp $hv*png $tmp/$vh.png
+ fi
+ done
+done
+
+montage -tile 36x18 -geometry +0+0 $tmp/v*png $tmp/bigmap.png
+convert $tmp/bigmap.png -resize 20% $tmp/map.png
+cp $tmp/map.png $output
+cp $tmp/bigmap.png $output
+
+if [ -d "$webdir" ]; then
+ cp $tmp/map.png $webdir
+fi
+
+
+###########
+
+exit 0
+
+inputs=$(ls -1 $*)
+labels=""
+for f in $inputs; do
+ labels="$labels -label $(echo $f | sed -e 's/^.*\(h..v..\).*/\1/') $f"
+done
+
+montage $labels -font Courier-Regular $output
+
Property changes on: SwiftApps/modis/bin/assemble2.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/colormodis.sh
===================================================================
--- SwiftApps/modis/bin/colormodis.sh (rev 0)
+++ SwiftApps/modis/bin/colormodis.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,53 @@
+#
+# Return a new modis files with the 0-16 pixel values changed to
+# colors that reflect the land use of that region. (See legend)
+#
+# usage: colormodis.sh modis.tif recolored.tif
+#
+
+infile=$1
+outfile=$2
+tmp=`mktemp /tmp/modis.$USER.XXXXXX`
+mv $tmp $tmp.tif
+tmp=$tmp.tif
+map=`mktemp /tmp/colormap.$USER.XXXXXX`
+
+# Create color set
+
+(
+ cat |
+ sed -e 's/ c.=/ /g' -e 's/[^0-9 ]//g' |
+ awk '{printf("#%02x%02x%02x #%02x%02x%02x\n",NR-1,NR-1,NR-1,$1,$2,$3)}') >$map <<EOF
+ <Entry c1="32" c2="65" c3="179" c4="255"/>
+ <Entry c1="0" c2="106" c3="15" c4="255"/>
+ <Entry c1="0" c2="124" c3="37" c4="255"/>
+ <Entry c1="0" c2="162" c3="91" c4="255"/>
+ <Entry c1="0" c2="161" c3="37" c4="255"/>
+ <Entry c1="6" c2="146" c3="40" c4="255"/>
+ <Entry c1="158" c2="150" c3="104" c4="255"/>
+ <Entry c1="193" c2="196" c3="143" c4="255"/>
+ <Entry c1="133" c2="170" c3="91" c4="255"/>
+ <Entry c1="177" c2="183" c3="65" c4="255"/>
+ <Entry c1="164" c2="208" c3="126" c4="255"/>
+ <Entry c1="115" c2="171" c3="174" c4="255"/>
+ <Entry c1="204" c2="210" c3="83" c4="255"/>
+ <Entry c1="217" c2="0" c3="0" c4="255"/>
+ <Entry c1="157" c2="227" c3="110" c4="255"/>
+ <Entry c1="182" c2="181" c3="194" c4="255"/>
+ <Entry c1="148" c2="148" c3="148" c4="255"/>
+EOF
+
+cp $infile $tmp
+
+# output logged to stdout/error is ignored by swift for this app()
+
+while read mval color ; do
+ echo color $mval is $color
+ echo convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
+ convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
+done <$map
+
+#cp $tmp $outfile
+convert -thumbnail 300x300 $tmp $outfile
+
+rm $tmp $map
Property changes on: SwiftApps/modis/bin/colormodis.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/erasewater.sh
===================================================================
--- SwiftApps/modis/bin/erasewater.sh (rev 0)
+++ SwiftApps/modis/bin/erasewater.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,78 @@
+#
+# Return a new modis files with the 0-16 pixel values changed to
+# colors that reflect the land use of that region. (See legend)
+#
+# usage: colormodis.sh modis.tif recolored.tif
+#
+
+infile=$1
+outfile=$2
+tmp=`mktemp /tmp/modis.$USER.XXXXXX`
+mv $tmp $tmp.tif
+tmp=$tmp.tif
+tmp=$2
+map=`mktemp /tmp/colormap.$USER.XXXXXX`
+
+# Create color set
+
+(
+ cat |
+ sed -e 's/ c.=/ /g' -e 's/[^0-9 ]//g' |
+ awk '{printf("#%02x%02x%02x #%02x%02x%02x\n",$1,$2,$3,255,255,255)}') >$map <<EOF
+ <Entry c1="32" c2="65" c3="179" c4="255"/>
+EOF
+
+cp $infile $tmp
+
+# output logged to stdout/error is ignored by swift for this app()
+
+while read mval color ; do
+ echo color $mval is $color
+ echo convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
+ convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
+done <$map
+
+exit
+
+#cp $tmp $outfile
+convert -thumbnail 300x300 $tmp $outfile
+
+# rm $tmp $map # Keep these for debugging, for now.
+
+cat >/dev/null <<END # PIXELVALUES
+ 0 water
+ 1 evergreen needleleaf forest
+ 2 evergreen broadleaf forest
+ 3 deciduous needleleaf forest
+ 4 deciduous broadleaf forest
+ 5 mixed forests
+ 6 closed shrubland
+ 7 open shrublands
+ 8 woody savannas
+ 9 savannas
+ 10 grasslands
+ 11 permanent wetlands
+ 12 croplands
+ 13 urban and built-up
+ 14 cropland/natural vegetation mosaic
+ 15 snow and ice
+ 16 barren or sparsely vegetated
+ 254 unclassified
+0 <Entry c1="32" c2="65" c3="179" c4="255"/>
+1 <Entry c1="0" c2="106" c3="15" c4="255"/>
+2 <Entry c1="0" c2="124" c3="37" c4="255"/>
+3 <Entry c1="0" c2="162" c3="91" c4="255"/>
+4 <Entry c1="0" c2="161" c3="37" c4="255"/>
+5 <Entry c1="6" c2="146" c3="40" c4="255"/>
+6 <Entry c1="158" c2="150" c3="104" c4="255"/>
+7 <Entry c1="193" c2="196" c3="143" c4="255"/>
+8 <Entry c1="133" c2="170" c3="91" c4="255"/>
+9 <Entry c1="177" c2="183" c3="65" c4="255"/>
+10 <Entry c1="164" c2="208" c3="126" c4="255"/>
+11 <Entry c1="115" c2="171" c3="174" c4="255"/>
+12 <Entry c1="204" c2="210" c3="83" c4="255"/>
+13 <Entry c1="217" c2="0" c3="0" c4="255"/>
+14 <Entry c1="157" c2="227" c3="110" c4="255"/>
+15 <Entry c1="182" c2="181" c3="194" c4="255"/>
+16 <Entry c1="148" c2="148" c3="148" c4="255"/>
+EOF
\ No newline at end of file
Property changes on: SwiftApps/modis/bin/erasewater.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/getlanduse.sh
===================================================================
--- SwiftApps/modis/bin/getlanduse.sh (rev 0)
+++ SwiftApps/modis/bin/getlanduse.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,14 @@
+#
+# Read a MODIS .tif file and return a histogram of pixel values.
+# The pixel values signify land use for that region (see legend in notes)
+#
+# Usage: getlanduse.sh modisFile histogramFile
+#
+
+#sleep 1
+convert $1 -format %c histogram:info:- 2>/dev/null |
+ grep '[0-9]' |
+ sort -nr |
+ sed -e 's/[^0-9 ]//g' |
+ awk '{print $1, $3, sprintf("%02x",$3)}' |
+ sort -n -k $2
Property changes on: SwiftApps/modis/bin/getlanduse.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/gray.png
===================================================================
(Binary files differ)
Property changes on: SwiftApps/modis/bin/gray.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftApps/modis/bin/grid.gif
===================================================================
(Binary files differ)
Property changes on: SwiftApps/modis/bin/grid.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftApps/modis/bin/imagehist.sh
===================================================================
--- SwiftApps/modis/bin/imagehist.sh (rev 0)
+++ SwiftApps/modis/bin/imagehist.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1 @@
+convert $1 -format %c histogram:info:- 2>/dev/null | grep : | sort -nr
Property changes on: SwiftApps/modis/bin/imagehist.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/markmap.sh
===================================================================
--- SwiftApps/modis/bin/markmap.sh (rev 0)
+++ SwiftApps/modis/bin/markmap.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,25 @@
+# markmap selectedTileFile outputMap
+
+bin=$(cd $(dirname $0); pwd)
+
+tilefile=$1
+outmap=$2
+
+cp $bin/grid.gif $outmap
+cat $tilefile | while read f ; do
+ hv=$(echo $f | sed -e 's,^.*/,,' -e 's/\..*//')
+ h=$(echo $hv | sed -e 's/h//' -e 's/v..//' -e 's/^0//')
+ v=$(echo $hv | sed -e 's/h..//' -e 's/v//' -e 's/^0//')
+ echo hv=$hv h=$h v=$v
+ convert $outmap -stroke red -linewidth 2 -fill transparent \
+ -draw "rectangle $((34+$h*16)),$((51+$v*16)) $((34+14+$h*16)),$((51+14+$v*16))" $outmap
+done
+
+exit
+
+# example:
+
+h=18
+v=8
+cp grid.gif g.gif
+convert g.gif -stroke red -linewidth 2 -fill transparent -draw "rectangle $((34+$h*16)),$((51+$v*16)) $((34+14+$h*16)),$((51+14+$v*16))" g.gif
Property changes on: SwiftApps/modis/bin/markmap.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/setborder.sh
===================================================================
--- SwiftApps/modis/bin/setborder.sh (rev 0)
+++ SwiftApps/modis/bin/setborder.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1 @@
+convert $1 -bordercolor red -border 20 $2
Property changes on: SwiftApps/modis/bin/setborder.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftApps/modis/bin/setglobushost.sh
===================================================================
--- SwiftApps/modis/bin/setglobushost.sh (rev 0)
+++ SwiftApps/modis/bin/setglobushost.sh 2011-12-21 16:52:08 UTC (rev 5457)
@@ -0,0 +1,2 @@
+ipaddr=`/sbin/ifconfig | grep inet | head -1 | cut -d ':' -f 2 |awk '{print $1}'`
+export GLOBUS_HOSTNAME=$ipaddr
Property changes on: SwiftApps/modis/bin/setglobushost.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the Swift-commit
mailing list