Comments (9)
π - would love to see a comparison of how shapely/fiona handle this.
from node-gdal.
@springmeyer Shapely doesn't know of drivers (or projections), it's 2D geometry algorithms only.
Fiona and Rasterio by design don't have any driver objects in their interfaces. Drivers are referred to by their string names only when needed. To open a shapefile for writing with Fiona:
import fiona
with fiona.open('file.shp', 'w', driver='ESRI Shapefile') as destination:
...
I've never seen Python OGR code that used driver objects for anything other than opening a file, e.g. http://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#iterate-over-features. And since the generic ogr.Open()
is equivalent to driver.Open()
, I've found the existence of driver objects to be pointless and distracting.
Of course, I think it's okay for node-gdal to make other design decisions.
from node-gdal.
Shapely doesn't know of drivers (or projections), it's 2D geometry algorithms only.
Whoops, sorry meant to say "Rasterio/Fiona".
fiona.open('file.shp', 'w', driver='ESRI Shapefile')
Nice, this feels very similar to the new GDAL 2.0 OpenEx function as part of http://trac.osgeo.org/gdal/wiki/rfc46_gdal_ogr_unification.
from node-gdal.
re-reading this. My sense is:
- Supporting
gdal.open
andogr.open
without first creating a driver is great.node-gdal
already allows this and its looking good. Accessing ogr likerequire('../lib/gdal.js').ogr
also seems fine for now. - After that the only meaningful purpose of drivers is for actions like
createCopy
andcopyFiles
, andrename
. I think exposing these off of the maingdal
object would be fine instead of requiring a driver instance.
So, I propose removing src/gdal_driver.cpp
and src/gdal_driver.hpp
and the corresponding tests. Then this ticket can be closed and getDriverByName
will not be in the public api anymore.
Also as context, I've learned from @sgillies that the reason for supporting the with rasterio.drivers():
syntax in rasterio is to be able to have a block of code that supports custom error handlers and custom gdal config options. Something like this could be added later but I don't think its needed at this point. Also how it plays with threads is an open question we are researching.
from node-gdal.
@springmeyer right, to have a lightweight and limited runtime. In Javascript, this is better done using an anonymous function, right?
> var gdal = require('./lib/gdal.js')
undefined
> var filename = "/Users/sean/code/rasterio/rasterio/tests/data/RGB.byte.tif"
undefined
> (function() {
... // set GDAL options and error handler
... var width = gdal.open(filename).getRasterXSize()
... // unset GDAL options and error handler
... return width
... })()
791
from node-gdal.
@sgillies I'm not sure this is applicable, given that GDAL in Node won't always be sync like it is in Python. Even if it is sync, people can mix it with async application code.
If we need different contexts, we'll need to implement something along the lines of:
var gdal = require('gdal').context();
And then you can pass gdal
around your application (DI style). But I'm not sure what that is good for βΒ and it'd messy the internals. Sorry if I'm misunderstanding!
from node-gdal.
For now, what about going with a global EventEmitter. Users would be able to listen/unlisten and do what they want with error messages.
gdal.on('error', function(message) { });
gdal.on('warning', function(message) { });
from node-gdal.
It strikes me that error context creation would happen within an given async function. So the error handler would be added in the c++ internals of gdal.soSomethingAysnc(cb)
and then released so that cb(err)
would return the GDAL error. But we need to test this.
from node-gdal.
Added driver collections with this commit : f59d8de
gdal.drivers.count()
gdal.drivers.get(name | id)
gdal.drivers.getNames()
gdal.drivers.forEach(callback)
Also made gdal.open()
more like GDALOpenEx
and fiona.open
gdal.open(filename, mode, drivers, ...);
//examples
gdal.open(filename, 'r', ['ESRI Shapefile', 'GeoJSON']);
gdal.open(filename, 'w', 'ESRI Shapefile');
from node-gdal.
Related Issues (20)
- Can't open MVT for write
- gdal.Driver.create's parameter: data_type which need Integer(number) , however , Constants (GDT) : gdal.GDT_* provide string HOT 4
- Using node-gdal in electron HOT 4
- This its under other libs and can't even compile because node-pre-gyp ERROR
- DGN driver
- Node.js 14 HOT 3
- converting
- Node 16 binaries on older OS (glibc version) HOT 3
- npm install not working HOT 2
- Change the AREA_OR_POINT value
- Multi process Read Error HOT 1
- Memory Usage Overflow
- Problem with Node 17
- npm install gdal --save errors on M1 mac HOT 3
- What versions of nodejs are supported?
- Example of resolving GPS lat/long to elevation from a WGS84 TIFF HOT 15
- Get altitude/elevation from GPS coordinates HOT 1
- Add support for node 18
- Is there any release for arm64?
- failed npm install gdal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-gdal.