Created
July 14, 2020 15:06
-
-
Save kevin-deyoungster/11d3412dc86939d63290b6ab6e20a0f6 to your computer and use it in GitHub Desktop.
QGIS script to export selected features to GeoJSON (separately)
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
import json | |
layer = qgis.utils.iface.activeLayer() | |
for i, elem in enumerate(layer.selectedFeatures()): | |
attrs = elem.__geo_interface__ | |
filename = attrs["properties"]["DISTRICT"] # change this to whatever you want to be filename | |
with open(f"{filename}.geojson", "w") as geo_json_output: | |
json.dump(attrs, geo_json_output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment