Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples of how to write data #93

Closed
bertday opened this issue Jan 2, 2023 · 6 comments
Closed

More examples of how to write data #93

bertday opened this issue Jan 2, 2023 · 6 comments
Labels

Comments

@bertday
Copy link
Contributor

bertday commented Jan 2, 2023

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:

ogr2ogr -f GeoJSON foo.geojson foo.shp

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!

@wavded
Copy link
Owner

wavded commented Jan 2, 2023

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")

@bertday
Copy link
Contributor Author

bertday commented Jan 2, 2023

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 😄

@sgibbes
Copy link

sgibbes commented Jan 5, 2023

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.

@wavded
Copy link
Owner

wavded commented Jan 13, 2023

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.

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Feb 13, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants