Open marjorieRobert opened 4 years ago
Hi @marjorieRobert
You are right, this information is currently not easily available. The GeoTIFFImage
class has the getGeoKeys
function which provides all parsed geo keys as per the GeoTIFF spec. It is possible, however, to get EPSG codes for some cases, e.g like we did in COG-Explorer: https://github.com/geotiffjs/cog-explorer/blob/master/src/components/mapview.jsx#L196
I always planned to implement some facilities to get the projection information of an image in proj, WKT or EPSG code format, but I never got around to do that as it is very complex, especially for corner cases.
I hope I could help you, and thanks for raising this issue.
Has this been fixed in geotiff.js now?
@howff There is no converter to proj format or WKT yet. But you can still use the solution described in the mentioned link if you have a specified CRS.
I'm using geotiff.js to visualize a geotiff file on a Openlayers'map. Here is my code : `const tiff = await GeoTIFF.fromBlob(file); const image = await tiff.getImage(); const data = await image.readRasters();
const geotiffLayer = new ol.layer.Image();
const rawBox = image.getBoundingBox(); const box = [rawBox[0],rawBox[1] - (rawBox[3] - rawBox[1]), rawBox[2], rawBox[1]]; const bands = await image.readRasters();
let the_canvas = document.createElement('canvas'); const plot = new plotty.plot({ canvas: the_canvas, data: bands[0], width: image.getWidth(), height: image.getHeight(), domain: [0,256], colorScale: 'earth' }); plot.render();
var imgSource = new ol.source.ImageStatic({ url: the_canvas.toDataURL("image/png"), imageExtent: box, imageSize : [image.getWidth(), image.getHeight()], projection: 'EPSG:2154' //here, I would like to get the projection of the geotiff })`
When I create the source of the layer, I've to put the projection of the geotiff file. Can you say me how can I get this projection? I've read the docs but didn't find it. Thanks