-
Notifications
You must be signed in to change notification settings - Fork 340
Geotiff grid shift support #503
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
Conversation
Ignore the second point, I figured it out... proj4.defs("EPSG:27700_tif","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +nadgrids=britishtif +units=m +no_defs +type=crs");
async function loadGeotiff() {
const response = await fetch('uk_os_OSTN15_NTv2_OSGBtoETRS.tif');
const arrayBuffer = await response.arrayBuffer();
const tiff = await fromArrayBuffer(arrayBuffer);
const image = await tiff.getImage();
const extent = image.getBoundingBox(); // comes out as: [-9, 48.99166666666667, 2.0166666666666657, 61]
const rasters = await image.readRasters();
proj4.nadtifgrid('britishtif', rasters, { lim:[image.getWidth(), image.getHeight()], ll: extent, del:[image.fileDirectory.ModelPixelScale[0], image.fileDirectory.ModelPixelScale[1]] });
console.log(proj4('EPSG:4326', 'EPSG:27700_tif', wgs84Coords)); // matches
} The function call needs a bit of work to make it a bit more user friendly, but what do you think of the approach in general? |
Thanks for putting this together, @oshawa-connection. The general approach looks good! Like you suggest, the API could be simplified - since the configuration object contains geotiff.js specific data anyway, you could pass the geotiff object directly. Instead of introducing a new proj4.defs("EPSG:27700_tif","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +nadgrids=britishtif +units=m +no_defs +type=crs");
async function loadGeotiff() {
const response = await fetch('uk_os_OSTN15_NTv2_OSGBtoETRS.tif');
const arrayBuffer = await response.arrayBuffer();
const tiff = await fromArrayBuffer(arrayBuffer);
await proj4.nadgrid('britishtif', tiff).ready;
console.log(proj4('EPSG:4326', 'EPSG:27700_tif', wgs84Coords)); // matches
} |
Thanks for the feedback, that's implemented so hopefully a bit easier on users now :)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @oshawa-connection, this is a great addition!
As discussed in #495 I have created a first draft to see if the approach is ok.
Users have to do something like this in their code. Not particularly friendly, but it does match roughly how users have to load NTV2 grids from an arraybuffer.
Secondly, I am a little bit stuck because of a small (but significant) difference between the british.gsb
and.tif
calculated extents - I'm not sure how to handle this. When proj4js reads from the british NTV2 file (OSTN15_NTv2_OSGBtoETRS.gsb), it determines the extent to be [-9,49, 2, 61]; whereas geotiff.js returns [-9, 48.99166666666667, 2.0166666666666657, 61] from uk_os_OSTN15_NTv2_OSGBtoETRS.tif which results in differences in the calculated projected coordinate.In QGIS, there is no difference between these two files, so I'm not sure what the cause of this difference is....