23 lines
675 B
Python
23 lines
675 B
Python
|
from pathlib import Path
|
||
|
import json
|
||
|
|
||
|
try:
|
||
|
file_path = (Path(__file__).parent / 'input_files' / 'part.geojson')
|
||
|
output_file_path = (Path(__file__).parent / 'input_files' / 'selected_building.geojson').resolve()
|
||
|
selected_building = 5755
|
||
|
|
||
|
with open(file_path) as json_file:
|
||
|
_geojson = json.loads(json_file.read())
|
||
|
features = [_geojson['features'][selected_building - 1]]
|
||
|
output_json = {"type": "FeatureCollection",
|
||
|
"features": features
|
||
|
}
|
||
|
json_object = json.dumps(output_json, indent=4)
|
||
|
with open(output_file_path, "w") as outfile:
|
||
|
outfile.write(json_object)
|
||
|
|
||
|
|
||
|
except Exception as ex:
|
||
|
print(ex)
|
||
|
print('error: ', ex)
|