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