Closed bertday closed 1 year ago
Thanks @rbrtmrtn for the suggestion and encouragement. I agree, a ogr2ogr
command to code example would be helpful. In your case it would be:
ogr2ogr -f GeoJSON foo.geojson foo.shp
By default, if possible, GeoJSON is returned, so:
let geojson = await ogr2ogr("./foo.shp")
Thanks for the quick response @wavded!
It's helpful to see that minimal example. I think what I struggle with a bit in Node is writing files out, so if there were a complete (but still minimal) example of reading foo.shp
and writing it out as foo.geojson
to disk, that would be super helpful.
Or I can try doing a PR once I figure it out 😄
Hi @rbrtmrtn, I am just getting started with trying to use this in an AWS Lambda function. I too was confused as to how to write the data, and I agree the documentation could be elaborated on. I was able to get this to work in a local environment (not quite there in the lambda function). If it helps, this is how I got the data to write to a geojson file:
ogr2ogr('/local/file.shp', {destination:'/local/file.json', options: [ '-t_srs', 'EPSG:4326' ]}).exec((err, data) => { if (data && data.details) { console.log(data.details) } if (err) { console.log(err) } })
Within the lambda function, I am stuck on how to install gdal tools. So if you have any tips on that, send them my way! Thanks.
Sorry for the delay on this. Previously we had an examples folder where we put little code snippets of usage for different use cases. Would that make sense to start another one? A lot of them previously were community driven. Suppose we could do a Wiki as well.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
Hello @wavded and thank you for this awesome project!
I'm trying to get started using this package to read and write geodata. I'm a little confused though looking at the examples how I would recreate a canonical use of
ogr2ogr
, like:All of the examples seem to focus on reading data in. I happened to see a more clear-cut read-write example in #92 so I'm using that, but just wanted to suggest as a new user that it may be helpful to have a similar example in the docs!
Thanks again and Happy New Year!