# Appending/removing data along a time dimension

**URL:** <https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125>\
**Category:** Uncategorized\
**Created:** [December 13, 2019, 2:53pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125 "2019-12-13T14:53:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djhoese](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/djhoese/32/43_2.png) [@djhoese](https://forum.tiledb.com/u/djhoese)\
**Post date:** [December 13, 2019, 2:53pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125/1 "2019-12-13T14:53:19Z")

</div>

I’m attempting to use TileDB as a backend for a mapserver. With the way my data works I need to add new images every 10 minutes (or more frequently) for the same data. I was hoping to be able to use a “time” dimension in TileDB, append new images to an array, and remove old images (to save space). From my research this doesn’t seem possible. Is that right?

I mentioned mapserver because I’m wondering since TileDB has a mapserver example if anyone has looked at supporting a TileDB dimension from mapserver?

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://forum.tiledb.com/u/stavros)\
**Post date:** [December 13, 2019, 4:18pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125/2 "2019-12-13T16:18:07Z")

</div>

Hello David,

Indeed, TileDB currently does not support deleting previous images the way you want to. The quick workaround for now is the following:

- Add a time dimension to the array schema. Each 2D image should be written in a dense slice like `A[t, x_range, y_range]` or `A[x_range, y_range, t]`, where `t` is the timestamp of insertion. Make sure to set the tile extent to 1, or any number that is meaningful if you write and/or slice more images than one at a time.
- TileDB stores the data of each write operation in a timestamped subdirectory inside the array directory. Each such subdirectory has name with format `__t1_t2_uuid`, where `t1` and `t2` are timestamps (which will be equal in your case if you do not run consolidation). Those timestamps are `ms` elapsed since 1970-01-01 00:00:00 +0000 (UTC). By listing your subdirectories in the console you can see them sorted in time (based on the name) and simply just remove the older subdirectories that you do not need. These deletions will not corrupt the array at all, and you will be able to see only your most recent images as desired.

I hope this helps. We are happy to add a more explicit API function to carry this out for you. If you could post this as a suggested feature on [http://feedback.tiledb.com/](http://feedback.tiledb.com/) we will review it and schedule it.

Thanks!

---

<div class="post-metadata">

**Author:** ![djhoese](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/djhoese/32/43_2.png) [@djhoese](https://forum.tiledb.com/u/djhoese)\
**Post date:** [December 13, 2019, 6:35pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125/3 "2019-12-13T18:35:57Z")

</div>

Oh that’s very interesting. I will have to try that out. I’ll look at adding something to the feedback site.

I’ll have to try this from mapserver too. Any idea if querying like this is supported by TileDB from mapserver (through GDAL)?

---

<div class="post-metadata">

**Author:** ![Norman\_Barker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/norman_barker/32/45_2.png) [@Norman\_Barker](https://forum.tiledb.com/u/Norman_Barker)\
**Post date:** [December 13, 2019, 6:40pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125/4 "2019-12-13T18:40:43Z")

</div>

Hi David,

that is an interesting use case you suggest, supporting a TileDB dimension from Mapserver. I have used Mapserver a lot in the past ([https://mapserver.org/ogc/wcs\_format.html](https://mapserver.org/ogc/wcs_format.html)) for serving time series data and I can look into creating a time series Mapserver demo with TileDB.

Are you able to share your existing map file so I can see what you are currently doing (or email me directly norman [tiledb.com](http://tiledb.com)), but lets keep the general discussion on this forum.

---

<div class="post-metadata">

**Author:** ![djhoese](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.tiledb.com/djhoese/32/43_2.png) [@djhoese](https://forum.tiledb.com/u/djhoese)\
**Post date:** [December 13, 2019, 6:50pm UTC](https://forum.tiledb.com/t/appending-removing-data-along-a-time-dimension/125/5 "2019-12-13T18:50:17Z")

</div>

So right now I don’t really have a working mapfile and am waiting on some guidance from the mapserver folks: [https://lists.osgeo.org/pipermail/mapserver-users/2019-December/081517.html](https://lists.osgeo.org/pipermail/mapserver-users/2019-December/081517.html)

The main issues (besides my lack of experience with mapserver and tiledb) I have are that the data I want to serve is in a non-EPSG projection and I would like to avoid resampling it. The other issue is not knowing what’s possible by pointing to a TileDB backend. I liked what I saw from TileDB and where it seems TileDB is going so wanted to try it out. The other is really not understanding if or how mapserver supports **updating** data sources in the time dimension (`wms_timeextent`).

I based what I have so far on the existing example on the tiledb docs:

```
LAYER
  NAME "goes16_fldk_true_color"
  TYPE RASTER
  DATA "/data/goes16_fldk_true_color"
  OFFSITE 0 0 0
  PROJECTION
    # "+proj=geos +sweep=x +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs"
    AUTO
  END
  METADATA
    "wms_title" "CSPP Geo Geo2Grid GOES-16 Full Disk True Color"
    "wms_timeextent" "2019-01-01/2021-01-01"
    #"wms_timedefault" "2019-05-01 10:11:12"
    "wms_timeitem" "TIFFTAG_DATETIME"
    "wms_enable_request" "*"
  END
  FILTER (`[TIFFTAG_DATETIME]`=`2019-02-01 01:02:03`)
END

```

If I have to make a shapefile to specify the time indexing then that’s too bad but I understand. I wonder if the TileDB GDAL driver could be updated/changed (if needed) to filter queries by dimension (like time or elevation) like PostGIS can (from what I’ve read).
