24 from __future__
import print_function
26 from optparse
import OptionParser
31 sys.stderr.write(
"LOG - " + msg +
"\n")
36 prs = OptionParser(version=
"%prog $Revision$",
37 usage=
"%prog -d <DB> -t <TABLE> [-c <COLUMN>]",
38 description=
"Brute-force dump of all pixel values of WKT Raster dataset")
39 prs.add_option(
"-d",
"--db", dest=
"db", action=
"store", default=
None,
40 help=
"PostgreSQL database connection string, required")
41 prs.add_option(
"-t",
"--table", dest=
"table", action=
"store", default=
None,
42 help=
"table with raster column [<schema>.]<table>, required")
43 prs.add_option(
"-c",
"--column", dest=
"column", action=
"store", default=
"rast",
44 help=
"raster column, optional, default=rast")
45 prs.add_option(
"-w",
"--where", dest=
"where", action=
"store", default=
None,
46 help=
"SQL WHERE clause to filter record - NOT IMPLEMENTED")
47 prs.add_option(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False,
48 help=
"be excessively verbose and useful for debugging")
50 (opts, args) = prs.parse_args()
53 prs.error(
"use -d option to specify database connection string")
54 if opts.table
is None:
55 prs.error(
"use -t option to specify raster table")
56 if opts.column
is None:
57 prs.error(
"use -c option to specify raster column in raster table")
60 VERBOSE = opts.verbose
63 logit(
"Connected to %s" % opts.db)
64 logit(
"Raster width=%d, height=%d, bands=%d" %(rast.width, rast.height, rast.num_bands))
66 for band
in range(1, rast.num_bands + 1):
67 logit(
"--- BAND %d ---------------------------------" % band)
68 sys.stderr.write(
"\n")
69 for y
in range(1, rast.height + 1):
71 for x
in range(1, rast.width + 1):
72 scanline +=
str(int(rast.get_value(band, x, y))) +
'\t'
RASTER driver (read-only)