or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/fiona@1.10.x
tile.json

tessl/pypi-fiona

tessl install tessl/pypi-fiona@1.10.0

Fiona reads and writes spatial data files

Agent Success

Agent success rate when using this tile

88%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.1x

Baseline

Agent success rate without this tile

80%

task.mdevals/scenario-10/

GIS Data Type Converter

Build a Python tool that converts property data types in GIS vector datasets. The tool should read features from an input dataset, convert specified property fields to new data types, and write the result to an output dataset.

Requirements

Your tool should:

  1. Accept an input file path, output file path, and a type conversion mapping
  2. Read the input dataset and its schema
  3. Create a new schema with converted field types based on the provided mapping
  4. Convert property values in each feature to match the new field types
  5. Write features to the output file with the new schema

Type Conversions to Support

Your tool must handle conversions between these data types:

  • Numeric types: int, float
  • String type: str
  • Temporal types: date, datetime
  • Binary type: bytes

Conversion Rules

  • String to numeric: Parse the string value
  • Numeric to string: Convert to string representation
  • String to date/datetime: Parse ISO format strings (e.g., "2024-01-15", "2024-01-15T10:30:00")
  • Date/datetime to string: Convert to ISO format
  • String to binary: Encode the string to bytes
  • Binary to string: Decode bytes to string
  • Numeric conversions: Cast between int and float

Test Cases

  • Converting population data from string type to integer type correctly updates the schema and values @test
  • Converting measurement data from integer to float preserves numeric values with decimal precision @test
  • Converting timestamp strings to datetime type correctly parses ISO format dates @test
  • Converting binary encoded data to string type correctly decodes the values @test

Implementation

@generates

API

def convert_field_types(
    input_path: str,
    output_path: str,
    type_mapping: dict[str, str],
    output_driver: str = "GeoJSON"
) -> None:
    """
    Convert field types in a GIS dataset.

    Args:
        input_path: Path to the input dataset
        output_path: Path to the output dataset
        type_mapping: Dictionary mapping field names to target types
                     (e.g., {"population": "int", "recorded": "datetime"})
        output_driver: Output format driver (default: "GeoJSON")
    """
    pass

Dependencies { .dependencies }

fiona { .dependency }

Provides GIS data reading and writing with field type support.