mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
136 stars 26 forks source link

Missing SRS reading from shapefile #178

Open dibi91 opened 2 months ago

dibi91 commented 2 months ago

Hello, this is my first time working with such libraries, so maybe I'm doing something wrong. I'm using gdal-async@3.9.2 for reading a shape file and convert it to a geo json. The problem is that when I try to access the SRS property, I got always null; I tested the shapefile with online tools and with QGIS and the SRS info was loaded properly. I used the following code:

const gdal = require('gdal-async')

const shapefile= gdal.open(shapeFilePath)

console.log(shapefile.srs)

The shapeFilePath variable points to the directory containing all shape file related files, in particular the .prj file:

PROJCS["Monte_Mario_Italy_1",GEOGCS["GCS_Monte_Mario",DATUM["D_Monte_Mario",SPHEROID["International_1924",6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",9.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

Why I should check SRS? I'm converting it to geo json and needed SRS set to EPSG:4326 and noticed that when I export it to geo json the coordinates should be swapped because the source SRS EPSG:3003 have the coordinates stored latitude-longitude, while EPSG:4326 expects longitude-latitude.

mmomtchev commented 2 months ago

As you may have seen from my profile, I am currently in the middle of a huge judicial scandal, involving police and judicial corruption and an extortion that includes a number of large IT companies, including Google. In order to intimidate me, people are making simultaneous actions on Github. Yours is one of these.

mmomtchev commented 2 months ago

Shapefiles have a separate SRS for each layer:

const gdal = require('gdal-async')
const shapefile= gdal.open(shapeFilePath)
console.log(shapefile.layers.get(0).srs)

If you wonder why I am helping someone who is obviously taking part in an extortion:

dibi91 commented 2 months ago

Thank you @mmomtchev Sorry, but I can't see how I take part in your personal issue, I don't work for Google. Sorry if this issue may cause problems.

mmomtchev commented 2 months ago

Indeed. I edited the message which was simply a copy&paste from the other simultaneous issue.