Closed informatter closed 1 year ago
Yes, I believe it is possible. The gpsToPixel
and pixelToGPS
matrices use the origin and resolution of the image. To simply get the origin/resolution you can use image.getOrigin()
and image.getResolution()
respectively, which will work with both ModelTransformation
as well as ModelTiePoint
/ModelPixelScale
.
I hope that helps!
@constantinius
Thank you for your quick reply. I can see what you are referring to in https://github.com/geotiffjs/geotiff.js/commit/5ab27ad7c4c2a0785e26c454b50ee567adccd845
So yes, my above approach
const origin = this.dtmGeoTiff.getOrigin();
const resolution = this.dtmGeoTiff.getResolution();
let [sx, sy, sz] = resolution;
let [px, py, k, gx, gy, gz] = [0,0,0,...origin]
const gpsToPixel = [-gx / sx, 1 / sx, 0, -gy / sy, 0, 1 / sy];
const pixelToGPS = [gx, sx, 0, gy, 0, sy];
Does seem to be correct, according to the linked PR. In addition in the section "GeoTIFF Tags for Coordinate Transformations" in http://geotiff.maptools.org/spec/geotiff2.6.html#2.6 , specifies that the I,J value is the point at location (I,J) in raster space, which i believe I can set to 0,0
and K its pixel value which according to the docs can be set to 0.
So let [px, py, k, gx, gy, gz] = [0,0,0,...origin]
makes sense.
I hope I am correct?
Thank you
Nicholas
Just verified, and in terms of the pixel location, its at the expected x,y in the image 👍
Hi guys
I think this is more of a question than a issue, but lets see...
I currently have a GeoTiff file am attempting to get the corresponding height from given a lat,lng coordinate. I am currently dealing with a file which does not have the
ModelTiepoint
tag, the optionalModelPixelScale
tag, but it does have theModelTransformation
tag.However when :
const { ModelPixelScale: s, ModelTiepoint: t } = dtmGeoTiff.fileDirectory;
is calleds
andt
will be undefined, as its expected. Is there a way to use theModelTransformation
in order to sucessfully continue with the rest of the below logic?Would this be a valid approach?
Any pointers will be greatly appreciated.
Thank you,
Nicholas