[GRASS-SVN] r50813 - grass/trunk/temporal/tr.export
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 14 10:01:14 EST 2012
Author: huhabla
Date: 2012-02-14 07:01:13 -0800 (Tue, 14 Feb 2012)
New Revision: 50813
Modified:
grass/trunk/temporal/tr.export/test.tr.export.sh
grass/trunk/temporal/tr.export/tr.export.py
Log:
Export GRASS GIS raster color rules and readme.txt with content description
Modified: grass/trunk/temporal/tr.export/test.tr.export.sh
===================================================================
--- grass/trunk/temporal/tr.export/test.tr.export.sh 2012-02-14 10:23:30 UTC (rev 50812)
+++ grass/trunk/temporal/tr.export/test.tr.export.sh 2012-02-14 15:01:13 UTC (rev 50813)
@@ -1,4 +1,4 @@
-# This is a test to list raster maps of a space time raster dataset
+# Export of space time raster datasets
# We need to set a specific region in the
# @preprocess step of this test. We generate
@@ -27,8 +27,8 @@
t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test with input files" descr="A test with input files"
# The first @test
-tr.register -i input=precip_abs1 file="${n1}" start="2001-01-01" increment="1 months"
+t.register -i type=rast input=precip_abs1 file="${n1}" start="2001-01-01" increment="1 months"
tr.export input=precip_abs1 output=strds_export.tar.bz2 compression=bzip2 workdir=/tmp
-t.remove type=rast input=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
t.remove type=strds input=precip_abs1
Modified: grass/trunk/temporal/tr.export/tr.export.py
===================================================================
--- grass/trunk/temporal/tr.export/tr.export.py 2012-02-14 10:23:30 UTC (rev 50812)
+++ grass/trunk/temporal/tr.export/tr.export.py 2012-02-14 15:01:13 UTC (rev 50813)
@@ -75,6 +75,7 @@
proj_file_name = "proj.txt"
init_file_name = "init.txt"
+metadata_file_name = "metadata.txt"
read_file_name = "readme.txt"
list_file_name = "list.txt"
tmp_tar_file_name = "archive"
@@ -141,15 +142,24 @@
# Write the filename, the start_time and the end_time
list_file.write(string)
+ # Export the raster map with r.out.gdal as tif
out_name = name + ".tif"
-
- # Export the raster map with r.out.gdal
ret = grass.run_command("r.out.gdal", flags="c", input=name, output=out_name, format="GTiff")
if ret != 0:
shutil.rmtree(new_cwd)
tar.close()
grass.fatal(_("Unable to export raster map <%s>" % name))
+
+ tar.add(out_name)
+ # Export the color rules
+ out_name = name + ".color"
+ ret = grass.run_command("r.colors.out", map=name, rules=out_name)
+ if ret != 0:
+ shutil.rmtree(new_cwd)
+ tar.close()
+ grass.fatal(_("Unable to export color rules for raster map <%s>" % name))
+
tar.add(out_name)
list_file.close()
@@ -175,10 +185,24 @@
init_file.write(string)
init_file.close()
- read = grass.read_command("t.info", input=id)
+ metadata = grass.read_command("t.info", input=id)
+ metadata_file = open(metadata_file_name, "w")
+ metadata_file.write(metadata)
+ metadata_file.close()
+
read_file = open(read_file_name, "w")
read_file.write("This space time raster dataset was exported with tr.export of GRASS GIS 7\n")
- read_file.write(read)
+ read_file.write("\n")
+ read_file.write("Files:\n")
+ #123456789012345678901234567890
+ read_file.write(" *.tif -- GeoTIFF time series raster files\n")
+ read_file.write(" *.color -- GRASS GIS raster color rules\n")
+ read_file.write("%13s -- Projection information in PROJ.4 format\n" % (proj_file_name))
+ read_file.write("%13s -- GRASS GIS space time raster dataset information\n" % (init_file_name))
+ read_file.write("%13s -- Time series file, lists all maps by name with interval\n" % (list_file_name))
+ read_file.write(" time stamps in ISO-Format. Field separator is |\n")
+ read_file.write("%13s -- Projection information in PROJ.4 format\n" % (metadata_file_name))
+ read_file.write("%13s -- This file\n" % (read_file_name))
read_file.close()
# Append the file list
@@ -186,6 +210,7 @@
tar.add(proj_file_name)
tar.add(init_file_name)
tar.add(read_file_name)
+ tar.add(metadata_file_name)
tar.close()
os.chdir(old_cwd)
More information about the grass-commit
mailing list