Skip to main content

Hello,


I am attempting to see if Sentinel Hub’s BYOC feature is a good fit for our use case. Unfortunately, I am unable to ingest some of my GeoTIFFs. It seems that BYOC fails on data from Umbra, a SAR imagery provider. The failure message is as follows:



Something is wrong with the geolocation info - TIFF is missing tag 33922, which defines the location point. Something is wrong with the geolocation info - TIFF is missing tag 33550, which defines the pixel scale.



These TIFFs are valid GeoTIFFs, and play nicely with GDAL and QGIS. However, the way the projection is defined appears to be different from some other GeoTIFFs. It has these tags:



Tag 34264: -0.015630,-0.341432,0.000000,409155.499183,-0.341432,0.015630,0.000000,1514995.763075,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000

Tag 34735: 1,1,0,7,1024,0,1,1,1025,0,1,1,1026,34781,22,0,2049,34781,7,22,2054,0,1,9102,3072,0,1,32638,3076,0,1,9001

Tag 34737: WGS 84 / UTM zone 38N|WGS 84|



I believe this is defining an affine transformation on the image data.


gdalinfo has no problem determining where this image is:


Corner Coordinates:
Upper Left ( 409155.499, 1514995.763) ( 44d 9'35.54"E, 13d42' 9.43"N)
Lower Left ( 404163.080, 1515224.305) ( 44d 6'49.31"E, 13d42'16.29"N)
Upper Right ( 408926.973, 1510003.686) ( 44d 9'28.51"E, 13d39'26.92"N)
Lower Right ( 403934.554, 1510232.228) ( 44d 6'42.31"E, 13d39'33.78"N)
Center ( 406545.026, 1512613.996) ( 44d 8' 8.92"E, 13d40'51.61"N)

However, Sentinel Hub cannot manage. Is there a way to work with this file, or would my only option be to reproject with something like gdalwarp? (Definitely not ideal.)

Hi,

I am sure you have already checked this, but does the image you are trying to ingest match all of the criteria set in the documentation?


Hello, yes, it does satisfy those criteria. Here is the full gdalinfo:


Driver: GTiff/GeoTIFF
Files: downloads/gray.tif
Size is 14621, 14622
Coordinate System is:
PROJCRS["WGS 84 / UTM zone 38N",
BASEGEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]],
CONVERSION["UTM zone 38N",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",45,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",0.9996,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",500000,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Navigation and medium accuracy spatial referencing."],
AREA["Between 42°E and 48°E, northern hemisphere between equator and 84°N, onshore and offshore. Armenia. Azerbaijan. Djibouti. Eritrea. Ethiopia. Georgia. Islamic Republic of Iran. Iraq. kazakhstan. Kuwait. Russian Federation. Saudi Arabia. Somalia. Türkiye (Turkey). Yemen."],
BBOXB0,42,84,48]],
ID "EPSG",32638]]
Data axis to CRS axis mapping: 1,2
GeoTransform =
409155.4991833474, -0.01563002989618997, -0.3414320005864762
1514995.763075314, -0.3414320005864814, 0.01563002989619013
Metadata:
AREA_OR_POINT=Area
TIFFTAG_RESOLUTIONUNIT=1 (unitless)
TIFFTAG_XRESOLUTION=1
TIFFTAG_YRESOLUTION=1
Image Structure Metadata:
INTERLEAVE=BAND
LAYOUT=COG
Corner Coordinates:
Upper Left ( 409155.499, 1514995.763) ( 44d 9'35.54"E, 13d42' 9.43"N)
Lower Left ( 404163.080, 1515224.305) ( 44d 6'49.31"E, 13d42'16.29"N)
Upper Right ( 408926.973, 1510003.686) ( 44d 9'28.51"E, 13d39'26.92"N)
Lower Right ( 403934.554, 1510232.228) ( 44d 6'42.31"E, 13d39'33.78"N)
Center ( 406545.026, 1512613.996) ( 44d 8' 8.92"E, 13d40'51.61"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Gray
Overviews: 7310x7311, 3655x3655, 1827x1827, 913x913, 456x456

Hi,

you are right that BYOC does not support the affine transform at the moment. Using GDAL Warp is a relatively safe bet to get to a format which works with the BYOC API.

Another option you could have is to modify the Tiff Tags directly using Python for example:

import tifftools

info = tifftools.read_tiff(file_path)
transform = info['ifds'][0]['tags'][34264]["data"]

info['ifds'][0]['tags'][33550] = {
'data': [transform[0], transform[0], 0],
'datatype': tifftools.Datatype.DOUBLE,
'count': 3
}
info['ifds'][0]['tags'][33922] = {
'data': [0, 0, 0, transform[3], transform[7], 0],
'datatype': tifftools.Datatype.DOUBLE,
'count': 6
}
del info['ifds'][0]['tags'][34264]

tifftools.write_tiff(info, 'test.tif')

Be aware that this only works if the affine transform does not specify any rotation and the resolution is the standard (negative res, positive res) i.e. the origin point defined in the affine transform is the top left point.

In this case I think the whole tiff is still written out again. I am unsure if this change of tags can be done in place with the tifftools library.

Edit: You might also want to try using tiffset from libtiff directly. It might not require a complete rewrite of the file.


Reply