Hint

You can run this notebook in a live session with Binder.

Search for products by tile#

Built-in search by tile#

Many providers already support search by tile (Sentinel 2 MGRS tiling grid): creodias, cop_dataspace, earth_search, geodes, planetary_computer.

For these providers, you can use grid:code as search parameter using EODAG:

[1]:
from eodag import EODataAccessGateway, setup_logging

dag = EODataAccessGateway()
products = dag.search(
    provider="cop_dataspace",
    collection="S2_MSI_L1C",
    start="2018-06-01",
    end="2018-06-15",
    **{"grid:code": "MGRS-31TFK"}
)
products

[1]:
SearchResult (6)
0  EOProduct(id=S2B_MSIL1C_20180602T104019_N0500_R008_T31TFK_20230827T165546, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2B_MSIL1C_20180602T104019_N0500_R008_T31TFK_20230827T165546',
properties["start_datetime"]: '2018-06-02T10:40:19.024000Z',
properties["end_datetime"]: '2018-06-02T10:40:19.024000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-02T10:40:19.024000Z',
end_datetime: '2018-06-02T10:40:19.024000Z',
id: 'S2B_MSIL1C_20180602T104019_N0500_R008_T31TFK_20230827T165546',
instruments: ['MSI' ],
platform: 'S2B',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-08T11:12:35.805259Z',
start_datetime: '2018-06-02T10:40:19.024000Z',
title: 'S2B_MSIL1C_20180602T104019_N0500_R008_T31TFK_20230827T165546',
uid: '047c7364-4708-4061-a6ff-8e6ac995bb1a',
updated: '2025-06-21T05:05:03.199177Z',
eo:cloud_cover: 97.81695602085318,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(047c7364-4708-4061-a6ff-8e6ac995bb1a)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(f25cd74f-d6ee-49a4-9212-756d79d75150)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(f25cd74f-d6ee-49a4-9212-756d79d75150)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-27T16:55:46.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2B_OPER_MSI_L1C_DS_S2RP_20230827T165546_S20180602T104102_N05.00',
s2:datatake_id: 'GS2B_20180602T104019_006469_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 6469,
sat:relative_orbit: 8,
}
assets: (0)
geometry
thumbnail
1  EOProduct(id=S2A_MSIL1C_20180604T103021_N0500_R108_T31TFK_20230819T115015, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2A_MSIL1C_20180604T103021_N0500_R108_T31TFK_20230819T115015',
properties["start_datetime"]: '2018-06-04T10:30:21.024000Z',
properties["end_datetime"]: '2018-06-04T10:30:21.024000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-04T10:30:21.024000Z',
end_datetime: '2018-06-04T10:30:21.024000Z',
id: 'S2A_MSIL1C_20180604T103021_N0500_R108_T31TFK_20230819T115015',
instruments: ['MSI' ],
platform: 'S2A',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-10T10:49:59.192931Z',
start_datetime: '2018-06-04T10:30:21.024000Z',
title: 'S2A_MSIL1C_20180604T103021_N0500_R108_T31TFK_20230819T115015',
uid: 'fae1b0d8-8e1a-49c2-ae7f-450a77dba94d',
updated: '2025-06-21T04:30:28.672642Z',
eo:cloud_cover: 98.6563965578072,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(fae1b0d8-8e1a-49c2-ae7f-450a77dba94d)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(fc466add-95f5-49cc-b274-7f09d9d09c28)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(fc466add-95f5-49cc-b274-7f09d9d09c28)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-19T11:50:15.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2A_OPER_MSI_L1C_DS_S2RP_20230819T115015_S20180604T103550_N05.00',
s2:datatake_id: 'GS2A_20180604T103021_015406_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 15406,
sat:relative_orbit: 108,
}
assets: (0)
geometry
thumbnail
2  EOProduct(id=S2A_MSIL1C_20180607T104021_N0500_R008_T31TFK_20230818T193607, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2A_MSIL1C_20180607T104021_N0500_R008_T31TFK_20230818T193607',
properties["start_datetime"]: '2018-06-07T10:40:21.024000Z',
properties["end_datetime"]: '2018-06-07T10:40:21.024000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-07T10:40:21.024000Z',
end_datetime: '2018-06-07T10:40:21.024000Z',
id: 'S2A_MSIL1C_20180607T104021_N0500_R008_T31TFK_20230818T193607',
instruments: ['MSI' ],
platform: 'S2A',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-09T18:28:34.976953Z',
start_datetime: '2018-06-07T10:40:21.024000Z',
title: 'S2A_MSIL1C_20180607T104021_N0500_R008_T31TFK_20230818T193607',
uid: 'b1d27fbb-5892-43d0-88d4-acfbda83481e',
updated: '2025-06-21T03:40:44.839175Z',
eo:cloud_cover: 89.5087081479285,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(b1d27fbb-5892-43d0-88d4-acfbda83481e)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(d73ad556-7e4e-4908-b2db-c0e83ecc9c7c)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(d73ad556-7e4e-4908-b2db-c0e83ecc9c7c)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-18T19:36:07.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2A_OPER_MSI_L1C_DS_S2RP_20230818T193607_S20180607T104022_N05.00',
s2:datatake_id: 'GS2A_20180607T104021_015449_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 15449,
sat:relative_orbit: 8,
}
assets: (0)
geometry
thumbnail
3  EOProduct(id=S2B_MSIL1C_20180609T103019_N0500_R108_T31TFK_20230823T173246, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2B_MSIL1C_20180609T103019_N0500_R108_T31TFK_20230823T173246',
properties["start_datetime"]: '2018-06-09T10:30:19.024000Z',
properties["end_datetime"]: '2018-06-09T10:30:19.024000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-09T10:30:19.024000Z',
end_datetime: '2018-06-09T10:30:19.024000Z',
id: 'S2B_MSIL1C_20180609T103019_N0500_R108_T31TFK_20230823T173246',
instruments: ['MSI' ],
platform: 'S2B',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-13T10:55:44.513575Z',
start_datetime: '2018-06-09T10:30:19.024000Z',
title: 'S2B_MSIL1C_20180609T103019_N0500_R108_T31TFK_20230823T173246',
uid: 'b9c45bf5-e7de-45cf-aa18-c68bca2862cf',
updated: '2025-06-21T03:05:44.363912Z',
eo:cloud_cover: 43.1501740913547,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(b9c45bf5-e7de-45cf-aa18-c68bca2862cf)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(d642d09f-9303-487c-9467-babe75320a62)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(d642d09f-9303-487c-9467-babe75320a62)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-23T17:32:46.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2B_OPER_MSI_L1C_DS_S2RP_20230823T173246_S20180609T103214_N05.00',
s2:datatake_id: 'GS2B_20180609T103019_006569_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 6569,
sat:relative_orbit: 108,
}
assets: (0)
geometry
thumbnail
4  EOProduct(id=S2B_MSIL1C_20180612T104019_N0500_R008_T31TFK_20230824T092151, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2B_MSIL1C_20180612T104019_N0500_R008_T31TFK_20230824T092151',
properties["start_datetime"]: '2018-06-12T10:40:19.025000Z',
properties["end_datetime"]: '2018-06-12T10:40:19.025000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-12T10:40:19.025000Z',
end_datetime: '2018-06-12T10:40:19.025000Z',
id: 'S2B_MSIL1C_20180612T104019_N0500_R008_T31TFK_20230824T092151',
instruments: ['MSI' ],
platform: 'S2B',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-14T10:02:37.987902Z',
start_datetime: '2018-06-12T10:40:19.025000Z',
title: 'S2B_MSIL1C_20180612T104019_N0500_R008_T31TFK_20230824T092151',
uid: 'a7c56b3d-789f-4bf7-8c13-b8db49d09b29',
updated: '2025-06-21T02:11:45.870486Z',
eo:cloud_cover: 59.5307865292139,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(a7c56b3d-789f-4bf7-8c13-b8db49d09b29)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(74816668-ddd5-409e-93f8-b922677b3ef7)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(74816668-ddd5-409e-93f8-b922677b3ef7)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-24T09:21:51.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2B_OPER_MSI_L1C_DS_S2RP_20230824T092151_S20180612T104356_N05.00',
s2:datatake_id: 'GS2B_20180612T104019_006612_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 6612,
sat:relative_orbit: 8,
}
assets: (0)
geometry
thumbnail
5  EOProduct(id=S2A_MSIL1C_20180614T103021_N0500_R108_T31TFK_20230812T193420, provider=cop_dataspace)
EOProduct
provider: 'cop_dataspace',
collection: 'S2_MSI_L1C',
properties["id"]: 'S2A_MSIL1C_20180614T103021_N0500_R108_T31TFK_20230812T193420',
properties["start_datetime"]: '2018-06-14T10:30:21.024000Z',
properties["end_datetime"]: '2018-06-14T10:30:21.024000Z',
properties: (27){
constellation: 'SENTINEL-2',
datetime: '2018-06-14T10:30:21.024000Z',
end_datetime: '2018-06-14T10:30:21.024000Z',
id: 'S2A_MSIL1C_20180614T103021_N0500_R108_T31TFK_20230812T193420',
instruments: ['MSI' ],
platform: 'S2A',
providers: [{ 'name': 'ESA' , 'roles': ['producer' ] } ],
published: '2024-03-14T02:07:39.308900Z',
start_datetime: '2018-06-14T10:30:21.024000Z',
title: 'S2A_MSIL1C_20180614T103021_N0500_R108_T31TFK_20230812T193420',
uid: '2fc0b020-247c-4866-9fc6-d4161ac5689e',
updated: '2025-06-21T01:35:42.420242Z',
eo:cloud_cover: 18.804693220351,
eodag:download_link: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Products(2fc0b020-247c-4866-9fc6-d4161ac5689e)/$value',
eodag:quicklook: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(0c3e0f03-2f23-47a4-994c-12cf770d7d13)/$value',
eodag:thumbnail: 'https://catalogue.dataspace.copernicus.eu/odata/v1/Assets(0c3e0f03-2f23-47a4-994c-12cf770d7d13)/$value',
grid:code: 'MGRS-31TFK',
order:status: 'succeeded',
processing:datetime: '2023-08-12T19:34:20.000000Z',
processing:level: 'S2MSI1C',
processing:version: '05.00',
product:type: 'S2MSI1C',
s2:datastrip_id: 'S2A_OPER_MSI_L1C_DS_S2RP_20230812T193420_S20180614T103021_N05.00',
s2:datatake_id: 'GS2A_20180614T103021_015549_N05.00',
s2:datatake_type: 'INS-NOBS',
sat:absolute_orbit: 15549,
sat:relative_orbit: 108,
}
assets: (0)
geometry
thumbnail
[2]:
[p.properties["grid:code"] for p in products]
[2]:
['MGRS-31TFK',
 'MGRS-31TFK',
 'MGRS-31TFK',
 'MGRS-31TFK',
 'MGRS-31TFK',
 'MGRS-31TFK']

