planetEarthReloaded
Not logged in

Back to RasterLite2 Tutorials index



Tutorial: building and testing the Planet Earth sample - full SQL

We've already seen on the previous tutorial how to create and populate the earth.sqlite DB using the command shell and rl2tool.
In this second example we'll perform yet again the same identical same task, but this time we'll use an alternative approach fully based on executing SQL statements.
So you'll start this tutorial by opening a command shell and then launching the standard sqlite3 CLI front-end tool.
$ export "SPATIALITE_SECURITY=relaxed"

$ sqlite3 earth2.sqlite
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
sqlite> .null NULL
sqlite> SELECT load_extension('mod_rasterlite2');
NULL
sqlite> SELECT load_extension('mod_spatialite');
NULL
sqlite> SELECT InitSpatialMetadata(1);
1
sqlite> SELECT CreateRasterCoveragesTable();
1
sqlite> SELECT CreateStylingTables();
1
sqlite>
sqlite> SELECT RL2_CreateCoverage('TrueMarble', 'UINT8', 'RGB', 3, 'JPEG', 80, 512, 512, 4326, 0.0166666666666667);
1
sqlite>
sqlite> SELECT RL2_LoadRaster('TrueMarble', 'TrueMarble.2km.21600x10800.tif');
------------------
Importing: TrueMarble.2km.21600x10800.tif
    Image Size (pixels): 21600 x 10800
                   SRID: 4326
       LowerLeft Corner: X=-180.00 Y=-90.00
      UpperRight Corner: X=180.00 Y=90.00
       Pixel resolution: X=0.01666666666666666 Y=0.01666666666666666
>> Image successfully imported in: 1 mins 03 secs
1
sqlite>
sqlite> SELECT RL2_CreateCoverage('NaturalEarth', 'UINT8', 'RGB', 3, 'JPEG', 80, 512, 512, 4326, 0.0166666666666667);
1
sqlite> SELECT RL2_LoadRaster('NaturalEarth', 'NE1_HR_LC_SR_W_DR.tif');
------------------
Importing: NE1_HR_LC_SR_W_DR.tif
    Image Size (pixels): 21600 x 10800
                   SRID: 4326
       LowerLeft Corner: X=-180.00 Y=-90.00
      UpperRight Corner: X=180.00 Y=90.00
       Pixel resolution: X=0.01666666666667 Y=0.01666666666667
>> Image successfully imported in: 2 mins 09 secs
1
sqlite> SELECT RL2_CreateCoverage('Etopo1', 'UINT8', 'RGB', 3, 'JPEG', 80, 512, 512, 4326, 0.0166666666666667);
1
sqlite> SELECT RL2_LoadRaster('Etopo1', 'color_etopo1_ice_full.tif');------------------
Importing: color_etopo1_ice_full.tif
    Image Size (pixels): 21600 x 10800
                   SRID: 4326
       LowerLeft Corner: X=-180.01 Y=-89.99
      UpperRight Corner: X=179.99 Y=90.01
       Pixel resolution: X=0.01666666666667 Y=0.01666666666667
>> Image successfully imported in: 2 mins 09 secs
1
sqlite> SELECT RL2_Pyramidize('TrueMarble');
1
sqlite> SELECT RL2_Pyramidize('NaturalEarth');
1
sqlite> SELECT RL2_Pyramidize('Etopo1');
1
sqlite> SELECT RL2_SetCoverageInfos('truemarble', 'TrueMarble 2km', 'worldwide synthetic collage of  Landsat cloud-free scenes');
1
sqlite> SELECT RL2_SetCoverageInfos('naturalearth', 'Natural Earth 1', 'worldwide land cover (Shaded Relief, Water and Drainages)');
1
sqlite> SELECT RL2_SetCoverageInfos('etopo1', 'Etopo1', 'NOAA Global Relief Model');
1
sqlite> .quit
$
Completing the final steps of this tutorial isn't at all difficult; you are just expected to repeat the same steps we've already commented in the previous paragraph, just adjusting the Coverage's name and the GeoTIFF pathname as appropriate.

  • in order to manage your RasterLite2 DB-files you can indifferently use rl2tool or an alternative approach purely based on executing SQL statements.
  • the final result will exactly be the same identical one in both cases: feel absolutely free to use the one or the other in the most flexible way, accordingly to your very specific individual preferences.
  • Useful hint: using some SQL script could eventually be a valuable resource in order to create and load very complex Raster Coverages in a completely automatic way.



Back to RasterLite2 Tutorials index