Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
fix a typo
Source Link
Jan Pisl
  • 746
  • 7
  • 22

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected it to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

How do I write a raster file to SQLite?

Perhaps using a different command than CopyLayer?

I didn't find any such command here but maybe I just didn't know where to look.

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

How do I write a raster file to SQLite?

Perhaps using a different command than CopyLayer?

I didn't find any such command here but maybe I just didn't know where to look.

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected it to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

How do I write a raster file to SQLite?

Perhaps using a different command than CopyLayer?

I didn't find any such command here but maybe I just didn't know where to look.

deleted 73 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to copy Copying raster to SQLite using GDAL?

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

Question: How todo I write a raster file to SQLite? 

Perhaps using a different command than CopyLayer? 

I didn't find any such command here but maybe I just didn't know where to look..

Any help or tips as where to look would be highly appreciated!

How to copy raster to SQLite using GDAL

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

Question: How to write a raster file to SQLite? Perhaps using a different command than CopyLayer? I didn't find any such command here but maybe I just didn't know where to look..

Any help or tips as where to look would be highly appreciated!

Copying raster to SQLite using GDAL?

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

How do I write a raster file to SQLite? 

Perhaps using a different command than CopyLayer? 

I didn't find any such command here but maybe I just didn't know where to look.

Source Link
Jan Pisl
  • 746
  • 7
  • 22

How to copy raster to SQLite using GDAL

I want to copy a raster file into SQLite database. Previously, I did the same with vector data like this:

def store_vector_output(self, file_name, identifier):
    from osgeo import ogr
    drv = ogr.GetDriverByName("SQLite")
    dsc_out = drv.CreateDataSource(self.dblocation)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
    
    dsc_out.Destroy()
    dsc_in.Destroy()

With raster data, I expected to be similar:

def store_raster_output(self, file_name, identifier):
    from osgeo import gdal

    dsc_in = gdal.Open(file_name)
    drv = gdal.GetDriverByName("SQLite")
    dsc_out = drv.Create(self.dblocation, xsize=30, ysize=30)
    layer = dsc_out.CopyLayer(dsc_in.GetLayer(), identifier,
                              ['OVERWRITE=YES'])
 
    dsc_out.Destroy()
    dsc_in.Destroy()

However, in store_raster_output, dsc_in.GetLayer() is None. There are no layers in dsc_in (its datatype is <class 'osgeo.gdal.Dataset'>)

So, I tried to use dsc_in.CreateLayer("some_name") but that resulted in this:

ERROR 6: CreateLayer() not supported by this dataset.

Therer is also a method ReadRaster() but since I am using CopyLayer the argument must be of datatype layer.

Question: How to write a raster file to SQLite? Perhaps using a different command than CopyLayer? I didn't find any such command here but maybe I just didn't know where to look..

Any help or tips as where to look would be highly appreciated!