Search by tile using custom locations#

eodag allows to search for products by geometric features that match a location query, see the API user guide for an introduction to this concept.

In this tutorial we will use a shapefile that represents the Sentinel 2 tiling grid to search for Sentinel 2 Level-1C products with cop_dataspace at a specific tile. In this shapefile each tile is defined by its centroid and a tile_id attribute (e.g. 29PMT). This shapefile was created by downloading first the Sentinel 2 tiling grid (MGRS) provided by ESA as a KML file. It was then converted as a shapefile and processed to compute the centroids. We use the tile’s centroid here as eodag returns products that intersects the user defined search area. Since tiles overlap with each other, using the polygons instead of the centroids would return more tiles than just the one we target.

[3]:
import os
from zipfile import ZipFile

# Interactive mapping
import folium
from folium.plugins import TimestampedGeoJson
# pyshp: to read shapefiles
import shapefile

Setup#

A workspace directory is created to store the files that will be generated.

[4]:
workspace = "eodag_workspace_locations_tiles"
if not os.path.isdir(workspace):
    os.mkdir(workspace)

You should have an auxdata folder next to this tutorial’s file. It contains a shapefile that is needed to run this tutorial correctly.

[5]:
sentinel2_grid_zip = os.path.join("auxdata", "sentinel2_tiling_grid_centroids.zip")
if not os.path.isfile(sentinel2_grid_zip):
    raise FileNotFoundError("Auxdata not found, please check your configuration.")
