Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
geoms=[]
for idx_attr, row in data_sdf.iterrows():
if row['f_code'] in stList:
if row['f_code'] in specificAttributeDict:
vals = []
for i in specificAttributeDict[row['f_code']]:
vals.append(i)
line = row['SHAPE']
def_count = len(vals)
polyline = Polyline(line)
geoms.append(polyline)
if def_count > 0:
fs = ",".join(vals)
oid = row['objectid']
temp_result_df.set_value(idx_attr, TMP_FIELDS[0],fs)
temp_result_df.set_value(idx_attr, TMP_FIELDS[1],feat_lyr)
temp_result_df.set_value(idx_attr, TMP_FIELDS[2],(domain_dict[row['f_code']]))
temp_result_df.set_value(idx_attr, TMP_FIELDS[3],round(oid))
temp_result_df.set_value(idx_attr, TMP_FIELDS[4],len(vals))
else:
temp_result_df.set_value(idx_attr, TMP_FIELDS[0],'N/A')
temp_result_df.set_value(idx_attr, TMP_FIELDS[1],feat_lyr)
temp_result_df.set_value(idx_attr, TMP_FIELDS[2],(domain_dict[row['f_code']]))
temp_result_df.set_value(idx_attr, TMP_FIELDS[3],round(oid))
if tag not in val_dict.keys():
val_dict[tag] = []
# Build Lists
for w in ways:
try:
# Populate Tags
for tag in [key for key in val_dict.keys() if key != 'osm_id']:
val_dict[tag].append(str(w['tags'].get(tag, 'Null')))
# Populate Geometries & IDs
coords = [[e['lon'], e['lat']] for e in w.get('geometry')]
if g_type == 'polygon':
poly = Polygon({"rings": [coords], "spatialReference": {"wkid": 4326}})
else:
poly = Polyline({"paths": [coords], "spatialReference": {"wkid": 4326}})
geo_dict['geo'].append(poly)
val_dict['osm_id'].append(str(w['id']))
except Exception as ex:
print('Way ID {0} Raised Exception: {1}'.format(w['id'], str(ex)))
try:
return SpatialDataFrame(val_dict, geometry=geo_dict['geo'])
except TypeError:
raise Exception('Ensure ArcPy is Included in Python Interpreter')
for w in w_list:
try:
coords = []
for w_n in w['nodes']:
for a_n in n_list:
if a_n['id'] == w_n:
coords.append([a_n['lon'], a_n['lat']])
if g_type == 'polygon':
poly = Polygon({
"rings": [coords],
"spatialReference": {"wkid": 4326}
})
else:
poly = Polyline({
"paths": [coords],
"spatialReference": {"wkid": 4326}
})
_name = 'Undefined'
tags = w.get("tags", None)
if tags:
name = tags.get("name", None)
if name:
_name = name
way_dict['ids'].append(str(w['id']))
way_dict['names'].append(_name)
way_dict['geoms'].append(poly)
except Exception as ex: