### Install Development Dependencies Source: https://github.com/josephinum-research/isoxml-py/blob/main/examples/README.md Install the development dependencies for the isoxml-py library using pip. This is a prerequisite for running the examples. ```bash pip install .[dev] ``` -------------------------------- ### Install isoxml Library Source: https://github.com/josephinum-research/isoxml-py/blob/main/README.md Install the library using pip. This command fetches and installs the latest version of the isoxml package. ```bash pip install isoxml ``` -------------------------------- ### Export TaskData to XML Source: https://github.com/josephinum-research/isoxml-py/blob/main/README.md Create and export ISOXML TaskData to an XML string. This example demonstrates creating customer and farm objects and then serializing them. ```python import isoxml.models.base.v4 as iso from isoxml.util.isoxml_io import isoxml_to_text customer = iso.Customer( id="CTR0001", last_name="demo_customer" ) farm = iso.Farm( id="FRM0001", designator="demo farm", customer_id_ref=customer.id ) task_data = iso.Iso11783TaskData( management_software_manufacturer="josephinum research", management_software_version="0.0.0", data_transfer_origin=iso.Iso11783TaskDataDataTransferOrigin.FMIS, customers=[customer], farms=[farm] ) xml_content = isoxml_to_text(task_data) print(xml_content) ``` ```xml ``` -------------------------------- ### Generate ISOXML V3-3 Models with xsdata Source: https://github.com/josephinum-research/isoxml-py/blob/main/isoxml/models/README.md Use this command to generate Python models for ISOXML version 3-3 from its XSD schema. Ensure xsdata is installed and the XSD file is accessible. ```bash xsdata resources/xsd/ISO11783_TaskFile_V3-3.xsd \ --package isoxml.models.base.v3 \ --subscriptable-types \ --union-type \ --structure-style clusters \ --no-relative-imports ``` -------------------------------- ### Import TaskData from Zip Source: https://github.com/josephinum-research/isoxml-py/blob/main/README.md Import ISOXML TaskData and binary data from a ZIP archive. Ensure the path to your TASKDATA.zip file is correct. ```python from isoxml.util.isoxml_io import isoxml_from_zip task_data, bin_data = isoxml_from_zip('/path/to/TASKDATA.zip') ``` -------------------------------- ### Convert IsoXML Guidance to GeoPandas GeoSeries Source: https://github.com/josephinum-research/isoxml-py/blob/main/examples/guidance_pattern_viewer.ipynb Parses an IsoXML TASKDATA.XML file, converts guidance patterns to Shapely geometries, and creates a GeoSeries for visualization. Requires IsoXML and GeoPandas libraries. ```python from test.resources.test_resources import TEST_RES_DIR from isoxml.util.isoxml_io import isoxml_from_path from isoxml.converter.shapely_geom import ShapelyConverterV4 import geopandas as gpd shp_converter = ShapelyConverterV4() task_data, _ = isoxml_from_path(TEST_RES_DIR / "isoxml/v4/cnh_export/TASKDATA.XML") shp_gp_geoms = [] for partfield in task_data.partfields: for gg in partfield.guidance_groups: for gp in gg.guidance_patterns: for lsg in gp.line_strings: if len(lsg.points) > 1: shp_gp_geoms.append(shp_converter.to_shapely_geom(lsg)) gs_gp_geoms = gpd.GeoSeries(data=shp_gp_geoms, crs='EPSG:4326') m = gs_gp_geoms.explore() m ``` -------------------------------- ### Generate ISOXML V4-3 Models with xsdata Source: https://github.com/josephinum-research/isoxml-py/blob/main/isoxml/models/README.md Use this command to generate Python models for ISOXML version 4-3 from its XSD schema. This command is similar to the V3-3 generation but targets a different version. ```bash xsdata resources/xsd/ISO11783_TaskFile_V4-3.xsd \ --package isoxml.models.base.v4 \ --subscriptable-types \ --union-type \ --structure-style clusters \ --no-relative-imports ``` -------------------------------- ### Convert IsoXML Partfields to GeoPandas GeoSeries Source: https://github.com/josephinum-research/isoxml-py/blob/main/examples/partfield_viewer.ipynb Parses an IsoXML file, converts its partfield polygons to Shapely objects, and creates a GeoPandas GeoSeries for visualization. Requires IsoXML data and GeoPandas. ```python import geopandas as gpd from isoxml.converter.shapely_geom import ShapelyConverterV3 from isoxml.util.isoxml_io import isoxml_from_path from test.resources.test_resources import TEST_RES_DIR shp_converter = ShapelyConverterV3() task_data, _ = isoxml_from_path(TEST_RES_DIR / "isoxml/v3/grid_type_2/TASKDATA.XML") shp_polys = [] for field in task_data.partfields: for poly in field.polygons: shp_polys.append(shp_converter.to_shapely_polygon(poly)) field_gs = gpd.GeoSeries(data=shp_polys, crs="EPSG:4326") field_gs.explore() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.