Skip to content

Ingesting Data

Populate your dataset collections by defining schemas, preparing structured data points, and submitting them efficiently to Tilebox for storage and querying.

Check out the examples below for common scenarios of ingesting data into a collection.

Tilebox Datasets are strongly typed. This means you can only ingest data that matches the schema of a dataset. The schema is defined during dataset creation time.

The examples on this page assume that you have access to a Timeseries dataset that has the following schema:

MyCustomDataset schema

MyCustomDataset schema

Field nameTypeDescription
timeTimestampTimestamp of the data point. Required by the Timeseries dataset type.
idUUIDAuto-generated UUID for each datapoint.
ingestion_timeTimestampAuto-generated timestamp for when the data point was ingested into the Tilebox API.
valuefloat64A numeric measurement value.
sensorstringA name of the sensor that generated the data point.
precise_timeTimestampA precise measurement time in nanosecond precision.
sensor_historyArray[float64]The last few measurements of the sensor.

Once you’ve defined the schema and created a dataset, you can access it and create a collection to ingest data into.

from tilebox.datasets import Client
client = Client()
dataset = client.dataset("my_org.my_custom_dataset")
collection = dataset.get_or_create_collection("Measurements")

Ingestion is available in Python and Go.

Every datapoint passed to collection.ingest must include time. Omit id and ingestion_time; Tilebox generates both fields during ingestion.

Use an iterable of mappings when you construct datapoints individually. Optional fields can be absent from individual records. None and common tabular missing values also leave optional fields unset.

Python
records = [
{
"time": "2025-03-28T11:44:23Z",
"value": 45.16,
"sensor": "A",
"sensor_history": [-12.15, 13.45, -8.2, 16.5, 45.16],
},
{
"time": "2025-03-28T11:45:19Z",
"value": 273.15,
"sensor": "B",
},
]
datapoint_ids = collection.ingest(records)

Use a mapping of field names to equally sized sequences when your data is already organized by column.

Python
columns = {
"time": [
"2025-03-28T11:44:23Z",
"2025-03-28T11:45:19Z",
],
"value": [45.16, 273.15],
"sensor": ["A", "B"],
}
collection.ingest(columns)

Tilebox treats each DataFrame row as one datapoint and maps column names to dataset fields.

Python
import pandas as pd
data = pd.DataFrame({
"time": [
"2025-03-28T11:44:23Z",
"2025-03-28T11:45:19Z",
],
"value": [45.16, 273.15],
"sensor": ["A", "B"],
})
collection.ingest(data)

Tilebox also accepts xarray.Dataset, the format returned when querying data.

Python
import numpy as np
import xarray as xr
data = xr.Dataset({
"time": ("time", [
"2025-03-28T11:46:13Z",
"2025-03-28T11:46:54Z",
]),
"value": ("time", [48.1, 290.12]),
"sensor_history": (("time", "n_sensor_history"), [
[13.45, -8.2, 16.5, 45.16, 48.1],
[280.12, 273.15, 290.12, np.nan, np.nan],
]),
})
collection.ingest(data)

Client.Datapoints.Ingest supports ingestion of data points in the form of a slice of protobuf messages.

Protobuf is Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data.

More details on protobuf can be found in the protobuf section.

In the example below, the v1.Modis type has been generated with tilebox dataset generate, as described in the protobuf section.

Go
datapoints := []*v1.Modis{
v1.Modis_builder{
Time: timestamppb.New(time.Now()),
GranuleName: proto.String("Granule 1"),
}.Build(),
v1.Modis_builder{
Time: timestamppb.New(time.Now().Add(-5 * time.Hour)),
GranuleName: proto.String("Past Granule 2"),
}.Build(),
}
ingestResponse, err := client.Datapoints.Ingest(ctx,
collectionID,
&datapoints
false,
)

Since ingest takes query’s output as input, you can easily copy or move data from one collection to another.

src_collection = dataset.collection("Measurements")
data_to_copy = src_collection.query(temporal_extent=("2025-03-28", "2025-03-29"))
dest_collection = dataset.collection("OtherMeasurements")
dest_collection.ingest(data_to_copy) # copy the data to the other collection
# To verify it now contains 4 datapoints (2 we ingested already, and 2 we copied just now)
print(dest_collection.info())
OtherMeasurements: [2025-03-28T11:44:23.000 UTC, 2025-03-28T11:46:54.000 UTC] (4 data points)

Tilebox automatically batches the ingestion requests for you, so you don’t have to worry about the maximum request size.

Tilebox will auto-generate datapoint IDs based on the data of all its fields - except for the auto-generated ingestion_time, so ingesting the same data twice will result in the same ID being generated. By default, Tilebox will silently skip any data points that are duplicates of existing ones in a collection. This behavior is especially useful when implementing idempotent algorithms. That way, re-executions of certain ingestion tasks due to retries or other reasons will never result in duplicate data points.

You can instead also request an error to be raised if any of the generated datapoint IDs already exist. This can be done by setting the allow_existing parameter to False.

data = pd.DataFrame({
"time": [
"2025-03-28T11:45:19Z",
],
"value": [45.16],
"sensor": ["A"],
"precise_time": [
"2025-03-28T11:44:23.345761444Z",
],
"sensor_history": [
[-12.15, 13.45, -8.2, 16.5, 45.16],
],
})
# we already ingested the same data point previously
collection.ingest(data, allow_existing=False)
# we can still ingest it, by setting allow_existing=True
# but the total number of datapoints will still be the same
# as before in that case, since it already exists and therefore
# will be skipped
collection.ingest(data, allow_existing=True) # no-op
ArgumentError: found existing datapoints with same id, refusing to ingest with "allow_existing=false"

Through the usage of xarray and pandas you can also easily ingest existing datasets available in file formats, such as CSV, Parquet, Feather and more.

Check out the Ingestion from common file formats guide for examples of how to achieve this.

To ingest datapoints that reference files in external storage, see Reference assets in a dataset.

Ingesting Geometries can traditionally be a bit tricky, especially when working with geometries that cross the antimeridian or cover a pole. Tilebox is designed to take away most of the friction involved in this, but it’s still recommended to follow the best practices for handling geometries.