PostGIS  2.1.10dev-r@@SVN_REVISION@@
def raster2pgsql.wkblify_raster (   options,
  infile,
  i,
  previous_gt = None 
)
Writes given raster dataset using GDAL features into HEX-encoded of
WKB for WKT Raster output.

Definition at line 917 of file raster2pgsql.py.

References get_gdal_geotransform(), and wkblify_raster_level().

Referenced by main().

917 def wkblify_raster(options, infile, i, previous_gt = None):
918  """Writes given raster dataset using GDAL features into HEX-encoded of
919  WKB for WKT Raster output."""
920 
921  assert infile is not None, "Input file is none, expected file name"
922  assert options.version == g_rt_version, "Error: invalid WKT Raster protocol version"
923  assert options.endian == NDR, "Error: invalid endianness, use little-endian (NDR) only"
924  assert options.srid >= -1, "Error: do you really want to specify SRID = %d" % options.srid
925 
926  # Open source raster file
927  ds = gdal.Open(infile, gdalc.GA_ReadOnly);
928  if ds is None:
929  sys.exit('Error: Cannot open input file: ' + str(infile))
930 
931  # By default, translate all raster bands
932 
933  # Calculate range for single-band request
934  if options.band is not None and options.band > 0:
935  band_range = ( options.band, options.band + 1 )
936  else:
937  band_range = ( 1, ds.RasterCount + 1 )
938 
939  # Compare this px size with previous one
940  current_gt = get_gdal_geotransform(ds)
941  if previous_gt is not None:
942  if previous_gt[1] != current_gt[1] or previous_gt[5] != current_gt[5]:
943  sys.exit('Error: Cannot load raster with different pixel size in the same raster table')
944 
945  # Generate requested overview level (base raster if level = 1)
946  summary = wkblify_raster_level(options, ds, options.overview_level, band_range, infile, i)
947  SUMMARY.append( summary )
948 
949  # Cleanup
950  ds = None
951 
952  return current_gt
953 
def get_gdal_geotransform(ds)
def wkblify_raster_level(options, ds, level, band_range, infile, i)

Here is the call graph for this function:

Here is the caller graph for this function: