Database Reference
In-Depth Information
(postgis_table_prefix, variable)
pg_ds =
ogr.Open(pg_connection_string, GA_Update )
pg_layer =
pg_ds.CreateLayer(table_name, srs = srs,
geom_type=ogr.wkbPoint,
options = [
'GEOMETRY_NAME=the_geom',
'OVERWRITE=YES', # this
will drop and recreate the table every
time
'SCHEMA=chp08',
])
print 'Table %s created.' %
table_name
# get georeference transformation
information
transform = sds.GetGeoTransform()
pixelWidth = transform[1]
pixelHeight = transform[5]
xOrigin = transform[0] +
(pixelWidth/2)
yOrigin = transform[3] -
(pixelWidth/2)
# 2. iterate subdataset bands and
append them to data
data = []
for b in range(1, bands+1):
band = sds.GetRasterBand(b)
band_data =
band.ReadAsArray(0, 0, cols, rows)
data.append(band_data)
# here we add the fields to
the table, a field for each band
# check datatype (Float32,
'Float64', ...)
Search WWH ::




Custom Search