Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def write_shapefile(data, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in
fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(BASE_PATH, 'intermediate', 'sitefinder')
if not os.path.exists(directory):
os.makedirs(directory)
print(os.path.join(directory, filename))
# Write all elements to output file
def write_shapefile(data, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((
fiona_type for fiona_type, python_type in \
fiona.FIELD_TYPES_MAP.items() if \
python_type == type(value)), None
)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(DATA_INTERMEDIATE, 'test_simulation')
if not os.path.exists(directory):
os.makedirs(directory)
def write_shapefile(data, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((
fiona_type for fiona_type, python_type in \
fiona.FIELD_TYPES_MAP.items() if \
python_type == type(value)), None
)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
directory = os.path.join(DATA_INTERMEDIATE, 'system_simulator')
if not os.path.exists(directory):
os.makedirs(directory)
def write_road_network_shapefile(data, path):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Write all elements to output file
with fiona.open(os.path.join(SYSTEM_RESULTS_PATH, path), 'w', driver=sink_driver, crs=sink_crs, schema=sink_schema) as sink:
for feature in data:
#print(feature)
sink.write(feature)
def write_shapefile(data, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(DATA_INTERMEDIATE, 'built_env_test')
if not os.path.exists(directory):
os.makedirs(directory)
# Write all elements to output file
with fiona.open(os.path.join(directory, filename), 'w', driver=sink_driver, crs=sink_crs, schema=sink_schema) as sink:
def write_shapefile(data, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(DATA_PROCESSED)
if not os.path.exists(directory):
os.makedirs(directory)
# Write all elements to output file
with fiona.open(os.path.join(directory, filename), 'w', driver=sink_driver, crs=sink_crs, schema=sink_schema) as sink:
def write_shapefile(data, directory, id):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
folder_directory = os.path.join(DATA_RAW_SHAPES, directory)
if not os.path.exists(folder_directory):
os.makedirs(folder_directory)
for area in data:
filename = area['properties'][id]
def write_shapefile(data, exchange_name, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(DATA_INTERMEDIATE, exchange_name)
if not os.path.exists(directory):
os.makedirs(directory)
print(os.path.join(directory, filename))
# Write all elements to output file
def write_shapefile(data, exchange_name, filename):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
# Create path
directory = os.path.join(DATA_INTERMEDIATE, exchange_name)
if not os.path.exists(directory):
os.makedirs(directory)
print(os.path.join(directory, filename))
# Write all elements to output file
def write_shapefile(data, folder, path):
# Translate props to Fiona sink schema
prop_schema = []
for name, value in data[0]['properties'].items():
fiona_prop_type = next((fiona_type for fiona_type, python_type in fiona.FIELD_TYPES_MAP.items() if python_type == type(value)), None)
prop_schema.append((name, fiona_prop_type))
sink_driver = 'ESRI Shapefile'
sink_crs = {'init': 'epsg:27700'}
sink_schema = {
'geometry': data[0]['geometry']['type'],
'properties': OrderedDict(prop_schema)
}
directory = os.path.join(DATA_RAW_SHAPES, folder)
if not os.path.exists(directory):
os.makedirs(directory)
# Write all elements to output file
with fiona.open(os.path.join(directory, path), 'w', driver=sink_driver, crs=sink_crs, schema=sink_schema) as sink:
for feature in data: