PostGIS  2.1.10dev-r@@SVN_REVISION@@
def raster2pgsql.main ( )

Definition at line 956 of file raster2pgsql.py.

References logit(), make_sql_create_gist(), make_sql_create_raster_overviews(), make_sql_create_table(), make_sql_drop_raster_table(), make_sql_vacuum(), parse_command_line(), and wkblify_raster().

956 def main():
957 
958  (opts, args) = parse_command_line()
959 
960  global VERBOSE
961  VERBOSE = opts.verbose
962 
963  global SUMMARY
964  SUMMARY = []
965 
966  saved_out = sys.stdout
967  if type(opts.output) is str:
968  filename = opts.output
969  opts.output = open(filename, "w")
970 
971  # BEGIN
972  opts.output.write('BEGIN;\n')
973 
974  # If overviews requested, CREATE TABLE raster_overviews
975  if opts.create_raster_overviews_table:
977  opts.output.write(sql)
978 
979  # Base raster schema
980  if opts.overview_level == 1:
981  # DROP TABLE
982  if opts.drop_table:
983  sql = make_sql_drop_raster_table(opts.table)
984  opts.output.write(sql)
985 
986  # CREATE TABLE
987  if opts.create_table and opts.overview_level == 1:
988  sql = make_sql_create_table(opts)
989  opts.output.write(sql)
990 
991  # INSERT
992  i = 0
993 
994  # Burn all specified input raster files into single WKTRaster table
995  gt = None
996  for infile in opts.raster:
997  filelist = glob.glob(infile)
998  assert len(filelist) > 0, "No input raster files found for '" + str(infile) + "'"
999 
1000  for filename in filelist:
1001  logit("MSG: Dataset #%d: %s\n" % (i + 1, filename))
1002 
1003  # Write raster data to WKB and send it to opts.output
1004  gt = wkblify_raster(opts, filename.replace( '\\', '/') , i, gt)
1005  i += 1
1006 
1007  # INDEX
1008  if opts.index and SUMMARY is not None:
1009  sql = make_sql_create_gist(SUMMARY[0][0], opts.column)
1010  opts.output.write(sql)
1011 
1012  # COMMIT
1013  opts.output.write('END;\n')
1014 
1015  # VACUUM
1016  if opts.vacuum and SUMMARY is not None:
1017  sql = make_sql_vacuum(SUMMARY[0][0])
1018  opts.output.write(sql)
1019 
1020  # Cleanup
1021  if opts.output != sys.stdout:
1022  sys.stdout = saved_out
1023 
1024  print "------------------------------------------------------------"
1025  print " Summary of GDAL to PostGIS Raster processing:"
1026  print "------------------------------------------------------------"
1027  if i == 1:
1028  m = '%d (%s)' % (i, infile)
1029  else:
1030  m = '%d' % i
1031  print "Number of processed raster files: " + m
1032  print "List of generated tables (number of tiles):"
1033  i = 0
1034  for s in SUMMARY:
1035  i += 1
1036  print "%d\t%s (%d)" % (i, s[0], s[1])
1037 
def parse_command_line()
Definition: raster2pgsql.py:80
def make_sql_drop_raster_table(table)
def make_sql_create_table
def make_sql_vacuum(table)
def make_sql_create_raster_overviews(options)
def logit(msg)
def make_sql_create_gist(table, column)

Here is the call graph for this function: