geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
I am not sure if a functionality exists in the geotiff.js library, but the issue is that I have a set of Ground control points (GCPS) which have the image points (x,y,0) and (lat, lng, 0). Now I want to write a geotiff using a raw image object or an image url, and the set of ground control points. I have tried to use tags such as the ModelTiePoint and ModelPixelScale, however, they do not do georeferning. The ground control point is an array in this example [ x, y, 0, lng, lat, 0].
const metadata = {
width: rawImageDocument.width,
height: rawImageDocument.height,
ModelTiepoint: controlPoints.flat(),
ModelPixelScale: [pixelWidth, pixelHeight, 0.0], // ModelPixelScale
ExtraSamples: 0,
SamplesPerPixel: 3, // 3=RGB, 4=RGBA Set the SamplesPerPixel tag for RGBA image
ProjectedCSTypeGeoKey: 4326, // (EPSG code for WGS 84)
GeoAsciiParams: 'WGS 84',
};
// Generate the GeoTIFF synchronously
const tiffData = GeoTIFF.writeArrayBuffer(rgbArray, metadata);
The following ground control points, if I have georeferenced marker:
// [x, y, 0, lng, lat, 0]
[ [0,0,0,121.53644574764846,-28.488382393735773,0],
[1258,0,0,121.6301344525469,-28.488382393735773,0],
[1258,1761,0,121.6301344525469,-28.603588342154737,0],
[0,1761,0,121.53644574764846,-28.603588342154737,0],
[544.90,712.057,0,121.57085806131366,-28.58478369021423,0]]
Here is the georeferenced image:
Here is a generated geo tiff file result in QGIS for the above image:
It will be a great idea to add functions like set_gcps, provided in gdal, to geotiff if possible, only if the functionality is not available currently.
I am not sure if a functionality exists in the geotiff.js library, but the issue is that I have a set of Ground control points (GCPS) which have the image points (x,y,0) and (lat, lng, 0). Now I want to write a geotiff using a raw image object or an image url, and the set of ground control points. I have tried to use tags such as the ModelTiePoint and ModelPixelScale, however, they do not do georeferning. The ground control point is an array in this example [ x, y, 0, lng, lat, 0].
Here is the georeferenced image:![Image 23-2-2024 at 4 10 pm](https://github.com/geotiffjs/geotiff.js/assets/94041411/48102f89-49e9-4d1a-bfe2-6717c498ee3b)
Here is a generated geo tiff file result in QGIS for the above image:
It will be a great idea to add functions like set_gcps, provided in gdal, to geotiff if possible, only if the functionality is not available currently.