[gdal-dev] Can GDAL Access Raster File Stored as Blob in SQLite3 Database?

Even Rouault even.rouault at spatialys.com
Thu Nov 6 09:05:11 PST 2014


Le jeudi 06 novembre 2014 17:53:37, Jema Bingham a écrit :
> Even,
> 
> I can load the file to memory and then create a virtual file via C#.
> However, that is expensive to do for many rasters if the data I need is for
> a handful of pixels or even a single pixel per image.  Is there a way to
> link to the object on disk?

You would have to figure out the offset in the sqlite file, but that would assume 
that a blob is strictly contiguous. I'm not sure if sqlite offers such 
guarantee, and I'm afraid there's no way to know at which offset the blob is 
stored.
The only alternative is to tile your raster into reasonably small tiles (say 
256x256 pixels) so that fetching a blob is fast. That's basically what 
Rasterlite does.

I didn't react to your initial statement that Rasterlite cannot store different 
projections for each raster table, but I'm surprised that would be the case. 
And the below experiment actually would confirm that you can store different 
projections

$ gdal_translate foo.tif rasterlite:foo.sqlite,table=foo -a_srs EPSG:3857 -of 
rasterlite

$ gdal_translate foo.tif rasterlite:foo.sqlite,table=foo2 -a_srs EPSG:32631 -
of rasterlite

$ gdalinfo rasterlite:foo.sqlite,table=foo

Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],
    AUTHORITY["EPSG","3857"]]


$ gdalinfo rasterlite:foo.sqlite,table=foo2

Coordinate System is:
PROJCS["WGS 84 / UTM zone 31N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",3],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32631"]]


> 
> Thanks for that quick reply.

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list