RasterLite2 - problems with a specific srid and faulty result with RL2_LoadRastersFromDir

50 views
Skip to first unread message

mj10777

unread,
Jul 2, 2015, 6:42:22 AM7/2/15
to spatiali...@googlegroups.com
While working on sql-scripts to use 'RL2_LoadRastersFromDir', I have run into unexpected problems
- the expected problems have been resolved
-- mainly importing images of different resolutions
---> use of mixed_resolutions= when creating the RasterCoverage

In the alpha version of RasterLite2, I had noticed that there were gaps in the tiles when using single images from a directory
- and I wanted to check if this has been resolved

The data used here can be downloaded at:
http://www.mj10777.de/public/download/rasterlite2/sandro/20150207.Dritte_Landesaufnahme.Toscana.tar.bz2

Dritte_Landesaufnahme.Toscana/
- directory with 9 GeoTiff (Area around Toscana), pus a gdal created Virtual files used to create a single image
--> 1904.30_44_Ravenna.200000.4805.tif
      the original image was faulty (scan error) a small portion at the bottom is missing
--> Each image is 1x1 degree using srid=4805 [MGI (Ferro), Militar_Geographische_Institut_Ferro]
sql/
- the sql scripts used for 
-- RL2_LoadRastersFromDir
-- RL2_LoadRaster
- the created db's from the sql_scripts
-- dritte_landesaufnahme_toscana.db
-- dritte_landesaufnahme_toscana_dir.db

gdal_commands.txt
- gdal commands used to create an single image from the 9 GeoTiffs

All GeoTifs show up correctly in QGIS

---
'RL2_LoadRastersFromDir'
- I am very sure that this as been done correctly
-- the following command show the expected results

rl2tool LIST --db-path dritte_landesaufnahme_toscana.db --coverage "dritte_landesaufnahme_toscana"
rl2tool LIST --db-path dritte_landesaufnahme_toscana_dir.db --coverage "dritte_landesaufnahme_toscana_dir"

- shows for the image number 6:
-------------------------------------------------------------------------------
              Section: (6) 1905.29_44_Florenz.200000.4805
-------------------------------------------------------------------------------
        Size (pixels): 4192 x 4192
           Input Path: *** unknowon ***
     LowerLeft corner: X=28.50 Y=43.50
    UpperRight corner: X=29.50 Y=44.50
         Center Point: X=29.00 Y=44.00
-------------------------------------------------------------------------------
- the (Ferro) positions are correct

---
Both databases show incorrectly in LibreWMS
"dritte_landesaufnahme_toscana_dir"
-- only 3 images can be seen, they are not correctly positioned
-- when zooming into the Top/Left image (1903.27_44_Genua)
--> Scale 1:344330 (Area Genova --> Speczia)
--- the positioning on the coast line is irregular
---- the irregularity changes with every zoom level

"dritte_landesaufnahme_toscana"
-- the whole image is shown
--- otherwise save effect

Same effect when WMS is called from QGIS.

Conclusion 01: the faulty rendering has nothing to do with 'RL2_LoadRastersFromDir'

---

I then attempted to export a portion of the coverage:

rl2tool EXPORT --db-path dritte_landesaufnahme_toscana.db --dst-path 1903.Genua.Spezia.tif  --compression JPEG --coverage "dritte_landesaufnahme_toscana" --center-x 27.5 --center-y 44.0 --resolution 0.000235960358660 --out-width 1000 --out-height 1000
--> failed without reason

SELECT RL2_GetMapImageFromRaster('dritte_landesaufnahme_toscana',BuildMBR(27.0,43.5,28.0,44.5),1000,1000,'default','image/tiff','#000000',0,80, 1) AS 'dritte_landesaufnahme_toscana.tif';
- image created in spatialite_gui
--> exported to tiff
---> dritte_landesaufnahme_toscana.tif
-----> shows expected area
---> dritte_landesaufnahme_toscana_dir.tif
-----> shows portion on the Genua map, Livorno portion is black

Conclusion 02: RL2_GetMapImageFromRaster does not retrieve image portions created with 'RL2_LoadRastersFromDir'

gdalinfo dritte_landesaufnahme_toscana.tif
- shows
Coordinate System is:
LOCAL_CS["MGI (Ferro)",
    UNIT["unknown",1]]

gdalinfo of 1903.27_44_Genua.200000.4805.tif
- original tiff file

