GeoCat / bridge-style

Cartography library making style format conversions as easy as using Python.
MIT License
42 stars 13 forks source link

Looking forward to the code that can convert arcgis style to sld. #59

Closed gengyanlei closed 2 years ago

gengyanlei commented 2 years ago

There is no detailed usage documentation.

GeoSander commented 2 years ago

@gengyanlei That's correct, there's no detailed documentation... Bridge-style can convert ArcGIS Pro styles (CIM) in *.lyrx files to SLD, but this functionality is still under development. Perhaps @volaya (who wrote this converter) can elaborate, but I'm not sure what you want to know? The general README provides the information you need to work with bridge-style either in Python or by using the CLI. The workflow is the same for all styles.

Using code, you should be able to do something like this for example:

import json
from bridgestyle import sld, arcgis

input_file = "/my/path/input.lyrx"
output_file = "/my/path/output.sld"

# Read the *.lyrx JSON
with open(input_file) as f:
    esri_style = json.load(f)

# Convert Esri CIM to GeoStyler (intermediate format)
geostyler, _, warnings = arcgis.togeostyler.convert(esri_style)
print(warnings)

# Convert GeoStyler to SLD
sld_output, warnings = sld.fromgeostyler.convert(geostyler)

# Write the XML output string to the destination SLD file
with open(output_file) as f:
    f.write(sld_output)
gengyanlei commented 2 years ago

thanks.