View Ticket
Not logged in
Ticket Hash: 6e95dbcac98c8c5c2b1777a71d40dedd454a8453
Title: RL2_WriteGeoTiff: bank images with 1-BIT MONOCHROME, FAX4
Status: Open Type: Code_Defect
Severity: Critical Priority:
Subsystem: Resolution:
Last Modified: 2017-08-28 08:31:02
Version Found In: dev
User Comments:
mj10777 added on 2017-08-28 08:31:02:

In preparation for a QGIS QgsRasterLite2Provider, I am building a small Database with 4 RasterCoverages of the same 2000x2000 Meter area.

    1656 : 1-BIT MONOCHROME, FAX4
    1811 : UINT8 RGB, JPEG
    1910 : UINT8 RGB, JPEG
    2010 : 1-BIT MONOCHROME, FAX4

From existing RL2 Databases the attempt was mad to extract this are from the 4 with RL2_WriteGeoTiff.
For the UINT8 RGB, JPEG: no problem.
For the 1-BIT MONOCHROME, FAX4: the images are blank.

All 4 are exported from 1 script
- here the portion from the last image:
-- -- ---------------------------------- --
SELECT DateTime('now','localtime'),'ATTACH DATABASE ''../2010.berlin_k5.400_dpi.db'' AS db_import';
ATTACH DATABASE '../2010.berlin_k5.400_dpi.db' AS db_import;
-- -- ---------------------------------- --
SELECT DateTime('now'),'2010.alt_berlin_coelln_friedrichsweder: pixel_size_x['||round((26000.0-24000.0)/0.3175065154982885)||'] pixel_size_y['||round((22250.0-20250.0)/0.3174918146641513)||']';
-- -- ---------------------------------- --
-- gdal_translate 2010.Berlin.5000.3068.FAX4_MINISWHITE.400.tif -projwin 24000.0 22250.000 26000.0 20250.000 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif
-- gdalinfo 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif > 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif.info.txt
-- -- ---------------------------------- --
SELECT RL2_WriteGeoTiff
(
 -- The dbPrefix argument is intended to specify the ATTACHED-DB where the Coverage is expected to be found
 'db_import',
 -- chosen name of raster_coverage
 lower('2010.berlin_k5'),
  -- directory where the files to be loaded are stored
 '2010.alt_berlin_coelln_friedrichsweder.5000.3068.tif',
 -- image-size width,height (calculate)
 -- 2143.730401266
 CAST(round((26000.0-24000.0)/0.3175065154982885) AS INTEGER),
 -- 2144.134100369
 CAST(round((22250.0-20250.0)/0.3174918146641513)AS INTEGER),
 -- area to extract,
 BuildMbr
 (
  24000.0,22250.000, 26000.0,20250.000,
  3068
 ),
 -- resolution horz/x
 0.3175065154982885,
-- resolution vert/y
 0.3174918146641513,
 -- world-file 0=no ; 1=yes
 1,
 -- compression
 'FAX4',
-- tile-size  (of tif)
 512
);
-- -- ---------------------------------- --
SELECT DateTime('now','localtime'),'DETACH DATABASE ''../2010.berlin_k5.400_dpi.db'' AS db_import';
DETACH DATABASE db_import;
-- -- ---------------------------------- --
The shown gdal command for the same task (from the original tiff) returns correct results.
Note on the side:
When the extent is given and either
    image size or resolution
are given - the missing value should be calculated.
In most cases, people will give the extent and size
    they should not have to bother about the resolution
If no resolution or size is given (i.e. values are 0):
    The original resolution should be taken to calculate the size
    as I have done with this script
This was a part of my patch which was never looked into.