In ArcGIS Pro, there is the option to symbolize a feature dependent on scale. I have several maps I am looking to convert and want to modify the .lyrx file (is JSON format) to accept these alternate symbols.
with an open JSON and a simple dataset I found the alternateSymbols list in
data['layerDefinitions'][0]['renderer']['groups'][0]['classes']['alternateSymbols']
when i try to import my other symbols with minScale and maxScale Values, i get nothing.
If I just dump them into 'classes' they DO show in arcmap, but are not scale dependenent.
this is the function I am using a the moment
def outload_into_one_file(detail, normal):
detail = detail
normal = normal
out_file = os.path.splitext(normal)[0] + "_COMBINED.lyrx"
with open (detail , "r") as jsonFile:
detail_data = json.load(jsonFile)
with open (normal , "r") as jsonFile:
normal_data = json.load(jsonFile)
detail_base = detail_data['layerDefinitions'][0]
detail_classes = detail_base['renderer']['groups'][0]['classes']
normal_base = normal_data['layerDefinitions'][0]
normal_classes = normal_base['renderer']['groups'][0]['classes']
detail_classes_dict = {}
for x in detail_classes:
detail_classes_dict.update({x["label"]: x})
for x in normal_classes:
x['maxScale'] = 251
x['minScale']= 3000
for x in normal_classes:
cls = detail_classes_dict.get(x['label'])
cls['maxScale']=250
cls['alternateSymbols'] = []
cls['alternateSymbols'].append(x)
with open(out_file, "w") as jsonFile:
json.dump(detail_data, jsonFile)