yocontra / node-gdal-next

Node.js bindings for GDAL (Geospatial Data Abstraction Library) [Fork]
https://contra.io/node-gdal-next/
Apache License 2.0
75 stars 35 forks source link

Cannot find coordinate operations (EPSG:8353) #45

Closed zdila closed 3 years ago

zdila commented 3 years ago

On my system I can use gdal or qgis with EPSG:8353 but node-gdal-next fails. Can I do something with that?

Error: Cannot find coordinate operations from `ENGCRS["S_JTSK_JTSK03_Krovak_East_North",EDATUM[""],CS[Cartesian,2],AXIS["easting",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing",north,ORDER[2],LENGTHUNIT["metre",1]],ID["EPSG",8353]]' to `EPSG:4326'
yocontra commented 3 years ago

What version of node-gdal are you using, what OS are you on, and can you include some sample code?

mmomtchev commented 3 years ago

@zdila, I am more surprised by the fact that you can use EPSG:8353 with a stock GDAL then the fact that it does not work with node-gdal-next 😄

The projection support we have comes from libproj - and the version we have does not include EPSG:8353. And I don't see it on the official libproj repository either unless I am missing something?

But if your OS-provided version of GDAL does work with it - you can rebuild node-gdal-next to use it instead of using the prebuilt version that comes with it:

npm install gdal-next --build-from-source --shared_gdal

zdila commented 3 years ago

I am using version installed by npm i node-gdal-next command with Node.js v14.15.0 on Debian Bullseye. GDAL version on my system (installed from official Debian reporitory) is 3.2.1. Version of libproj is 7.2.1.

EPSG8353 is mentioned in /usr/share/proj/proj.db which is from proj-data_7.2.1-1_all.deb.

My current workaround is to use https://www.npmjs.com/package/proj4 where it works by manually specifying projections:

const proj4 = require('proj4');

proj4.defs([
  [
    'EPSG:4326',
    '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees'
  ],
  [
    'EPSG:8353',
    '+proj=krovak +lat_0=49.5 +lon_0=24.8333333333333 +alpha=30.2881397527778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=485.021,169.465,483.839,7.786342,4.397554,4.102655,0 +units=m +no_defs'
  ]
]);

const [x, y] = proj4('EPSG:4326', 'EPSG:8353', [17.25605, 48.36889]);

This did not help:

npm install gdal-next --build-from-source --shared_gdal
mmomtchev commented 3 years ago

node-gdal-next is not compatible with proj4 - so you will have to transform all the coordinates on your own

Can you find gdal.node in your node_modules/node-gdal-next and do an ldd gdal.node?

Normally, when you compile it like this, you should be calling the OS-provided GDAL from JS

Now, the question is, does the OS provided GDAL support it out of the box?

In proj.6 I have krovak but not EPSG:8353

zdila commented 3 years ago

Now I recall that with gdalwarp I was specifying transformation using proj4 string and not by EPSG code. I will recheck it tomorrow as I am no longer at PC.

mmomtchev commented 3 years ago

If you create a gdal.SpatialReference.fromProj4 it should be possible to get it to work as it already supports the underlying transformation - krovak - only the projection specification is missing

zdila commented 3 years ago

OK, my bad, gdalwarp works only when I specify proj4 transformation string and not only srs.

gdal.SpatialReference.fromProj4 works. Thank you.

I apologize for invalid report. Feel free to close this issue.

yocontra commented 3 years ago

Thanks for helping out @mmomtchev !