3 output_dir
="/home/jbeezley/wrfdata/geog/landfire_data"
11 pval
=$
(grep -a $pname $fname |
sed "s/^${pname} *//" |
sed 's/ *//g' |
tr -d '\r' )
17 str
=$
(echo $1 |
sed 's/^ *//' |
sed 's/ *$//' |
sed 's/ */ /g')
18 pdeg
=$
(echo $str | cut
-s -d " " -f 1)
19 pmin
=$
(echo $str | cut
-s -d " " -f 2)
20 psec
=$
(echo $str | cut
-s -d " " -f 3)
23 function get_origin_params
29 sstr
='\/\* 1st standard parallel'
30 par1str
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
31 split_string
"$par1str"
35 sstr
='\/\* 2nd standard parallel'
36 par2str
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
37 split_string
"$par2str"
41 sstr
='\/\* central meridian'
42 merstr
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
43 split_string
"$merstr"
47 sstr
='\/\* latitude of projection'
48 latstr
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
49 split_string
"$latstr"
53 sstr
='\/\* false easting'
54 falseeast
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
55 sstr
='\/\* false northing'
56 falsenorth
=$
(grep -a "$sstr" $fname |
sed "s/ *${sstr}.*$//" |
tr -d '\r')
63 fname
="${dir}/${dir}.prj"
64 get_param
$fname Projection
66 get_param
$fname Datum
68 get_param
$fname Spheroid
70 get_param
$fname Units
72 get_param
$fname Zunits
74 get_param
$fname Xshift
76 get_param
$fname Yshift
79 get_origin_params
$fname
81 fname
="${dir}/${dir}.hdr"
82 get_param
$fname ncols
84 get_param
$fname nrows
86 get_param
$fname xllcorner
88 get_param
$fname yllcorner
90 get_param
$fname cellsize
92 get_param
$fname NODATA_value
94 get_param
$fname byteorder
100 rm -fr "$output_dir" &> /dev
/null
101 mkdir
-p "$output_dir" &> /dev
/null
102 idx
="$output_dir/index"
104 if [ "$proj" == "ALBERS" ] && [ "$datum" == "NAD83" ] ; then
106 # echo "projection=albers_nad83" >> $idx
107 echo "projection=regular_ll" >> $idx
109 echo "Projection $proj $datum not supported"
113 echo 'type=categorical' >> $idx
114 echo 'units="category"' >> $idx
115 echo 'description="Anderson 13 Fire Behavior Fuel Models"' >> $idx
117 if [ $nproj -eq 1 ] && [ $units == METERS
] ; then
118 echo "dx=$cellsize" >> $idx
119 echo "dy=$cellsize" >> $idx
121 echo "Unit conversion for $units to meters not supported"
125 echo 'known_x=1' >> $idx
126 echo 'known_y=1' >> $idx
128 echo "WARNING: reference long/lat is not implemented yet, setting to static value"
129 echo 'known_lat=35.7337' >> $idx
130 echo 'known_lon=-107.3452' >> $idx
132 echo 'wordsize=2' >> $idx
133 echo 'category_min=1' >> $idx
134 echo 'category_max=14' >> $idx
135 echo 'tile_bdr=0' >> $idx
136 echo 'missing_value=0' >> $idx
137 echo 'scale_factor=1' >> $idx
138 echo 'row_order=bottom_top' >> $idx
140 if [ $byteorder == LSBFIRST
] ; then
141 echo 'endian=little' >> $idx
143 echo 'endian=big' >> $idx
146 echo "tile_x=$nrows" >> $idx
147 echo "tile_y=$ncols" >> $idx
148 echo "tile_z=14" >> $idx
150 .
/convert_landfire.x
${1}/${1}.flt
$ncols $nrows
151 nfname
="$output_dir/$(printf "%05d
,%05d.
%05d
,%05d
" 1 $ncols 1 $nrows)"
152 mv "${1}/${1}.flt_tmp" "$nfname"