[6]:
# We unzip the archived shapefile.
with ZipFile(sentinel2_grid_zip, "r") as fzip:
    fzip.extractall("auxdata")

In this tutorial products will just be searched for, not downloaded. We don’t need to set up cop_dataspace credentials to search for products. If you wish to download them, you should set the credentials beforehand, using these two environment variables for instance.

[7]:
# os.environ["EODAG__COP_DATASPACE__AUTH__CREDENTIALS__USERNAME"] = "PLEASE_CHANGE_ME"
# os.environ["EODAG__COP_DATASPACE__AUTH__CREDENTIALS__PASSWORD"] = "PLEASE_CHANGE_ME"

Logging is activated to better inspect what eodag does internally.

[8]:
setup_logging(2)  # INFO level

The default search criteria consists of a time period in June 2018 and eodag’s collection identifier for Sentinel 2 Level-1C products.

[9]:
default_search_criteria = dict(
    collection="S2_MSI_L1C",
    start="2018-06-01",
    end="2018-06-15"
)

Add a locations configuration#

We check and store the content of this shapefile.

[10]:
sentinel2_shp = os.path.join('auxdata', 'sentinel2_tiling_grid_centroids.shp')
with shapefile.Reader(sentinel2_shp) as shp:
    print(shp, "\n")
    print("fields:", shp.fields)
    shaperecs = shp.shapeRecords()
