Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

Tiff: How to calculate Tiff Tag ModelPixelScaleTag (field 33550) and Field 34735

$
0
0

I have to manage a service which can return images in tiff format.

This service is requesting another WCS Service from which it receives the Image File without geo-referenced informations.

So i need to set those informations and particularly tiff Tag field 33550, 33922, 34735 & 34737.

With metadata from WFS service i can use the pootprint and the projection to calculate tiepoints & bounds…

i get field 34737 from my projection (string) ex: WGS 84 / Plate Carree (deprecated)|WGS 84|

i get field 33922 from the foot print (it seems to be always 0.000000,0.000000,0.000000,Upper Left X,Upper Left Y,0.000000

tag 34735: how to know the meaning of all those parameters?

ex: projection epsg:32662
1,1,0,7,1024,0,1,1,1025,0,1,1,1026,34737,35,0,2049,34737,7,35,2054,0,1,9102,3072,0,1,32662,3076,0,1,9001

ex: projection epsg:3857
1,1,0,7,1024,0,1,1,1025,0,1,1,1026,34737,25,0,2049,34737,7,25,2054,0,1,9102,3072,0,1,3857,3076,0,1,9001

how to calculate field 33550 (ModelPixelScaleTag). I supposed it should be based on bounds and pixel width and/or height of the image. But my results is a little bit different from what i should set. (in the wcf service i saved a tiff before and after projection, i used this image (TiffInfo) to check what i have to set in the second service).

Do someone could explain me how to manage & set those fields? (particularly field 33550 & 34735)

TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFF Directory at offset 0x8 (8)
  Image Width: 448 Image Length: 418
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Extra Samples: 1<assoc-alpha>
  Samples/Pixel: 4
  Rows/Strip: 4
  Planar Configuration: single image plane
  Tag 33550: 155.783428,155.783428,0.000000
  Tag 33922: 0.000000,0.000000,0.000000,-1824666.305496,1276523.665790,0.000000
  Tag 34735: 1,1,0,7,1024,0,1,1,1025,0,1,1,1026,34737,35,0,2049,34737,7,35,2054,

0,1,9102,3072,0,1,32662,3076,0,1,9001
Tag 34737: WGS 84 / Plate Carree (deprecated)|WGS 84|

Update – more details:

My problematic is:

In one hand I have the image file (stream) associated to a Segment comming from a WCS Service. This image has been reprojected (if requested), but i only get the image without any geo-referenced informations.

In Second hand I have meta-data for this Segment (coming from a WFS Service). Those meta-data include wktBounds, wktCenter, wktFootPrint of the segment in WGS84.

In third hand I have request information –> projection

At the moment when a user requests for tiff Image, the service works with WGS84 tiff Image and set following tifftags:

                        // Referring to TiffInfo need to set
                        // Tag 34264 - TiePoints used to georeference image file
                        // Tag 34735 - fixed value associated to WGS 84 spatial reference system
                        // Tag 34736 - Ellipsoïd/Spheroid associated to the spatial reference system
                        // Tag 34737 - Name of spatial reference system

                        if (tiePoints != null)
                        {
                            val34264[0] = tiePoints[0];
                            val34264[1] = tiePoints[2];
                            val34264[3] = tiePoints[4];
                            val34264[4] = tiePoints[1];
                            val34264[5] = tiePoints[3];
                            val34264[7] = tiePoints[5];
                            tif.SetField((TiffTag)34264, val34264);
                        }

                        short[] val34735 = { 1, 1, 0, 7, 1024, 0, 1, 2, 1025, 0, 1, 1, 2048, 0, 1, 4326, 2049, -30799, 7, 0, 2054, 0, 1, 9102, 2057, -30800, 1, 1, 2059, -30800, 1, 0 };
                        tif.SetField((TiffTag)34735, val34735);

                        double[] val34736 = { 298.257223563, 6378137 };
                        tif.SetField((TiffTag)34736, val34736);

                        tif.SetField((TiffTag)34737, "WGS 84|");

The result is that the browser download the geotiff image.

Now i’m trying to adapt this for other projections (3857 and 32662) and calculate TiffTag Fields based on the meta-data of the genuine segment.

Best regards,
Christophe.


Viewing all articles
Browse latest Browse all 397

Trending Articles