Created
May 23, 2022 07:39
-
-
Save paulmwatson/f162901904b077c2140e23773ee2f48f to your computer and use it in GitHub Desktop.
Convert multiple feature/layers in a geoJSON file to individual files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creates multiple files from one geojson file | |
require 'json' | |
file = File.read('data.geojson') | |
data_hash = JSON.parse(file) | |
data_hash['features'].each do |feature| | |
file_name = feature['properties']['OBJECTID'] | |
File.open("#{file_name}.geojson", 'w') do |f| | |
f.write(feature.to_json) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment