[GRASS-SVN] r58965 - in grass/trunk/raster/r.li: r.li.daemon r.li.setup
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Feb 8 22:16:50 PST 2014
Author: hamish
Date: 2014-02-08 22:16:50 -0800 (Sat, 08 Feb 2014)
New Revision: 58965
Modified:
grass/trunk/raster/r.li/r.li.daemon/daemon.c
grass/trunk/raster/r.li/r.li.setup/area_query
grass/trunk/raster/r.li/r.li.setup/masked_area_selection.sh
grass/trunk/raster/r.li/r.li.setup/r.li.setup
grass/trunk/raster/r.li/r.li.setup/r.li.setup.html
grass/trunk/raster/r.li/r.li.setup/r.li.setup.main
grass/trunk/raster/r.li/r.li.setup/r.li.setup.procedures.tcl
grass/trunk/raster/r.li/r.li.setup/r.li.windows.tcl
grass/trunk/raster/r.li/r.li.setup/sample_area_vector.sh
grass/trunk/raster/r.li/r.li.setup/square_mouse_selection.sh
grass/trunk/raster/r.li/r.li.setup/square_query
Log:
sync old r.li.setup scripts with devbr6 (up to r58929)
Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c 2014-02-09 06:16:50 UTC (rev 58965)
@@ -371,6 +371,7 @@
aid++;
insertNode(l, m);
}
+
while ((token = strtok(NULL, " ")) != NULL &&
(strcmp(token, "MASKEDOVERLAYAREA") == 0));
Modified: grass/trunk/raster/r.li/r.li.setup/area_query
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/area_query 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/area_query 2014-02-09 06:16:50 UTC (rev 58965)
@@ -4,21 +4,22 @@
# Simply ask if the selected area is ok or not and save the
-# answer in the environment variable "env(name)"
+# answer in the filename given by the environment variable "env(name)"
wm title . "Select this area"
wm minsize . 250 100
- label .label -text "Is this area ok?"
+
+ label .label -text "\nIs this area ok?"
pack .label
frame .buttons
pack .buttons
- set val ""
+ set val "$env(input_vector)_$env(CAT)"
button .buttons.ok -text "Ok" -command {
frame .name
pack .name
frame .name.e
pack .name.e
- label .name.e.n -text "Insert area name"
+ label .name.e.n -text "Enter area name\n(raster map mask name)"
entry .name.e.val -textvariable val -width 20
grid .name.e.n .name.e.val
frame .name.buttons
@@ -27,7 +28,7 @@
if {$val != ""} then {
exec echo 1 $val > $env(name)
destroy .
- }
+ }
}
pack .name.buttons.b
}
@@ -35,4 +36,11 @@
exec echo 0 > $env(name)
destroy .
}
- grid .buttons.ok .buttons.no
+ # what to call it: "stop"? "abort"? "quit"?
+ button .buttons.abort -text "Done" -command {
+ exec echo -1 > $env(name)
+ destroy .
+ }
+
+ grid .buttons.ok .buttons.no .buttons.abort -padx 2 -pady 2
+
Modified: grass/trunk/raster/r.li/r.li.setup/masked_area_selection.sh
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/masked_area_selection.sh 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/masked_area_selection.sh 2014-02-09 06:16:50 UTC (rev 58965)
@@ -57,7 +57,7 @@
#% required: no
#%end
#%option
-#% key: west
+#% key: west
#% type: string
#% description: Western edge (use only with the 'f' flag)
#% required: no
@@ -134,32 +134,33 @@
fi
done
-# open the Xmonitor
-d.mon stop="$XMON"
-d.mon start="$XMON"
+d.mon start="$XMON" --quiet
-d.rast -o map="$GIS_OPT_raster"
+d.rast -o map="$GIS_OPT_raster" --quiet
if [ -n "$GIS_OPT_vector" ] ; then
- d.vect map="$GIS_OPT_vector"
+ d.vect map="$GIS_OPT_vector" type=area fcolor=none width=2
fi
-if [ -n "$GIS_OPT_site" ] ; then
+if [ -n "$GIS_OPT_site" ] ; then
+ d.vect map="$GIS_OPT_site" color=black fcolor=black size=9 icon=basic/circle
d.vect map="$GIS_OPT_site" color=red fcolor=red size=5 icon=basic/circle
fi
# setup for drawing area
if [ "$GIS_FLAG_c" -eq 1 ] ; then
RDIG_INSTR="$f_path/circle.txt"
+ STYLE="circle"
else
RDIG_INSTR="$f_path/polygon.txt"
+ STYLE="polygon"
fi
# feed options to r.digit
-r.digit output="tmp_rli_mask.$$" < "$RDIG_INSTR"
+r.digit output="tmp_rli_mask.$$" --quiet < "$RDIG_INSTR"
# show the selected area
-d.rast -o map="tmp_rli_mask.$$"
+d.rast -o map="tmp_rli_mask.$$" --quiet
name="$TMP.val"
export name
@@ -172,10 +173,11 @@
if [ "$ok" -eq 1 ] ; then
+ mask_name="rli_samp_${STYLE}_${r_name}"
# r.mask + 'g.region zoom= align=' + 'r.mapcalc cropmap=map' would be cleaner?
- r.to.vect input="tmp_rli_mask.$$" output="tmp_rli_mask_v$$" feature=area
+ r.to.vect input="tmp_rli_mask.$$" output="tmp_rli_mask_v$$" feature=area --quiet
g.region vect="tmp_rli_mask_v$$"
- v.to.rast input="tmp_rli_mask_v$$" output="$r_name" value=1 use=val
+ v.to.rast input="tmp_rli_mask_v$$" output="$mask_name" use=val value=1 --quiet
# write info in configuration file
eval `g.region -g`
@@ -184,7 +186,7 @@
east="$e"
west="$w"
- echo "SAMPLEAREAMASKED $r_name $north|$south|$east|$west" >> \
+ echo "SAMPLEAREAMASKED $mask_name $north|$south|$east|$west" >> \
"$GIS_OPT_conf"
# remove tmp raster and vector
@@ -203,7 +205,7 @@
fi
-d.mon stop="$XMON"
+d.mon stop="$XMON" --quiet
# clean tmp files
cleanup
Modified: grass/trunk/raster/r.li/r.li.setup/r.li.setup
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/r.li.setup 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/r.li.setup 2014-02-09 06:16:50 UTC (rev 58965)
@@ -5,12 +5,14 @@
# MODULE: r.li.setup
#
# AUTHOR(S): Spano Lucio Davide & Claudio Porta
+# shell scripts rewrite by Hamish Bowman
#
-# PURPOSE: Configuration editor for r.li.<index>. It sets sampling frame and
-# sample areas to analyze, the configuration is raster map indipendent.
+# PURPOSE: Configuration editor for r.li.<index>. It sets sampling
+# frame and sample areas to analyze, the configuration is
+# raster map indipendent.
#
-# This program is free software under the GPL (>=v2)
-# Read the COPYING file that comes with GRASS for details.
+# This program is free software under the GPL (>=v2)
+# Read the COPYING file that comes with GRASS for details.
#
#############################################################################
Modified: grass/trunk/raster/r.li/r.li.setup/r.li.setup.html
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/r.li.setup.html 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/r.li.setup.html 2014-02-09 06:16:50 UTC (rev 58965)
@@ -32,7 +32,7 @@
<li> Centered over sites (vector points).
</ul>
<li> Moving window: rectagular or circular with size
-<li> Select areas from the overlayed vector map (for details see below)
+<li> Select areas from the overlaid vector map (for details see below)
</ul>
<img src="sampleAreas.jpg" alt="Sampling area definition">
@@ -63,9 +63,9 @@
of new configuration file
<li> <em>Raster map name</em> (required): the name of raster
map to use for setting
- <li> <em>Vector map to overlay</em> (optional): name of a vector
+ <li> <em>Vector areas map to overlay</em> (optional): name of a vector
map to overlay in setting
- <li> <em>Site file to overlay</em> (optional): name of vector map
+ <li> <em>Vector points map to overlay</em> (optional): name of vector map
of points type to overlay in setting
</ul>
<li> Set the sampling frame. The sample frame is a rectangular area
@@ -119,7 +119,7 @@
circular area, it is moved over all the raster increasing only
of a cell for every move(in columns if possible, if not in rows).
It produces a new raster containing the result of all analysis.
- <li><em>Select areas from the overlayed vector map</em>:
+ <li><em>Select areas from the overlaid vector map</em>:
the sample areas are defined by the vector map selected above.
For every cat in vector map, the procedure prompts the
user if he wants to include it as sample area.
Modified: grass/trunk/raster/r.li/r.li.setup/r.li.setup.main
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/r.li.setup.main 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/r.li.setup.main 2014-02-09 06:16:50 UTC (rev 58965)
@@ -89,13 +89,13 @@
pack $widget.samplingArea.choice
set selection ""
radiobutton $widget.samplingArea.choice.whole -text "Whole map layer" -relief flat -variable selection -value whole -width 40 -anchor w
- radiobutton $widget.samplingArea.choice.regions -text "Regions" -relief flat -variable selection -value regions -width 40 -anchor w
- radiobutton $widget.samplingArea.choice.units -text "Sample units" -relief flat -variable selection -value units -width 40 -anchor w
+ radiobutton $widget.samplingArea.choice.regions -text "Regions (digitize polygons with mouse)" -relief flat -variable selection -value regions -width 40 -anchor w
+ radiobutton $widget.samplingArea.choice.units -text "Sample units (digitize box or circular areas\nwith mouse or define using keyboard)" -relief flat -variable selection -value units -width 40 -anchor w
radiobutton $widget.samplingArea.choice.window -text "Moving window" -relief flat -variable selection -value window -width 40 -anchor w
set vectorAreas [exec cat $env(TMP).set | grep "SAMPLINGFRAME" | tail -n 1 | cut -f2 -d " "]
if { $vectorAreas == "0|0|1|1"} then {
- #inserting select areas from the overlayed vector map
- radiobutton $widget.samplingArea.choice.vector -text "Select areas from the overlayed vector map" -relief flat -variable selection -value vector -width 40 -anchor w
+ #inserting select areas from the overlaid vector map
+ radiobutton $widget.samplingArea.choice.vector -text "Select areas from the overlaid vector map" -relief flat -variable selection -value vector -width 40 -anchor w
pack $widget.samplingArea.choice.whole $widget.samplingArea.choice.regions $widget.samplingArea.choice.units $widget.samplingArea.choice.window $widget.samplingArea.choice.vector
} else {
pack $widget.samplingArea.choice.whole $widget.samplingArea.choice.regions $widget.samplingArea.choice.units $widget.samplingArea.choice.window
@@ -172,8 +172,8 @@
frame .newConf.frame -relief flat
pack .newConf.frame -side top -fill y -anchor center
- set names {{} {Configuration file name:} {Raster map to use to select areas:} {[Vector map to overlay:]}\
- {[Site file to overlay:]} }
+ set names {{} {Configuration file name:} {Raster map to use to select areas:} {[Vector areas map to overlay:]}\
+ {[Vector points map to overlay:]} }
label .newConf.frame.label1 -text [lindex $names 1] -anchor e
entry .newConf.frame.entry1 -width 35 -textvariable env(CONF)
grid .newConf.frame.label1 .newConf.frame.entry1 -sticky ew -pady 2 -padx 1
@@ -203,15 +203,15 @@
# insert buttons
frame .newConf.buttons -relief flat
pack .newConf.buttons -side bottom -anchor center -pady 2
- button .newConf.buttons.save -text "Save settings" -state disabled -command {
+ button .newConf.buttons.save -text "3. Save settings" -state disabled -command {
saveSettings .newConf
}
- button .newConf.buttons.s_area -text "Setup sampling areas" -state disabled -command {
+ button .newConf.buttons.s_area -text "2. Setup sampling areas" -state disabled -command {
setupSamplingArea .newConf
.newConf.buttons.save configure -state active
.newConf.buttons.s_area configure -state disabled
}
- button .newConf.buttons.s_frame -text "Setup sampling frame" -command {
+ button .newConf.buttons.s_frame -text "1. Setup sampling frame" -command {
setupSamplingFrame .newConf
.newConf.buttons.s_frame configure -state disabled
}
@@ -239,7 +239,7 @@
frame $widget.newUni.button
pack $widget.newUni.button -side left -anchor w
#buttons
- button $widget.newUni.button.b2 -text " Use keyboard to enter sampling units dimension " -width 50 -command {
+ button $widget.newUni.button.b2 -text " Use keyboard to define sampling units dimension " -width 50 -command {
setKeyboardUnit
$setSampleUnits.newUni.button.b2 configure -state disabled
$setSampleUnits.newUni.button.b3 configure -state disabled
@@ -273,7 +273,7 @@
frame $widget.newWin.button
pack $widget.newWin.button -side left -anchor w
#buttons
- button $widget.newWin.button.b2 -text " Use keyboard to enter moving window dimension " -width 50 -command {
+ button $widget.newWin.button.b2 -text " Use keyboard to define moving window dimension " -width 50 -command {
setKeyboardWindow
$setMovWindow.newWin.button.b2 configure -state disabled
$setMovWindow.newWin.button.b3 configure -state disabled
@@ -366,8 +366,8 @@
wm title .removeconf "\[r.li.setup\] Remove Window"
# new top label
- label .removeconf.topLabel -text "Are You sure to remove the ' $selection ' file ?"
- pack .removeconf.topLabel -side top
+ label .removeconf.topLabel -text "Are you sure to remove the '$selection' file ?"
+ pack .removeconf.topLabel -side top -pady 10 -padx 10
# create new frame
frame .removeconf.buttons -relief flat
@@ -377,8 +377,7 @@
button .removeconf.buttons.y -text "Yes" -width 8 -command {
if { [ catch { exec rm $env(HOME)/.grass7/r.li/$selection } ] } then {
tk_messageBox -message "'$selection' Not deleted" -type ok -icon error} else {
- #annoying "deleted" messageBox
- #tk_messageBox -message "$selection deleted" -type ok
+ tk_messageBox -message "'$selection' deleted." -type ok
openDir .files "~/.grass7/r.li"
destroy .removeconf}
}
@@ -386,7 +385,7 @@
# create no button
button .removeconf.buttons.n -text "No" -width 8 -command { destroy .removeconf
openDir .files "~/.grass7/r.li"}
- grid .removeconf.buttons.y .removeconf.buttons.n
+ grid .removeconf.buttons.y .removeconf.buttons.n -padx 2 -pady 10
}
}
Modified: grass/trunk/raster/r.li/r.li.setup/r.li.setup.procedures.tcl
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/r.li.setup.procedures.tcl 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/r.li.setup.procedures.tcl 2014-02-09 06:16:50 UTC (rev 58965)
@@ -7,8 +7,8 @@
#update sample frame environment variables
proc updateSF_Environment { } {
global env
- exec g.region rast=$env(RASTER)
- exec g.region -g > $env(TMP).tmp
+ exec g.region rast=$env(RASTER)
+ exec g.region -g > $env(TMP).tmp
set n [ exec cat $env(TMP).tmp | grep "n=" | cut -f2 -d= ]
set s [ exec cat $env(TMP).tmp | grep "s=" | head -n 1 | cut -f2 -d= ]
set w [ exec cat $env(TMP).tmp | grep "w=" | cut -f2 -d= ]
@@ -26,18 +26,18 @@
file delete $env(TMP).tmp
#debug line
#tk_messageBox -message "$env(SF_N)|$env(SF_S)|$env(SF_W)|$env(SF_E)|$env(SF_NSRES)|$env(SF_EWRES)|"
-
+
}
-
-
- #shows the instruction for drawing squares
+
+
+ #shows the instruction for drawing squares
proc squareInstruction {} {
toplevel .instruction
wm title .instruction "\[r.li.setup\] Commands"
#wm maxsize .instruction 300 200
frame .instruction.txt
- pack .instruction.txt
- text .instruction.txt.t -font Helvetica -height 12
+ pack .instruction.txt
+ text .instruction.txt.t -font Helvetica -height 12
.instruction.txt.t tag configure big -font {Helvetica 16 bold}
.instruction.txt.t tag configure normal -font {Helvetica 14}
.instruction.txt.t insert end "Mouse buttons functions \n \n" big
@@ -55,14 +55,14 @@
#.instruction.txt configure -state disabled
return .instruction
}
-
+
proc vectorInstruction {} {
toplevel .instruction
wm title .instruction "\[r.li.setup\] Commands"
#wm maxsize .instruction 300 200
frame .instruction.txt
- pack .instruction.txt
- text .instruction.txt.t -font Helvetica -height 12
+ pack .instruction.txt
+ text .instruction.txt.t -font Helvetica -height 12
.instruction.txt.t tag configure big -font {Helvetica 16 bold}
.instruction.txt.t tag configure normal -font {Helvetica 14}
.instruction.txt.t insert end "Mouse buttons functions \n \n" big
@@ -80,14 +80,14 @@
#.instruction.txt configure -state disabled
return .instruction
}
-
+
proc circleInstruction {} {
toplevel .instruction
wm title .instruction "\[r.li.setup\] Commands"
#wm maxsize .instruction 300 200
frame .instruction.txt
- pack .instruction.txt
- text .instruction.txt.t -font Helvetica -height 12
+ pack .instruction.txt
+ text .instruction.txt.t -font Helvetica -height 12
.instruction.txt.t tag configure big -font {Helvetica 16 bold}
.instruction.txt.t tag configure normal -font {Helvetica 14}
.instruction.txt.t insert end "Mouse buttons functions \n \n" big
@@ -116,15 +116,15 @@
pack .fileBrowser.top -side top -fill y -anchor center
listbox .fileBrowser.top.listbox -selectmode single
openDir .fileBrowser.top.listbox $path
- pack .fileBrowser.top.listbox -expand 1 -fill both -padx 7 -pady 7
+ pack .fileBrowser.top.listbox -expand 1 -fill both -padx 7 -pady 7
#browser buttons
frame .fileBrowser.buttons
pack .fileBrowser.buttons -side bottom -pady 2 -anchor center
button .fileBrowser.buttons.open -text "Open" -command {set selection [fileSelect .fileBrowser .fileBrowser.top.listbox $p_entry]}
pack .fileBrowser.buttons.open
-
+
}
-
+
proc fileSelect {widget listbox entry} {
set selection [$listbox get [$listbox curselection]]
switch [file type $selection] {
@@ -137,10 +137,10 @@
}
}
}
-
-
-
- #Open the specified directory
+
+
+
+ #Open the specified directory
proc openDir {listbox newpath} {
catch {cd $newpath}
$listbox delete 0 end
@@ -174,12 +174,12 @@
} else {
set ins [squareInstruction]
tkwait window $ins
- catch { exec $env(F_PATH)/square_mouse_selection.sh raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$tmp.tmp }
+ catch { exec $env(F_PATH)/square_mouse_selection.sh raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$tmp.tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $tmp.tmp | grep "SQUAREAREA" | cut -f1 -d\ ]}
if { $ok == "SQUAREAREA" } then {
#sampling frame accepted
- set start [exec cat $tmp.tmp | grep "START" | cut -f2 -d\ ]
+ set start [exec cat $tmp.tmp | grep "START" | cut -f2 -d\ ]
scan $start %f|%f|%f|%f|%f|%f s_n s_s s_e s_w s_nres s_sres
set square [exec cat $tmp.tmp | grep "SQUAREAREA" | cut -f2 -d\ ]
#resolution north-south
@@ -191,11 +191,11 @@
set env(SF_S) $s
set env(SF_E) $e
set env(SF_W) $w
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
# calulating area coordinates
- set env(SF_Y) [expr abs(round(($s_n - $n) / $nres)) ]
- set env(SF_X) [expr abs(round(($s_w - $w) / $sres)) ]
+ set env(SF_Y) [expr abs(round(($s_n - $n) / $nres)) ]
+ set env(SF_X) [expr abs(round(($s_w - $w) / $sres)) ]
set env(SF_RL) [expr abs(round(($n - $s) / $nres)) ]
set env(SF_CL) [expr abs(round(($e - $w) / $sres)) ]
set env(SF_NSRES) $nres
@@ -206,12 +206,12 @@
set cl [ expr double($env(SF_CL)) / double($cols) ]
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
- exec echo "SAMPLINGFRAME $x|$y|$rl|$cl" >> $tmp.set
+ exec echo "SAMPLINGFRAME $x|$y|$rl|$cl" >> $tmp.set
tk_messageBox -message "Selected area set as sampling frame" -type ok
file delete $tmp.tmp
$button configure -state disabled
} else {
- tk_messageBox -message "Warning sampling frame not set" -type ok -icon warning
+ tk_messageBox -message "Warning: sampling frame not set" -type ok -icon warning
}
}
}
@@ -225,7 +225,7 @@
set tmp $env(TMP)
switch $selection {
whole {
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set x [expr double($env(SF_X)) / double($cols) ]
set y [expr double($env(SF_Y)) / double($rows) ]
@@ -246,8 +246,8 @@
vector {
tk_messageBox -message "WARNING: this configuration file will work only on $env(RASTER) raster map" -type ok -icon warning
#TODO change here
- if { $env(RASTER) != "" && $env(VECTOR) != "" && $env(CONF) != "" } then {
- catch { exec $env(F_PATH)/sample_area_vector.sh raster=$env(RASTER) vector=$env(VECTOR) conf=$env(TMP).set }
+ if { $env(RASTER) != "" && $env(VECTOR) != "" && $env(CONF) != "" } then {
+ catch { exec $env(F_PATH)/sample_area_vector.sh raster=$env(RASTER) vector=$env(VECTOR) sites=$env(SITE) conf=$env(TMP).set >@stdout 2>@stderr }
} else {
tk_messageBox -message "Please set configuration file name, raster map and vector file to overlay" -type ok -icon error
}
@@ -259,84 +259,84 @@
# defines sampling units distribuition
proc defineSamplingUnits {selec rl cl maskname} {
global env
- set tmp $env(TMP)
+ set tmp $env(TMP)
#da modificare qua per le proiezioni
switch $selec {
-
+
nonoverlapping {
- toplevel .dialog
+ toplevel .dialog
wm title .dialog " Random Nonoverlapping "
- wm minsize .dialog 300 150
-
+ wm minsize .dialog 300 100
+
frame .dialog.scale
pack .dialog.scale
- label .dialog.scale.label1 -text " What number of Sampling Units to use?"
+ label .dialog.scale.label1 -text "\n How many Sampling Units to use?"
entry .dialog.scale.e1 -width 5 -textvariable number1
- grid .dialog.scale.label1 .dialog.scale.e1 -padx 3
-
+ grid .dialog.scale.label1 .dialog.scale.e1 -padx 3
+
button .dialog.button -text " Ok " -command {
if { $number1!="" && ![catch { exec printf %i $number1 }]} then {
exec echo "RANDOMNONOVERLAPPING $number1" >> $env(TMP).set
- tk_messageBox -message "Sampling units distribuition set as Random Nonoverlapping" -type ok
+ tk_messageBox -message "Sampling units distribuition set to Random Nonoverlapping" -type ok
set number1 ""
destroy .dialog
} else {
tk_messageBox -message "Please type integer value" -type ok -icon error
- }
+ }
}
- pack .dialog.button
+ pack .dialog.button -pady 3
}
-
- contiguous {
+
+ contiguous {
exec echo "SYSTEMATICCONTIGUOUS " >> $env(TMP).set
- tk_messageBox -message "Sampling units distribuition set as Systematic Contiguous" -type ok
+ tk_messageBox -message "Sampling units distribuition set to Systematic Contiguous" -type ok
}
-
- noncontiguous {
- toplevel .dialog
+
+ noncontiguous {
+ toplevel .dialog
wm title .dialog " Systematic non contiguous "
wm minsize .dialog 300 150
-
+
frame .dialog.scale
pack .dialog.scale
label .dialog.scale.label1 -text " Insert distance between units"
entry .dialog.scale.e1 -width 5 -textvariable number1
grid .dialog.scale.label1 .dialog.scale.e1 -padx 3
-
+
button .dialog.button -text " Ok " -command {
if { $number1!="" && ![catch { exec printf %i $number1 }]} then {
exec echo "SYSTEMATICNONCONTIGUOUS $number1" >> $env(TMP).set
- tk_messageBox -message "Sampling units distribuition set as Systematic Non Contiguous" -type ok
+ tk_messageBox -message "Sampling units distribuition set to Systematic Non Contiguous" -type ok
set number1 ""
destroy .dialog
} else {
tk_messageBox -message "Please type integer value" -type ok -icon error
}
}
- pack .dialog.button
+ pack .dialog.button
}
-
- random {
- toplevel .dialog
+
+ random {
+ toplevel .dialog
wm title .dialog " Stratified Random "
wm minsize .dialog 300 150
-
+
frame .dialog.scale
pack .dialog.scale
label .dialog.scale.label1 -text " Insert number of row strates "
entry .dialog.scale.e1 -width 5 -textvariable number1
grid .dialog.scale.label1 .dialog.scale.e1 -padx 3
-
+
frame .dialog.scale2
pack .dialog.scale2
label .dialog.scale2.label2 -text " Insert number of column strates "
entry .dialog.scale2.e2 -width 5 -textvariable number2
grid .dialog.scale2.label2 .dialog.scale2.e2 -padx 3
-
+
button .dialog.button -text " Ok " -command {
if { $number1!="" && $number2!="" && ![catch { exec printf %i%i $number1 $number2 }]} then {
exec echo "STRATIFIEDRANDOM $number1|$number2" >> $env(TMP).set
- tk_messageBox -message "Sampling units distribuition set as Stratified random" -type ok
+ tk_messageBox -message "Sampling units distribuition set to Stratified random" -type ok
set number1 ""
destroy .dialog
} else {
@@ -345,8 +345,8 @@
}
pack .dialog.button
}
-
- sites {
+
+ sites {
if { $env(RASTER) == "" || $env(SITE) == "" } then {
tk_messageBox -message "Please set raster and site file names first" -icon error
} else {
@@ -367,7 +367,7 @@
#check if we have integers
tk_messageBox -message "Type integer values" -type ok -icon error
} else {
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set rl [expr double($number2) / double($rows) ]
set cl [expr double($number1) /double($cols) ]
@@ -380,14 +380,14 @@
tk_messageBox -message "Set all entries first" -type ok -icon error
}
}
- circle {
+ circle {
if { $number3 != "" } then {
if { [catch { exec printf %i $number3 }] } then {
#check if we have integers
tk_messageBox -message "Type integer values" -type ok -icon error
} else {
circleMask $number3 $maskname
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set rl [expr double($env(CIR_RL)) /double($rows)]
set cl [expr double($env(CIR_CL)) /double($cols)]
@@ -413,19 +413,19 @@
set ins [vectorInstruction]
tkwait window $ins
while { $i < $number } {
- catch { exec $env(F_PATH)/masked_area_selection.sh -f north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp }
+ catch { exec $env(F_PATH)/masked_area_selection.sh -f north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f1 -d\ ]}
if { $ok == "SAMPLEAREAMASKED" } then {
- #region accepted
+ #region accepted
incr i
set r_name [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f2 -d\ ]
set square [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f3 -d\ ]
scan $square %f|%f|%f|%f n s e w
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
- set abs_y [expr $env(SF_Y) + abs(round(($env(SF_N) - $n) / $env(SF_NSRES))) ]
- set abs_x [expr $env(SF_X)+ abs(round(($env(SF_W) - $w) / $env(SF_EWRES))) ]
+ set abs_y [expr $env(SF_Y) + abs(round(($env(SF_N) - $n) / $env(SF_NSRES))) ]
+ set abs_x [expr $env(SF_X)+ abs(round(($env(SF_W) - $w) / $env(SF_EWRES))) ]
set abs_rl [expr abs(round(($n - $s) / $env(SF_NSRES))) ]
set abs_cl [expr abs(round(($e - $w) / $env(SF_EWRES))) ]
#debug line
@@ -436,16 +436,16 @@
set cl [ expr double($abs_cl) / double($cols) ]
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
- exec echo "MASKEDSAMPLEAREA $x|$y|$rl|$cl|$r_name" >> $env(TMP).set
+ exec echo "MASKEDSAMPLEAREA $x|$y|$rl|$cl|$r_name" >> $env(TMP).set
tk_messageBox -message "Selected region saved as sampling area" -type ok
file delete $env(TMP).tmp
} else {
tk_messageBox -message "Please redraw region number $i" -type ok -icon warning
}
}
-
-
-
+
+
+
}
}
@@ -463,13 +463,13 @@
tk_messageBox -message "Please enter a raster map and a configuration file name first" -type ok -icon error
} else {
while { $i < $num } {
- catch { exec $env(F_PATH)/square_mouse_selection.sh -f north=$env(SF_N) south=$env(SF_S) east=$env(SF_E) west=$env(SF_W) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp }
+ catch { exec $env(F_PATH)/square_mouse_selection.sh -f north=$env(SF_N) south=$env(SF_S) east=$env(SF_E) west=$env(SF_W) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $env(TMP).tmp | grep "SQUAREAREA" | cut -f1 -d\ ]}
if { $ok == "SQUAREAREA" } then {
#sampling area accepted
incr i
- set start [exec cat $env(TMP).tmp | grep "START" | cut -f2 -d\ ]
+ set start [exec cat $env(TMP).tmp | grep "START" | cut -f2 -d\ ]
scan $start %f|%f|%f|%f|%f|%f s_n s_s s_e s_w s_nres s_sres
set square [exec cat $env(TMP).tmp | grep "SQUAREAREA" | cut -f2 -d\ ]
#resolution north-south
@@ -477,11 +477,11 @@
#resolution east-west
set sres ""
scan $square %f|%f|%f|%f|%f|%f n s e w nres sres
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
# calulating area coordinates
- set abs_y [expr abs(round(($s_n - $n) / $nres)) ]
- set abs_x [expr abs(round(($s_w - $w) / $sres)) ]
+ set abs_y [expr abs(round(($s_n - $n) / $nres)) ]
+ set abs_x [expr abs(round(($s_w - $w) / $sres)) ]
set abs_rl [expr abs(round(($n - $s) / $nres)) ]
set abs_cl [expr abs(round(($e - $w) / $sres)) ]
#debug line
@@ -492,12 +492,12 @@
set cl [ expr double($abs_cl) / double($cols) ]
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
- exec echo "SAMPLEAREA $x|$y|$rl|$cl" >> $env(TMP).set
+ exec echo "SAMPLEAREA $x|$y|$rl|$cl" >> $env(TMP).set
tk_messageBox -message "Selected area saved as sample area" -type ok
file delete $env(TMP).tmp
} else {
- tk_messageBox -message "Warning sampling area not set" -type ok -icon warning
- }
+ tk_messageBox -message "Warning: sampling area not set" -type ok -icon warning
+ }
}
}
}
@@ -507,19 +507,19 @@
set ins [circleInstruction]
tkwait window $ins
while { $i < $num } {
- catch { exec $env(F_PATH)/masked_area_selection.sh -f -c north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp }
+ catch { exec $env(F_PATH)/masked_area_selection.sh -f -c north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f1 -d\ ]}
if { $ok == "SAMPLEAREAMASKED" } then {
- #region accepted
+ #region accepted
incr i
set r_name [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f2 -d\ ]
set square [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f3 -d\ ]
scan $square %f|%f|%f|%f n s e w
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
- set abs_y [expr $env(SF_Y) + abs(round(($env(SF_N) - $n) / $env(SF_NSRES))) ]
- set abs_x [expr $env(SF_X)+ abs(round(($env(SF_W) - $w) / $env(SF_EWRES))) ]
+ set abs_y [expr $env(SF_Y) + abs(round(($env(SF_N) - $n) / $env(SF_NSRES))) ]
+ set abs_x [expr $env(SF_X)+ abs(round(($env(SF_W) - $w) / $env(SF_EWRES))) ]
set abs_rl [expr abs(round(($n - $s) / $env(SF_NSRES))) ]
set abs_cl [expr abs(round(($e - $w) / $env(SF_EWRES))) ]
#debug line
@@ -530,7 +530,7 @@
set cl [ expr double($abs_cl) / double($cols) ]
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
- exec echo "MASKEDSAMPLEAREA $x|$y|$rl|$cl|$r_name" >> $env(TMP).set
+ exec echo "MASKEDSAMPLEAREA $x|$y|$rl|$cl|$r_name" >> $env(TMP).set
tk_messageBox -message "Selection saved as sampling area" -type ok
file delete $env(TMP).tmp
} else {
@@ -539,12 +539,12 @@
}
}
}
-
+
}
#draw moving window with mouse
proc drawMouseWindow { sel } {
- global env
+ global env
#rectangular or circular window
switch $sel {
rectangle {
@@ -555,13 +555,13 @@
tk_messageBox -message "Please enter a raster map and a configuration file name first" -type ok -icon error
} else {
while { $i == 0 } {
- catch { exec $env(F_PATH)/square_mouse_selection.sh -f north=$env(SF_N) south=$env(SF_S) east=$env(SF_E) west=$env(SF_W) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp }
+ catch { exec $env(F_PATH)/square_mouse_selection.sh -f north=$env(SF_N) south=$env(SF_S) east=$env(SF_E) west=$env(SF_W) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $env(TMP).tmp | grep "SQUAREAREA" | cut -f1 -d\ ]}
if { $ok == "SQUAREAREA" } then {
#moving window accepted
incr i
- set start [exec cat $env(TMP).tmp | grep "START" | cut -f2 -d\ ]
+ set start [exec cat $env(TMP).tmp | grep "START" | cut -f2 -d\ ]
scan $start %f|%f|%f|%f|%f|%f s_n s_s s_e s_w s_nres s_sres
set square [exec cat $env(TMP).tmp | grep "SQUAREAREA" | cut -f2 -d\ ]
#resolution north-south
@@ -569,7 +569,7 @@
#resolution east-west
set sres ""
scan $square %f|%f|%f|%f|%f|%f n s e w nres sres
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
#calculating moving window width and length
set abs_rl [expr abs(round(($n - $s) / $nres)) ]
@@ -581,14 +581,14 @@
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
exec echo "MOVINGWINDOW" >> $env(TMP).set
- exec echo "SAMPLEAREA -1|-1|$rl|$cl" >> $env(TMP).set
+ exec echo "SAMPLEAREA -1|-1|$rl|$cl" >> $env(TMP).set
tk_messageBox -message "Moving window set" -type ok
file delete $env(TMP).tmp
} else {
tk_messageBox -message "Moving window not set" -type ok -icon warning
- }
+ }
}
- }
+ }
}
circle {
#circulars areas
@@ -596,16 +596,16 @@
set ins [circleInstruction]
tkwait window $ins
while { $i == 0 } {
- catch { exec $env(F_PATH)/masked_area_selection.sh -f -c north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp }
+ catch { exec $env(F_PATH)/masked_area_selection.sh -f -c north=$env(SF_N) south=$env(SF_S) west=$env(SF_W) east=$env(SF_E) raster=$env(RASTER) vector=$env(VECTOR) site=$env(SITE) conf=$env(TMP).tmp >@stdout 2>@stderr }
set ok ""
catch {set ok [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f1 -d\ ]}
if { $ok == "SAMPLEAREAMASKED" } then {
- #region accepted
+ #region accepted
incr i
set r_name [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f2 -d\ ]
set square [exec cat $env(TMP).tmp | grep "SAMPLEAREAMASKED" | cut -f3 -d\ ]
scan $square %f|%f|%f|%f n s e w
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set abs_rl [expr abs(round(($n - $s) / $env(SF_NSRES))) ]
set abs_cl [expr abs(round(($e - $w) / $env(SF_EWRES))) ]
@@ -616,20 +616,20 @@
#debug line
#tk_messageBox -message "$x|$y|$rl|$cl"
exec echo "MOVINGWINDOW" >> $env(TMP).set
- exec echo "MASKEDSAMPLEAREA -1|-1|$rl|$cl|$r_name" >> $env(TMP).set
+ exec echo "MASKEDSAMPLEAREA -1|-1|$rl|$cl|$r_name" >> $env(TMP).set
tk_messageBox -message "Moving window set" -type ok
file delete $env(TMP).tmp
} else {
tk_messageBox -message "Moving window not set" -type ok -icon warning
}
}
- }
+ }
}
}
#create a circle mask for the keyboard circle selection
proc circleMask { radius name} {
- global env
+ global env
exec g.region rast=$env(RASTER)
exec g.region -m > $env(TMP).tmp
set nsres [ exec cat $env(TMP).tmp | grep "nsres=" | cut -f2 -d= ]
@@ -638,7 +638,7 @@
set xcell [expr round((2 * $radius) / $ewres) ]
set ycell [expr round((2 * $radius) / $nsres) ]
#to create a good raster circle the center of the circle have to be
- #in the center of a cell, then we need an odd number of cells...
+ #in the center of a cell, then we need an odd number of cells...
if { [ expr $xcell % 2 ] == 0 } then {
incr xcell
}
@@ -653,33 +653,33 @@
set southEdge [expr double($env(SF_N) - ($ycell * $env(SF_NSRES)))]
#restrict region
exec g.region n=$env(SF_N) s=$southEdge e=$easthEdge w=$env(SF_W)
- set xcenter [exec g.region -c | grep "region center easting:" | cut -f2 -d: | tr -d " "]
- set ycenter [exec g.region -c | grep "region center northing:" | cut -f2 -d: | tr -d " "]
+ set xcenter [exec g.region -c | grep "center easting:" | cut -f2 -d: | tr -d " "]
+ set ycenter [exec g.region -c | grep "center northing:" | cut -f2 -d: | tr -d " "]
#debug line
#tk_messageBox -message "$xcenter , $ycenter $env(SF_N) $southEdge $env(SF_W) $easthEdge"
#creating circle
catch {exec r.circle -b output=$name coordinate=$xcenter,$ycenter max=$radius }
file delete $env(TMP).tmp
-}
+}
-#set sample units from a site file
+#set sample units from a site file
proc centerOverSites { rl cl name} {
- global env
+ global env
if { $env(SITE) == "" || $env(RASTER) == "" } then {
tk_messageBox -message "Please set raster and site file name first" -type ok -icon error
} else {
#raster boundaries
- exec g.region rast=$env(RASTER)
- exec g.region -g > $env(TMP).tmp
- set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
+ exec g.region rast=$env(RASTER)
+ exec g.region -g > $env(TMP).tmp
+ set rows [exec r.info map=$env(RASTER) | grep "Rows" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
set cols [exec r.info map=$env(RASTER) | grep "Columns" | tr -d " " | cut -f 2 -d: | cut -f 1 -d\| ]
- #create ascii site file
+ #create ascii site file
exec v.out.ascii input=$env(SITE) output=$env(TMP).asc format=point
- #counting points
+ #counting points
set num [exec cat $env(TMP).asc | grep -c "" ]
set i 0
-
+
# inserting point if they are into sample frame
while { $i < $num } {
incr i
@@ -696,7 +696,7 @@
}
if { $ok == "TRUE" } then {
#the point is into sample frame
- #calculating what cell contains this point
+ #calculating what cell contains this point
set p_c [expr int( abs($x - $env(SF_W)) / $env(SF_EWRES))]
set p_r [expr int( abs($y - $env(SF_N)) / $env(SF_NSRES))]
#debug line
@@ -704,7 +704,7 @@
#the point is the center of the rectangle, we have to see if the rectangle is into sample frame
set rl_delta [expr int( $rl/2)]
set cl_delta [expr int( $cl/2)]
- set n_diff [expr ($p_r - $rl_delta) - $env(SF_Y)]
+ set n_diff [expr ($p_r - $rl_delta) - $env(SF_Y)]
set s_diff [expr ($env(SF_Y) + $env(SF_RL)) - ($p_r + $rl_delta +1) ]
set e_diff [expr ($env(SF_X) + $env(SF_CL)) - ($p_c + $cl_delta + 1) ]
set w_diff [expr ($p_c - $cl_delta) - $env(SF_X)]
@@ -723,33 +723,33 @@
}
}
}
-
+
}
- file delete $env(TMP).tmp $env(TMP).line $env(TMP).asc
-
- }
+ file delete $env(TMP).tmp $env(TMP).line $env(TMP).asc
+
+ }
}
proc saveSettings { widget } {
global env
-
+
#write the sample frame
- exec cat $env(TMP).set | grep "SAMPLINGFRAME " | tail -n 1 > $env(CONF)
+ exec cat $env(TMP).set | grep "SAMPLINGFRAME " | tail -n 1 > $env(CONF)
#write sampling areas
- catch { exec cat $env(TMP).set | grep "SAMPLEAREA " >> $env(CONF) }
+ catch { exec cat $env(TMP).set | grep "SAMPLEAREA " >> $env(CONF) }
catch { exec cat $env(TMP).set | grep "MASKEDSAMPLEAREA " >> $env(CONF) }
set overlay 0
catch { set overlay [ exec cat $env(TMP).set | grep "MASKEDOVERLAYAREA " -c ] }
if { $overlay != 0 } then {
- exec cat $env(TMP).set | grep "MASKEDOVERLAYAREA " >> $env(CONF)
+ exec cat $env(TMP).set | grep "MASKEDOVERLAYAREA " >> $env(CONF)
exec echo "RASTERMAP $env(RASTER)" >> $env(CONF)
exec echo "VECTORMAP $env(VECTOR)" >> $env(CONF)
}
#write disposition line
- catch { exec cat $env(TMP).set | grep "MOVINGWINDOW" >> $env(CONF) }
- catch { exec cat $env(TMP).set | grep "RANDOMNONOVERLAPPING " >> $env(CONF) }
+ catch { exec cat $env(TMP).set | grep "MOVINGWINDOW" >> $env(CONF) }
+ catch { exec cat $env(TMP).set | grep "RANDOMNONOVERLAPPING " >> $env(CONF) }
catch { exec cat $env(TMP).set | grep "SYSTEMATICCONTIGUOUS " >> $env(CONF) }
- catch { exec cat $env(TMP).set | grep "SYSTEMATICNONCONTIGUOUS " >> $env(CONF) }
+ catch { exec cat $env(TMP).set | grep "SYSTEMATICNONCONTIGUOUS " >> $env(CONF) }
catch { exec cat $env(TMP).set | grep "STRATIFIEDRANDOM " >> $env(CONF) }
file delete $env(TMP).set
destroy $widget
Modified: grass/trunk/raster/r.li/r.li.setup/r.li.windows.tcl
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/r.li.windows.tcl 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/r.li.windows.tcl 2014-02-09 06:16:50 UTC (rev 58965)
@@ -153,7 +153,7 @@
label .kUni.scale.label4 -text " What radius size (in meters) for each sampling unit?" -state disabled
entry .kUni.scale.e4 -width 5 -textvariable number4 -state disabled
grid .kUni.scale.label4 .kUni.scale.e4 -pady 20 -padx 3
- label .kUni.scale.label5 -text " Name for the circle mask" -state disabled
+ label .kUni.scale.label5 -text " Name for the circle mask raster map" -state disabled
entry .kUni.scale.e5 -width 15 -textvariable maskname -state disabled
grid .kUni.scale.label5 .kUni.scale.e5 -padx 3
@@ -196,6 +196,7 @@
#check if we have integers
tk_messageBox -message "Type integer values or set raster map name" -type ok -icon error
} else {
+ set maskname "rli_circlemask_$maskname"
circleMask $number4 $maskname
defineSamplingUnits $selec $env(CIR_RL) $env(CIR_RL) $maskname
if { $selec != "sites" } then {
@@ -393,7 +394,7 @@
label .load.info.l1 -text "The sampling areas are defined only for $rname file"
pack .load.info.l1
set vname [exec cat $filename | grep "VECTORMAP " | cut -f2 -d\ ]
- label .load.info.l2 -text "The overlayed vector file is $vname"
+ label .load.info.l2 -text "The overlaid vector file is $vname"
pack .load.info.l2
} else {
#extract sample areas
Modified: grass/trunk/raster/r.li/r.li.setup/sample_area_vector.sh
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/sample_area_vector.sh 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/sample_area_vector.sh 2014-02-09 06:16:50 UTC (rev 58965)
@@ -20,10 +20,16 @@
#% type: string
#% gisprompt: old,vector,vector
#% key_desc: name
-#% description: Vector map where areas are defined
+#% description: Vector map containing areas
#% required: yes
#%end
#%option
+#% key: sites
+#% type: string
+#% description: Vector points map to overlay
+#% required: no
+#%end
+#%option
#% key: conf
#% type: string
#% key_desc: name
@@ -88,10 +94,11 @@
fi
done
-# open Xmonitor
-d.mon stop="$XMON"
-d.mon start="$XMON"
+#d.mon stop="$XMON" --quiet
+d.mon start="$XMON" --quiet
+# TODO: pause to offer a "resize xmon now" window since it will
+# be locked during the interactive selection.
f_path="$GISBASE/etc/r.li.setup"
@@ -100,41 +107,63 @@
# convert to raster and save the bounds to configuration file
##############################################################
-# using v.category instead of v.build with cdump
-v.category input="$GIS_OPT_vector" option=print | \
+# using v.category instead of v.build with cdump because v.build
+# needs fully qualified map name and is harder to parse.
+
+v.category input="$GIS_OPT_vector" type=centroid option=print | \
sort -n | uniq > "$TMP.cat"
+NUM_CATS=`wc -l < "$TMP.cat"`
+
+if [ "$NUM_CATS" -gt 30 ] ; then
+ g.message -w "<$GIS_OPT_vector> contains $NUM_CATS areas. Manual selection may be time consuming."
+ # TODO: d.menu [Continue][Abort] on screen display
+elif [ "$NUM_CATS" -eq 0 ] ; then
+ g.message -w "<$GIS_OPT_vector> doesn't contain any areas. Aborting selection."
+ # TODO: d.menu [Ok] on screen display
+fi
+
# crop away @mapset part, if present
input_vector=`echo "$GIS_OPT_vector" | cut -d'@' -f 1`
# process each feature in the vector that has a cat
+i=0
while read CAT ; do
- # skip blank lines..
+ # skip blank lines.. (shouldn't be any)
if [ -z "$CAT" ] ; then
continue
fi
+ i=`expr $i + 1`
+
# Temporary vector map to store an individual feature from the input vector
# It will be removed at the end of the iteration.
EXTRACT="tmp_$$_${input_vector}_${CAT}"
v.extract input="$GIS_OPT_vector" output="$EXTRACT" \
- type=point,line,centroid,area \
- new=-1 -d list="$CAT" # where="CAT = $CAT"
+ type=area new=-1 -d list="$CAT" --quiet
# set region with raster resolution
g.region vect="$EXTRACT" align="$GIS_OPT_raster"
d.erase
- d.rast -o "$GIS_OPT_raster"
+ d.rast -o "$GIS_OPT_raster" --quiet
# render extracted vector map (prehaps fcolor=none for areas?)
- d.vect "$EXTRACT"
+ d.vect "$EXTRACT" type=boundary width=2
+ if [ -n "$GIS_OPT_SITES" ] ; then
+ d.vect map="$GIS_OPT_SITES" color=black fcolor=black size=9 icon=basic/circle
+ d.vect map="$GIS_OPT_SITES" color=red fcolor=red size=5 icon=basic/circle
+ fi
+
+ echo " Area $i of $NUM_CATS (category $CAT)" | \
+ d.text color=black size=2.5
+
# ask the user to analyse this vector and a name for raster in a Tcl GUI
name="$TMP.val" # where find the answer
- export name
+ export name input_vector CAT
# ask if it's ok, save 0,1 to "$name" temp file
"$GRASS_WISH" "$f_path/area_query"
@@ -143,15 +172,20 @@
r_name=`cat "$name" | cut -f2 -d' '`
# debug or needed?
- echo "$r_name"
+ g.message -d message="area_query map name (exit code 1) or exit code: $r_name"
if [ "$ok" -eq 1 ] ; then
#area selected, create mask
- v.to.rast input="$EXTRACT" output="$r_name" use=cat
+ mask_name="rli_samp_${r_name}"
+ v.to.rast input="$EXTRACT" output="$mask_name" use=cat --quiet
# save the region settings into the configuration file
eval `g.region -g`
- echo "MASKEDOVERLAYAREA $r_name|$n|$s|$e|$w" >> "$GIS_OPT_conf"
+ echo "MASKEDOVERLAYAREA $mask_name|$n|$s|$e|$w" >> "$GIS_OPT_conf"
+
+ elif [ "$ok" -eq -1 ] ; then
+ g.remove vect="$EXTRACT" --quiet
+ break
fi
#remove temporary vector map created from v.extract
@@ -160,7 +194,7 @@
done < "$TMP.cat"
-d.mon stop="$XMON"
+d.mon stop="$XMON" --quiet
# clean tmp files and restore region
Modified: grass/trunk/raster/r.li/r.li.setup/square_mouse_selection.sh
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/square_mouse_selection.sh 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/square_mouse_selection.sh 2014-02-09 06:16:50 UTC (rev 58965)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh
#
# This script selects a square area using the mouse
#
@@ -6,7 +6,7 @@
# Read the COPYING file that comes with GRASS for details.
#
-#%Module
+#%Module
#% description: Select a rectangular area
#%End
#%option
@@ -55,7 +55,7 @@
#% required: no
#%end
#%option
-#% key: west
+#% key: west
#% type: string
#% description: Western edge (use only with the 'f' flag)
#% required: no
@@ -93,7 +93,7 @@
g.remove region="tmp_rli_sq.$$" --quiet
fi
- rm -f "$TMP" "$TMP.var"
+ rm -f "$TMP" "$TMP.var"
}
trap "cleanup" 2 3 15
@@ -108,9 +108,7 @@
fi
done
-# open the Xmonitor
-d.mon stop="$XMON"
-d.mon start="$XMON"
+d.mon start="$XMON" --quiet
# setup internal region
@@ -135,12 +133,13 @@
e="$GIS_OPT_east" w="$GIS_OPT_west"
fi
-d.rast -o map="$GIS_OPT_raster"
+d.rast -o map="$GIS_OPT_raster" --quiet
if [ -n "$GIS_OPT_vector" ] ; then
- d.vect map="$GIS_OPT_vector"
+ d.vect map="$GIS_OPT_vector" type=area fcolor=none width=2
fi
-if [ -n "$GIS_OPT_site" ] ; then
+if [ -n "$GIS_OPT_site" ] ; then
+ d.vect map="$GIS_OPT_site" color=black fcolor=black size=9 icon=basic/circle
d.vect map="$GIS_OPT_site" color=red fcolor=red size=5 icon=basic/circle
fi
@@ -156,6 +155,7 @@
#EOF
######
+# note if user right clicks to quit without zooming the whole frame is used.
d.zoom
@@ -166,12 +166,17 @@
# ask if it's ok, save 0,1 to the "$name" tmp file
"$GRASS_WISH" "$f_path/square_query"
-read ok < "$TMP.var"
+if [ -e "$name" ] ; then
+ read ok < "$name"
+else
+ ok="-999"
+fi
if [ "$ok" -eq 0 ] ; then
echo "NO" >> "$GIS_OPT_conf"
elif [ "$ok" -eq 1 ] ; then
# write the square boundaries
+ # TODO: is range (0-1, 0-1) valid or a bug?
eval `g.region -g`
echo "SQUAREAREA $n|$s|$e|$w|$nsres|$ewres" >> "$GIS_OPT_conf"
else
@@ -179,7 +184,7 @@
fi
# close the Xmonitor
-d.mon stop="$XMON"
+d.mon stop="$XMON" --quiet
# clean tmp files and temporary region
cleanup
Modified: grass/trunk/raster/r.li/r.li.setup/square_query
===================================================================
--- grass/trunk/raster/r.li/r.li.setup/square_query 2014-02-09 06:05:24 UTC (rev 58964)
+++ grass/trunk/raster/r.li/r.li.setup/square_query 2014-02-09 06:16:50 UTC (rev 58965)
@@ -12,17 +12,17 @@
global env
wm title . "Select this area"
wm minsize . 250 100
- label .label -text "Is this area ok?"
+ label .label -text "\nIs this area ok?"
pack .label
frame .buttons
pack .buttons
set val ""
button .buttons.ok -text "Ok" -command {
- exec echo 1 > $env(name).var
+ exec echo 1 > $env(name)
destroy .
}
button .buttons.no -text "No" -command {
- exec echo 0 > $env(name).var
+ exec echo 0 > $env(name)
destroy .
}
- grid .buttons.ok .buttons.no
+ grid .buttons.ok .buttons.no -padx 3 -pady 3
More information about the grass-commit
mailing list