Skip to content

Fiona no longer casts int to float since 1.10 #1469

@om-henners

Description

@om-henners

Expected behavior and actual behavior.

Hi all, in the current version of fiona rather than upcasting integers to floats. Worse it appears to drop the field in output types (like GeoJSON). In previous versions of fiona it would upcast integers automatically to floating point numbers.

I think it's related to #1376

Steps to reproduce the problem.

Simple example with the WARNING logs on

>>> import fiona
>>> fiona.__version__
'1.10.1'
>>> import logging
>>> logging.basicConfig(level=logging.WARNING)
>>> schema = {'geometry': 'Point', 'properties': {'a': 'float', 'b': 'int'}}
>>> with fiona.open("test_fiona110.geojson", mode="w", schema=schema) as col:
...     col.writerecords([{'id': '0', 'type': 'Feature', 'properties': {'a': 1, 'b': 1}, 'geometry': {'type': 'Point', 'coordinates': (0.0, 0.0)}}])
... 
WARNING:fiona.ogrext:Skipping field because of invalid value: key='a', value=1
>>> with open("test_fiona110.geojson") as f:
...     print(f.read())
... 
{
"type": "FeatureCollection",
"name": "test_fiona110",
"features": [
{ "type": "Feature", "properties": { "b": 1 }, "geometry": { "type": "Point", "coordinates": [ 0.0, 0.0 ] } }
]
}

Operating system

For example: Debian linux

> lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
Codename:	trixie

Fiona and GDAL version and provenance

  • fiona version: 1.10.1 (installed via apt-get)
  • Python 3.12.7 (installed via apt-get)
  • gdal version: GDAL 3.9.3, released 2024/10/07 (installed via apt-get)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions