[postgis-commits] svn - r3858 - spike/wktraster/scripts
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Thu Mar 12 11:35:00 PDT 2009
Author: mloskot
Date: 2009-03-12 11:35:00 -0700 (Thu, 12 Mar 2009)
New Revision: 3858
Added:
spike/wktraster/scripts/rtpixdump.py
Modified:
spike/wktraster/scripts/pyrtreader.py
Log:
scripts: Added rtpixdump.py script to dump whole RASTER (bands/pixel values) in single field (row/column) to text. It is based on pyrtreader.py.
Property changes on: spike/wktraster/scripts/pyrtreader.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: spike/wktraster/scripts/rtpixdump.py
===================================================================
--- spike/wktraster/scripts/rtpixdump.py 2009-03-12 17:56:41 UTC (rev 3857)
+++ spike/wktraster/scripts/rtpixdump.py 2009-03-12 18:35:00 UTC (rev 3858)
@@ -0,0 +1,59 @@
+#! /usr/bin/env python
+#
+# $Id$
+#
+# Brute-force dump of all pixels of all bands in WKT Raster field/row to text.
+# This utility is handy for debugging purposes.
+#
+# Copyright (C) 2009 Mateusz Loskot <mateusz at loskot.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+###############################################################################
+# BEGIN CONFIGURATION
+rt_connstr = "dbname='test' host='localhost' user='mloskot'" # PostgreSQL format
+rt_table = "mytable"; # Name of table with RASTER column
+rt_column = "rast"; # Name of RASTER column in the table
+rt_where = None # SQL WHERE clause, leave None if you don't need
+# END CONFIGURATION
+###############################################################################
+import pyrtreader
+import sys
+
+if len(sys.argv) != 1:
+ print "Usage:"
+ print "1. Edit CONFIGURATION block"
+ print "2. Run rtpixdump.py without any input parameters"
+ sys.exit(1)
+
+def logit(msg):
+ sys.stderr.write("LOG - " + msg + "\n")
+
+try:
+ rast = pyrtreader.RasterReader(rt_connstr, rt_table, rt_column)
+ logit("Connected to %s" % rt_connstr)
+ logit("Raster width=%d, height=%d, bands=%d" %(rast.width, rast.height, rast.num_bands))
+
+ for band in range(1, rast.num_bands + 1):
+ sys.stderr.write("--- BAND %d ---------------------------------\n" % band)
+ for y in range(1, rast.height + 1):
+ scanline = ""
+ for x in range(1, rast.width + 1):
+ scanline += str(int(rast.get_value(band, x, y))) + '\t'
+ print scanline
+ print # Bands separator
+
+except pyrtreader.RasterError, e:
+ print "ERROR - ", e
Property changes on: spike/wktraster/scripts/rtpixdump.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
More information about the postgis-commits
mailing list