[GRASS-SVN] r52111 - grass-promo/tutorials/batch_processing/earthquakes
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jun 17 01:40:09 PDT 2012
Author: hamish
Date: 2012-06-17 01:40:09 -0700 (Sun, 17 Jun 2012)
New Revision: 52111
Modified:
grass-promo/tutorials/batch_processing/earthquakes/README
grass-promo/tutorials/batch_processing/earthquakes/do_quakes_wintri.sh
Log:
merge in changes from adhoc
Modified: grass-promo/tutorials/batch_processing/earthquakes/README
===================================================================
--- grass-promo/tutorials/batch_processing/earthquakes/README 2012-06-17 08:18:38 UTC (rev 52110)
+++ grass-promo/tutorials/batch_processing/earthquakes/README 2012-06-17 08:40:09 UTC (rev 52111)
@@ -7,5 +7,9 @@
This is just a (working) example. You'll have to adjust the paths, etc. to match your needs.
+Currently running on the OSGeo Adhoc VM:
+ http://adhoc.osgeo.osuosl.org/grass/
+
+
HB Dec2010
Modified: grass-promo/tutorials/batch_processing/earthquakes/do_quakes_wintri.sh
===================================================================
--- grass-promo/tutorials/batch_processing/earthquakes/do_quakes_wintri.sh 2012-06-17 08:18:38 UTC (rev 52110)
+++ grass-promo/tutorials/batch_processing/earthquakes/do_quakes_wintri.sh 2012-06-17 08:40:09 UTC (rev 52111)
@@ -16,7 +16,9 @@
# of Colorado at Boulder.
#
# Earthquake data is downloaded from the USGS
-# http://neic.usgs.gov/neis/gis/bulletin.asc
+# http://neic.usgs.gov/neis/gis/bulletin.asc (defunct)
+# new1: http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt
+# new2: http://earthquake.usgs.gov/earthquakes/feed/csv/2.5/week
#
if [ -z "$GISBASE" ] ; then
@@ -24,6 +26,10 @@
exit 1
fi
+
+PROJ_SHORT_NAME=world_wintri
+WEB_DIR=/var/www/grass/earthquakes
+
#GRASS_PNGFILE=earthquakes.png
GRASS_PNGFILE=earthquakes.ppm
GRASS_WIDTH=900
@@ -34,19 +40,18 @@
export GRASS_WIDTH GRASS_HEIGHT GRASS_TRUECOLOR GRASS_PNG_COMPRESSION \
GRASS_VERBOSE GRASS_PNGFILE
-TMPDIR="/var/local/grass/tmp"
+TMPDIR="/var/tmp/grass"
if [ ! -d "$TMPDIR" ] ; then
mkdir -p "$TMPDIR"
fi
cd "$TMPDIR"
-# remove old stuff
-g.remove vect=recent_earthquakes --quiet
-
### download and import
-wget -nv -O "$TMPDIR/bulletin.tmp" http://neic.usgs.gov/neis/gis/bulletin.asc 2>&1
+wget -nv -O "$TMPDIR/bulletin.tmp" \
+ "http://neic.usgs.gov/neis/gis/bulletin.asc" 2>&1
+
if [ $? -ne 0 ] ; then
echo "Failed to download data from the USGS." >&2
exit 1
@@ -101,13 +106,18 @@
# how to do POW(x,n) in SQLite?
#v.db.update recent_earthquakes column=magn_energy value="POW(magnitude,10) * 1e-7" --verbose
-v.db.select recent_earthquakes column=cat,magnitude | awk -F'|' \
- '{printf("UPDATE recent_earthquakes SET magn_energy=%f WHERE cat=%d;\n", ($2^10)*1e-7, $1)}' | db.execute
+v.db.select -c recent_earthquakes column=cat,magnitude | awk -F'|' \
+ '{printf("UPDATE recent_earthquakes SET magn_energy=%f WHERE cat=%d;\n", ($2^10)*1e-7, $1)}' \
+ > "${PROJ_SHORT_NAME}_$$.sql"
+db.execute input="${PROJ_SHORT_NAME}_$$.sql"
+\rm "${PROJ_SHORT_NAME}_$$.sql"
# get the timestamp
-YMD=20`tail -n 1 "$INPUT" | cut -f1 -d,`
+#YMD=20`tail -n 1 "$INPUT" | cut -f1 -d,`
+YMD=20`cut -f1 -d, "$INPUT" | uniq | grep -v Date | sort | tail -n 1`
+
if [ `echo "$YMD" | wc -c` -ne 11 ] ; then
echo "Bad timestamp ($YMD). Using system date instead." >&2
YMD=`date +%Y/%m/%d`
@@ -115,9 +125,8 @@
### draw
-# LatLon:
+
#g.region n=90N s=90S w=25W e=25W res=0:24 # -p
-# Winkel Tripel:
g.region n=10035000 s=-10035000 w=-20070000 e=20070000 res=44600 # rows=450 cols=900
@@ -126,14 +135,12 @@
MAP=color_etopo1_ice_900
d.rgb r=$MAP.red at etopo1 g=$MAP.green at etopo1 b=$MAP.blue at etopo1
+
# d.rast -o usgs_logo
# d.rast -o grass_logo
d.font Vera
-echo "Earthquakes for the week ending $YMD" | \
- d.text at=1,2 color=60:60:60 size=3
-
echo "
.C red
Shallow
@@ -174,11 +181,16 @@
# magn^2.72
# wscale=0.01
+
+echo "Earthquakes for the week ending $YMD" | \
+ d.text at=1,2 color=60:60:60 size=3
+
+
sync
d.mon stop=PNG
sync
-IMG=/usr/local/grass/earthquakes/graphics/earthquakes_logo_overlay
+IMG=graphics/earthquakes_logo_overlay
#pngtopnm $IMG.png > $IMG.pnm
#pngtopnm -alpha $IMG.png > $IMG.pgm
pnmcomp -alpha $IMG.pgm $IMG.pnm earthquakes.ppm | \
@@ -193,13 +205,13 @@
#convert -geometry 75% -quality 85 earthquakes.png earthquakes_small.jpg
#convert -geometry 40% -quality 85 earthquakes.png earthquakes_tiny.jpg
+cp -f earthquakes.png "$WEB_DIR/earthquakes_wintri.png"
+
### cleanup and closeup
-#g.remove vect=recent_earthquakes --quiet
+g.remove vect=recent_earthquakes --quiet
rm -f "$INPUT"*
-#cp -f earthquakes.png earthquakes*.jpg /var/www/grass/
-cp earthquakes.png /var/www/grass/alternate_projections/earthquakes_wintri.png
# all done.
exit 0
More information about the grass-commit
mailing list