Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fiona no longer casts int to float since 1.10 #1469

Open
om-henners opened this issue Dec 2, 2024 · 0 comments
Open

Fiona no longer casts int to float since 1.10 #1469

om-henners opened this issue Dec 2, 2024 · 0 comments

Comments

@om-henners
Copy link

om-henners commented Dec 2, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant