Quickly convert KML to GeoJSON or GeoJSON to SVG and concatenate multiple GeoJSON files via the terminal.
First download and install Node.js from https://nodejs.org/en
In the command line install kml2geojson globally:
npm i -g kml-streamIn the command line install kml2geojson globally:
npm i -g geojson-to-svgIn the command line install geojson-merge globally:
npm i -g geojson-mergeIn the terminal use the following command below. Just replace INPUT with the path of the KML file and OUTPUT with the any name for the GeoJSON file you fancy.
kml2geojson < INPUT.kml > OUTPUT.geojsonThis works well with small GeoJSON files. Useful for graphic designers who use Illustrator or just for a quick static image for web. In the terminal use the following command below. Just replace INPUT with the path of the KML file and OUTPUT with the any name for the GeoJSON file you fancy.
geojson2svg --input INPUT.geojson > OUTPUT.svgWith the GeoJSON files all in one folder, use the following command to merge them all. Just replace OUTPUT with the any name for the combined GeoJSON file you want.
geojson-merge *.geojson > OUTPUT.geojson** Just make sure that your terminal is in the same directory as your GeoJSON files.
I learned all this during the fire coverage at the San Francisco Chronicle. I found the semi-updated KML/KMZ files for current fire locations and perimeters provided by United States Geological Survey (USGS). You can also download historical fire data too. If you have Google Earth Pro, you download them and view them quickly. All of which can be found here: https://rmgsc.cr.usgs.gov/outgoing/GeoMAC
Thanks for this resource.
I wrote a small article about how I ended handling the KML/KMZ in Nodejs - https://boobo94.github.io/tutorials/create-kml-kmz-nodejs/.
Hope it helps!