PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ main()

def raster2pgsql.main ( )

Definition at line 954 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(), ovdump.type, and wkblify_raster().

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