Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@ icon: laptop-code
---

```go
func (datasetClient) Create(
func (datasetClient) CreateOrUpdate(
ctx context.Context,
name string,
kind datasets.DatasetKind,
codeName string,
description string,
name string,
fields []Field,
) (*datasets.Dataset, error)
```

Create a dataset.
Create a dataset or update an existing one, if a dataset with the given `codeName` already exists.

## Parameters

<ParamField path="name" type="string">
The name of the dataset
</ParamField>
<ParamField path="kind" type="datasets.DatasetKind">
The kind of the dataset
</ParamField>
<ParamField path="codeName" type="string">
The code name of the dataset
</ParamField>
<ParamField path="description" type="string">
The description of the dataset
<ParamField path="name" type="string">
The name of the dataset
</ParamField>
<ParamField path="fields" type="[]Field">
The fields of the dataset
Expand Down Expand Up @@ -95,11 +91,10 @@ The created dataset object.

<RequestExample>
```go Go
dataset, err := client.Datasets.Create(ctx,
"My personal catalog",
dataset, err := client.Datasets.CreateOrUpdate(ctx,
datasets.KindSpatiotemporal,
"my_catalog",
"A description of my catalog",
"My personal catalog",
[]Field{
field.String("field1"),
field.Int64("field2").Repeated(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: Client.create_dataset
title: Client.create_or_update_dataset
sidebarTitle: Client.create_or_update...
icon: laptop-code
---

```python
def Client.create_dataset(
def Client.create_or_update_dataset(
kind: DatasetKind,
code_name: str,
fields: list[FieldDict],
*,
name: str | None = None,
description: str | None = None
) -> Dataset
```

Expand All @@ -30,9 +30,6 @@ Create a dataset.
<ParamField path="name" type="str | None">
The name of the dataset
</ParamField>
<ParamField path="description" type="str | None">
A short description of the dataset
</ParamField>

## Dataset kinds

Expand Down
14 changes: 8 additions & 6 deletions datasets/concepts/datasets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ Once you have your dataset object, you can use it to [list the available collect
In python, if you're using an IDE or an interactive environment with auto-complete, you can use it on your client instance to discover the datasets available to you. Type `client.` and trigger auto-complete after the dot to do so.
</Tip>

## Creating a dataset
## Creating / Updating a dataset

You can create a dataset in code or using the Console (cf [Creating a dataset using the Console](/guides/datasets/create)).
You can create a dataset using the [Tilebox Console](/guides/datasets/create) or by using one of the available [client SDKs](/sdks/introduction).

<CodeGroup>
```python Python
Expand All @@ -161,7 +161,7 @@ from tilebox.datasets.data.datasets import DatasetKind

client = Client()

dataset = client.create_dataset(
dataset = client.create_or_update_dataset(
DatasetKind.SPATIOTEMPORAL,
"my_landsat8_oli_tirs",
[
Expand All @@ -185,15 +185,13 @@ dataset = client.create_dataset(
},
],
name="Personal Landsat-8 catalog",
description="This catalog contains metadata for Landsat-8 OLI-TIRS data.",
)
```
```go Go
dataset, err := client.Datasets.Create(ctx,
"Personal Landsat-8 catalog",
datasets.KindSpatiotemporal,
"my_landsat8_oli_tirs",
"This catalog contains metadata for Landsat-8 OLI-TIRS data.",
"Personal Landsat-8 catalog",
[]datasets.Field{
field.String("granule_name").Description("The name of the Earth View Granule").ExampleValue("20220830_185202_SN18_10N_552149_5297327"),
field.Float64("cloud_cover").Description("Cloud cover percentage").ExampleValue("91"),
Expand All @@ -206,6 +204,10 @@ dataset, err := client.Datasets.Create(ctx,
This code will create a new catalog with 7 fields in total.
4 of those fields are auto-generated by choosing the spatio-temporal dataset type, and 3 (`granule_name`, `cloud_cover`, `proj_shape`) are custom fields that are defined.

<Tip>
If a dataset with the same `code_name` already exists, it will be updated instead.
</Tip>

## Accessing a dataset

Each dataset has an automatically generated *slug* that can be used to access it. The *slug* is the name of the group, followed by a dot, followed by the dataset *code name*.
Expand Down