shapefile Reader
    56686 shapes (type 'POINT')
    56686 records (2 fields)

fields: [Field(name="DeletionFlag", field_type=FieldType.C, size=1, decimal=0), Field(name="tile_id", field_type=FieldType.C, size=5, decimal=0)]

It has about 57 000 tiles/polygons and a field tile_id.

We create a YAML file to configure this new location selector, we will refer to it with s2_tile_centroid.

[11]:
# Save the locations configuration file.
locations_yaml_content = """
shapefiles:
  - name: s2_tile_centroid
    path: {}
    attr: tile_id
""".format(os.path.abspath(sentinel2_shp))

locations_filepath = os.path.abspath(os.path.join(workspace, "custom_locations.yml"))

with open(locations_filepath, "w") as f_yml:
    f_yml.write(locations_yaml_content.strip())

An instance of an EODataAccessGateway class is created, it makes use of this location configuration file.

[12]:
dag = EODataAccessGateway(locations_conf_path=locations_filepath)
2026-03-27 16:57:54,440 eodag.provider                   [INFO    ] Loading user configuration from: /home/sbrunato/.config/eodag/eodag.yml
2026-03-27 16:57:54,449 eodag.provider                   [WARNING ] peps: could not create provider from scratch using config
2026-03-27 16:57:54,452 eodag.core                       [INFO    ] aws_eos: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,452 eodag.core                       [INFO    ] cop_cds: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,452 eodag.core                       [INFO    ] meteoblue: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] hydroweb_next: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] wekeo_ecmwf: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] creodias_s3: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] dedt_lumi: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] dedt_mn5: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] geodes_s3: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,453 eodag.core                       [INFO    ] cop_ewds: provider needing auth for search has been pruned because no credentials could be found
2026-03-27 16:57:54,455 eodag.core                       [INFO    ] Locations configuration loaded from /home/sbrunato/workspace/eodag/docs/notebooks/tutos/eodag_workspace_locations_tiles/custom_locations.yml

We want to look for Sentinel 2 Level-1C products. We can check whether this collection is offered by cop_dataspace (as configured in eodag). If so, cop_dataspace is set as the provider used to search for products.

[13]:
"S2_MSI_L1C" in dag.providers["cop_dataspace"].collections_config
[13]:
True