hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

8.9K
active users

Dave Mackey

looking to data from a proprietary format into an open format, to be specific.

any suggestions on good ways to proceed using ?

Emphasis should be placed on the *transform* step (e.g., I can't simply convert the XML to JSON, I need to modify fields/values).

@davidshq I'd use xslt3 for that. There is a learning curve, but it is the right tool for this kind of job. Saxon can be called from Python if Python is what you need to use on the top level saxonica.com/saxon-c/doc11/htm #xml

www.saxonica.comPython: module saxonc

@davidshq You could parse your custom XML data into either shapely objects shapely.readthedocs.io/en/stab or a SpatiaLite DB (extension for SQLite) gaia-gis.it/fossil/libspatiali as an intermediate representation.

Having done your transformations, it is easy to dump from either Shapely objects or a SpatiaLite DB to GeoJSON.

Also lots of people suggesting pandas. If you go that route, you could look into geopandas.org/en/stable/ but I have not used this myself.

shapely.readthedocs.ioShapely — Shapely 2.0.1 documentation

@chris thanks! I found an example of someone using shapely to convert from xml to qupath, I'll take a look at shapely

@davidshq I was looking for something similar earlier today for a one-off and discovered a package called "yq" that turns YAML into JSON and passes it into jq.

The yq package includes another one called "xq" which takes in XML and emits JSON.

And since the whole thing runs through jq, you have the ability to query and/or alter the JSON output as needed.

Third times the charm, right? Here's the *CORRECT* link

github.com/kislyuk/yq

GitHubGitHub - kislyuk/yq: Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documentsCommand-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents - kislyuk/yq

@ThatBlairGuy Cool, I'll take a look. xmltodict is one module I'd been looking at!