PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ wkblify_raster()

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 915 of file raster2pgsql.py.

References get_gdal_geotransform(), and wkblify_raster_level().

Referenced by main().

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