Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a geotiff from an image and a list of ground control points. #421

Open
DevkumarPatel opened this issue Feb 23, 2024 · 0 comments

Comments

@DevkumarPatel
Copy link

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);

Screenshot 2024-02-23 at 4 01 57 pm
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:
Image 23-2-2024 at 4 10 pm

Here is a generated geo tiff file result in QGIS for the above image:
Screenshot 2024-02-23 at 4 14 50 pm
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant