У меня есть dxf
файлы, и я хочу преобразовать их в geojson
файлы:
import subprocess
from subprocess import call
import os
working_directory = 'D:/dxf_files/'
for subdir, dirs, files in os.walk(working_directory):
for file in files:
if file.endswith('.dxf'):
print(file)
Выход:
BJ-SZZDS-1010084246-dongta-11.dxf
BJ-SZZDS-1010084246-dongta-12.dxf
BJ-SZZDS-1010084246-dongta-17.dxf
BJ-SZZDS-1010084246-dongta-18.dxf
BJ-SZZDS-1010084246-dongta-19.dxf
...
Я хочу поместить каждый из этих файлов в input_file
ниже, оставив output_file
имя файла таким же, как input_file
, заменив расширение файла. Теперь два блока кода разделены, как я могу объединить их вместе? Спасибо за любую помощь заранее.
input_file = 'BJ-SZZDS-1010084246-dongta-11.dxf'
output_file = 'BJ-SZZDS-1010084246-dongta-11.geojson'
def dxf2geojson(output_file, input_file):
command = ['ogr2ogr', '-f', 'GeoJSON', output_file, input_file]
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return p
dxf2geojson(output_file, input_file)