Fiona reads and writes spatial data files
88
Schema definition and validation system for specifying the structure of geospatial data, including field types, geometry types, and validation rules.
def prop_type(text):
"""
Returns a schema property's proper Python type.
Parameters:
- text: str, type name with or without width
Returns:
type: Python class (int, str, float, etc.)
"""
def prop_width(val):
"""
Returns the width of a str type property.
Parameters:
- val: str, type:width string from schema
Returns:
int or None: Width for string types, None for others
"""Fiona supports various field types for representing different kinds of attribute data:
from fiona import prop_type, prop_width
# Get Python type from schema string
int_type = prop_type('int') # <class 'int'>
str_type = prop_type('str:50') # <class 'str'>
float_type = prop_type('float') # <class 'float'>
# Get string field width
width = prop_width('str:25') # 25
default_width = prop_width('str') # 80
non_str_width = prop_width('int') # None
# Schema definition example
schema = {
'geometry': 'Point',
'properties': {
'name': 'str:50', # String with max 50 characters
'population': 'int', # Integer
'area': 'float', # Float
'active': 'bool', # Boolean
'founded': 'date', # Date
'metadata': 'json' # JSON data
}
}Install with Tessl CLI
npx tessl i tessl/pypi-fionadocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10