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
129 stars 26 forks source link

Unable to Create File Geodatabase Data #84

Closed stdavis closed 1 year ago

stdavis commented 1 year ago

I get an error when I attempt to create new data using the OpenFileGDB driver. For example: image

I'd love any suggestions on what I'm doing wrong. Thanks!

ok958726 commented 1 year ago

I met the same problem as yours, did you solve it?

stdavis commented 1 year ago

No, I haven't found a solution yet. I'm hoping that one of the maintainers of this library can give us a clue.

ok958726 commented 1 year ago

No, I haven't found a solution yet. I'm hoping that one of the maintainers of this library can give us a clue.

I found out that the gdal.vectorTranslate method can be used to create a new FileGDB. First create an empty dataset, then convert to FileGDB, and write data on it. But I don't know if this method will have any problems in terms of performance. Below is simple sample code:

const driverShapefile = gdal.drivers.get('ESRI Shapefile'); 
const datasetShapefile=driverShapefile.create('./data/temp.shp');
const datasetGDB=gdal.vectorTranslate("./data/output.gdb", datasetShapefile,[ '-of', 'OpenFileGDB' ])
datasetShapefile.close()
const layer = datasetGDB.layers.create('jz_cy', gdal.SpatialReference.fromEPSG(4490), gdal.Point);
// next write the data you need
// ......
// save and close the dataset when finished
datasetGDB.flush();
datasetGDB.close();
mmomtchev commented 1 year ago

Duplicate of https://github.com/mmomtchev/node-gdal-async/issues/61

stdavis commented 1 year ago

@mmomtchev In what way is this issue a duplicate of #61? Does the OpenFileGDB driver only support raster?

mmomtchev commented 1 year ago

OpenFileGDB supports only vector files in GDAL 3.6: https://gdal.org/drivers/vector/openfilegdb.html

If you want to copy this dataset, you have to do exactly as described in #61 - by copying all the features from all the layers.

Or you can use gdal.vectorTranslate.

stdavis commented 1 year ago

If you want to copy this dataset, you have to do exactly as described in #61

@mmomtchev I get the "Unhandled error Error: Only vector datasets supported" error message when I try and call driver.create('path/data.gdb') using the OpenFileGDB driver. How am I supposed to follow the steps in #61 if I can't create an empty file geodatabase?

I've also tried gdal.vectorTranslate and it outputs the layers as stand-alone tables without any geometry. Can you give me a hint on how to make it output the shapes?

mmomtchev commented 1 year ago

@stdavis Your first question was about createCopy. In GDAL 3.6, OpenFileGDB supports read-write operations only on vector datasets. In the very recent GDAL 3.7, read-only support for raster files has been added. Creating a new raster file is not currently possible.

stdavis commented 1 year ago

I'm not working with rasters; only vector. Sorry if I wasn't clear.

mmomtchev commented 1 year ago

Yes, indeed, because of a bug in the parsing of the type, create falsely assumes a Byte type when creating this dataset.

For now, you can use:

gdal.drivers.get('OpenFileGDB').create('test.gdb', 0, 0, 0, 'Unknown')