Coordinate System is:
GEOGCS["MGI (Ferro)",
    DATUM["Militar_Geographische_Institut_Ferro",
        SPHEROID["Bessel 1841",6377397.155,299.1528128000033,
            AUTHORITY["EPSG","7004"]],
        TOWGS84[682,-203,480,0,0,0,0],
        AUTHORITY["EPSG","6805"]],
    PRIMEM["Ferro",-17.66666666666667],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4805"]]


SELECT srtext FROM spatial_ref_sys where srid=4805

GEOGCS["MGI (Ferro)",DATUM["Militar_Geographische_Institut_Ferro",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[682,-203,480,0,0,0,0],AUTHORITY["EPSG","6805"]],PRIMEM["Ferro",-17.66666666666667,AUTHORITY["EPSG","8909"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4805"]]

To make sure that spatialite_gui, when exporting to a tiff file from a RasterLite2 query
- I did the same for a Solder Berlin image

rl2tool EXPORT --db-path 1910.berlin_data.db --dst-path 1811.Rote_Rathaus.jpeg.tif  --compression JPEG --coverage 1811.berlin_selter --center-x 25258.22999992637051 --center-y 21288.28000037543825  --resolution 0.475212 --out-width 7953 --out-height 5965 
SELECT RL2_GetMapImageFromRaster('1811.berlin_selter',BuildMBR(23368.549,19870.962,27147.909,22705.600),7953,5965,'default','image/tiff','#FFFFFF',0,80, 1) AS '1811.Rote_Rathaus';

and the results of gdalinfo look the same to me.

Conclusion 03: somehow the srid is not being correctly used when reading the created database.

--
Final conclusion:
- there are 2 errors here
- I will try this with some images of 'Soldner Berlin', to see if there is a difference

(we just has a 5 min. power out, just after writing 'Conclusion 03' - for us it is a 'hot' day)

Mark



mj10777

unread,
Jul 2, 2015, 8:01:21 AM7/2/15
to spatiali...@googlegroups.com

- I will try this with some images of 'Soldner Berlin', to see if there is a difference


RL2_LoadRastersFromDir worked without any problem:

---
Step 01:

rl2sniff -dir ../Berlin_Zentrum
..
image_format MD5_checksum image_path width height sample_type pixel_type bands no_data compression srid x_resolution y_resolution min_x min_y max_x max_y
GeoTIFF Berlin_Zentrum/1932.423C_42338.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 22400.0 19600.0 24000.0 22000.0
GeoTIFF Berlin_Zentrum/1935.423B_42368.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 24000.0 22000.0 25600.0 24400.0
GeoTIFF Berlin_Zentrum/1931.414B_41458.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 19200.0 17200.0 20800.0 19600.0
GeoTIFF Berlin_Zentrum/1940.423D_42318.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 25600.0 19600.0 27200.0 22000.0
GeoTIFF Berlin_Zentrum/1935.423B_42358.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 25600.0 22000.0 27200.0 24400.0
GeoTIFF Berlin_Zentrum/1934.424D_42418.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 19200.0 19600.0 20800.0 22000.0
GeoTIFF Berlin_Zentrum/1936.423A_42388.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 20800.0 22000.0 22400.0 24400.0
GeoTIFF Berlin_Zentrum/1931.424B_42468.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 17600.0 22000.0 19200.0 24400.0
GeoTIFF Berlin_Zentrum/1931.424B_42458.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 19200.0 22000.0 20800.0 24400.0
GeoTIFF Berlin_Zentrum/1940.423D_42328.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 24000.0 19600.0 25600.0 22000.0
GeoTIFF Berlin_Zentrum/1935.413A_41378.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 22400.0 17200.0 24000.0 19600.0
GeoTIFF Berlin_Zentrum/1931.414B_41468.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 17600.0 17200.0 19200.0 19600.0
GeoTIFF Berlin_Zentrum/1934.424D_42428.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 17600.0 19600.0 19200.0 22000.0
GeoTIFF Berlin_Zentrum/1933.413A_41388.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 20800.0 17200.0 22400.0 19600.0
GeoTIFF Berlin_Zentrum/1934.413B_41368.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 24000.0 17200.0 25600.0 19600.0
GeoTIFF Berlin_Zentrum/1936.423A_42378.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 22400.0 22000.0 24000.0 24400.0
GeoTIFF Berlin_Zentrum/1935.413B_41358.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 25600.0 17200.0 27200.0 19600.0
GeoTIFF Berlin_Zentrum/1932.423C_42348.4000.3068.k4.tif 2610 3915 UINT8 RGB 3 DEFLATE 3068 0.613026819923 0.613026819923 20800.0 19600.0 22400.0 22000.0
 
With rl2sniff you can see the settings needed for RL2_CreateRasterCoverage
- all resolution (x + y) are the same (0.613026819923)
-- so 'mixed_resolutions' can remain 0
---> also ' RL2_PyramidizeMonolithic'
----> with mixed_resolutions=1 you would get the following message
         'MixedResolutions forbids a Monolithic Pyramid'

rl2sniff will also show the Data/Image type needed
- 'DEFLATE' shows how the source files were compressed
-- but we will use 'JPEG' instead
 (3068)

SELECT RL2_CreateRasterCoverage
(
 '1926.berlin_zentrum', -- chosen name of raster_coverage
 'UINT8', -- Data-Type of Image
 'RGB', -- Image-Type of Image
 3, -- Amount of Bands in the Image
 'JPEG',  -- chosen Compression to be used
 80, --- quality: only used for JPEG
 512, -- tile-size-x
 512, -- tile-size-y
 3068, -- srid of Image being read [Soldner Berlin]
 0.613026819923, -- Resolution_X / Pixel Size of gdalinfo (gdalbuildvrt -resolution highest)
 0.613026819923, -- Resolution_Y / Pixel Size of gdalinfo (gdalbuildvrt -resolution highest)
 NULL, -- no_data: will create default values [default_nodata(sample, pixel, num_bands)]
 0, --  strict_resolution: default 0
 0, -- mixed_resolutions: default 0 ; 1= allows mixed resolutions horz/vert_resolution=999999.999999
 0, -- section_paths: default 0
 0, -- section_md5: default 0
 0 -- section_summary: default 0
);


Mark



mj10777

unread,
Jul 2, 2015, 8:13:20 AM7/2/15
to spatiali...@googlegroups.com
(sorry, this was sent before completion) 

- '3068' the srid to use

---
Step 02:
 
SELECT RL2_CreateRasterCoverage
(
 '1926.berlin_zentrum', -- chosen name of raster_coverage
 'UINT8', -- Data-Type of Image
 'RGB', -- Image-Type of Image
 3, -- Amount of Bands in the Image
 'JPEG',  -- chosen Compression to be used
 80, --- quality: only used for JPEG
 512, -- tile-size-x
 512, -- tile-size-y
 3068, -- srid of Image being read [Soldner Berlin]
 0.613026819923, -- Resolution_X / Pixel Size of gdalinfo (gdalbuildvrt -resolution highest)
 0.613026819923, -- Resolution_Y / Pixel Size of gdalinfo (gdalbuildvrt -resolution highest)
 NULL, -- no_data: will create default values [default_nodata(sample, pixel, num_bands)]
 0, --  strict_resolution: default 0
 0, -- mixed_resolutions: default 0 ; 1= allows mixed resolutions horz/vert_resolution=999999.999999
 0, -- section_paths: default 0
 0, -- section_md5: default 0
 0 -- section_summary: default 0
);

---
Step 03: 
SELECT SE_UpdateRasterCoverageExtent(1);
- seems to be needed here, otherwise 'the DB "1926.berlin_zentrum.db" doesn't contain any valid Raster or Vector Coverage' will turn up.

--
Step 04:
SELECT RL2_SetRasterCoverageInfos('1926.berlin_zentrum','1926 - Berlin 414A+B, 414B, 423A-D, 424B+D - 1:200000','Berlin Zentrum. 9 Geo-Tiff Images 308 MB');
- setting a good text is useful, and will show up in the wms-client

---
Step 05:
SELECT RL2_LoadRastersFromDir('1926.berlin_zentrum','../Berlin_Zentrum','.tif');

1/18) Importing: ../Berlin_Zentrum/1932.423C_42338.4000.3068.k4.tif
...
18/18) Importing: ../Berlin_Zentrum/1932.423C_42348.4000.3068.k4.tif

---
Step 06:

SELECT RL2_PyramidizeMonolithic('1926.berlin_zentrum');

  ----------
    1926.berlin_zentrum: Monolithic Pyramid Level 1 - Row 1 of 3  successfully built
  ----------
    1926.berlin_zentrum: Monolithic Pyramid Level 1 - Row 2 of 3  successfully built
  ----------
    1926.berlin_zentrum: Monolithic Pyramid Level 1 - Row 3 of 3  successfully built
  ----------
    1926.berlin_zentrum: Monolithic Pyramid Level 2 - Row 1 of 1  successfully built
  ----------
    1926.berlin_zentrum: Monolithic Pyramid Level 3 - Row 1 of 1  successfully built
  ----------
    Monolithic Pyramid levels successfully built for: 1926.berlin_zentrum

---
Step 7:

SELECT SE_UpdateRasterCoverageExtent(1);
- again, otherwise wmlite will complain.
--

Time needed: 2 minutes and 20 seconds
- database size: 68.2 MB (the 18 GeoTifs: 332,9 MB)

---
Everything showed properly, without any gaps, in LibreWMS

Mark



Mark



Reply all
Reply to author
Forward
0 new messages