[GRASS-dev] Temporal framework: Proper way to register new maps from a python module?

Laurent C. lrntct at gmail.com
Fri Oct 9 08:13:57 PDT 2015


Hello,

I'm writing a module that generates raster maps and register them in
newly created strds.
The temporal type of the generated strds depends on the entry values
of the module.
I've seen in the documentation that
register_maps_in_space_time_dataset() can read the timestamp from the
GRASS raster, so my module is currently doing the following:
 - writes maps
 - assign timestamp, either absolute or relative with r.timestamp
 - at the end, register all the generated maps from a list using
register_maps_in_space_time_dataset()

But I end up with the following error with relative time:
File "/home/lo/ProgramaciĆ³n/t_sim_flood/gis.py", line 286, in
register_maps_in_strds
    strds_id, maps=map_lst_str, unit='seconds')
  File "/usr/lib/grass71/etc/python/grass/temporal/register.py", line
289, in register_maps_in_space_time_dataset
    statement += map.insert(dbif=dbif, execute=False)
  File "/usr/lib/grass71/etc/python/grass/temporal/abstract_map_dataset.py",
line 273, in insert
    self.write_timestamp_to_grass()
  File "/usr/lib/grass71/etc/python/grass/temporal/space_time_datasets.py",
line 242, in write_timestamp_to_grass
    self._convert_timestamp())
  File "/usr/lib/grass71/etc/python/grass/temporal/abstract_map_dataset.py",
line 124, in _convert_timestamp
    start = datetime_to_grass_datetime_string(start_time)
  File "/usr/lib/grass71/etc/python/grass/temporal/datetime_math.py",
line 817, in datetime_to_grass_datetime_string
    if dt.tzinfo is not None:
AttributeError: 'NoneType' object has no attribute 'tzinfo'

The grass timestamp are well written and are visible with r.info.
If I give a start=0 to register_maps_in_space_time_dataset(), all the
maps are registered in the strds without generating errors, but they
all starts and ends at 0:
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 0
 | Relative time unit:......... seconds
 | Granularity:................ 0
 | Temporal type of maps:...... point
 +-------------------- Spatial extent ----------------------------------------+

And the raster timestamps are overwritten.
I haven't tried yet with absolute type.
How should I proceed? Is there a way to avoid generating a temporary
text file to feed register_maps_in_space_time_dataset()?

Regards,
Laurent


More information about the grass-dev mailing list