Propose new module (save & read)
See original GitHub issueI seem to constantly have to write the following functions to read & save GeoJSON files (.geojson).
var truncate = require('@turf/truncate')
function read (filename) {
return JSON.parse(fs.readFileSync(filename, 'utf8'))
}
function save (filename, features) {
fs.writeFileSync(filename, JSON.stringify(truncate(features), null, 2))
}
An easy solution was to change the GeoJSON filename extension to (.json), but there’s many times where the data comes in as (.geojson) and I need to write this helper function.
Solution
Create a FILE SYSTEM
group of functions @turf/file-system
(I dunno… just throwing that out there).
For start it would have both read & save
functions.
var read = require('@turf/file-system').read
var save = require('@turf/file-system').save
For people who only need fs
to read & write GeoJSON this would replace require('fs')
for GeoJSON purposes.
var fs =require('@turf/file-system')
fs.save('example.geojson', featureCollection)
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
csv — CSV File Reading and Writing — Python 3.11.1 ...
The csv module implements classes to read and write tabular data in CSV format. ... The Python Enhancement Proposal which proposed this addition...
Read more >Module Composition | Terraform - HashiCorp Developer
Module composition allows infrastructure to be described from modular building blocks.
Read more >Chapter 8. Writing a custom SELinux policy
8.3. Creating a local SELinux policy module · Open a new .cil file with a text editor, for example: Copy · Insert the...
Read more >Module proposal form with guidance notes When drafting a ...
When drafting a new module, use the module proposal form which includes guidance notes. Modules are drafted on the New module proposal form...
Read more >Create custom functions in Excel - Microsoft Support
Creating a simple custom function · Press Alt+F11 to open the Visual Basic Editor (on the Mac, press FN+ALT+F11), and then click Insert...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
👍 This sounds useful, I guess the big question is whether
save
should, by default, usetruncate
to limit coords.I just used
load-json-file
&write-json-file
in thetest.js
for@turf/truncate
without any issues, those libraries are very easy to use and solves read & write issue I had.https://github.com/Turfjs/turf/blob/master/packages/turf-truncate/test.js