Opened 110 minutes ago
#36626 new New feature
Support sub-second resolution in GDAL Features' datetime fields
Reported by: | Tilman Koschnick | Owned by: | |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Tilman Koschnick | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I have a GPX DataSource with points that have sub-second resolution:
<trkpt lat="47.454540000" lon="8.573658000"> <ele>436.900</ele> <time>2025-09-25T12:24:42.990Z</time> </trkpt>
The GDAL API returns these only with second resolution, although the underlying datetime presentation is still accessible with the as_string() method:
>>> point <django.contrib.gis.gdal.feature.Feature object at 0x7f99254b9190> >>> point.get('time') datetime.datetime(2025, 9, 25, 12, 24, 42) >>> point['time'] <django.contrib.gis.gdal.field.OFTDateTime object at 0x7f99253212b0> >>> point['time'].as_datetime() (c_int(2025), c_int(9), c_int(25), c_int(12), c_int(24), c_int(42), c_int(100)) >>> point['time'].as_string() '2025/09/25 12:24:42.990+00'
In my case, I lose information, and end up being at different locations at the same time ;)
Would it be possible to support sub-second resolutions in the GDAL API? As I understand it, OGR_F_GetFieldAsDateTime() is used to return the datetime object:
https://gdal.org/en/stable/doxygen/ogr__api_8h.html#a47ca681bb6099eb8c18004d1f7112d95
GDAL also provides OGR_F_GetFieldAsDateTimeEx() that returns seconds as float with millisecond accuracy:
https://gdal.org/en/stable/doxygen/ogr__api_8h.html#a748995fa28574b25f6b723013a405a8f
I unfortunately don't understand the GDAL API enough to provide a patch myself.
Regards, Til