From 346cc4e13b5960fbf0f0a57cc89e6e0d4a990861 Mon Sep 17 00:00:00 2001 From: Augustin Nesson Date: Tue, 30 Jul 2024 15:35:32 +0200 Subject: [PATCH] feat: accept integers as shapefile attributes --- docs/notebooks/api_user_guide/4_search.ipynb | 2 +- eodag/utils/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/notebooks/api_user_guide/4_search.ipynb b/docs/notebooks/api_user_guide/4_search.ipynb index c131f34490..2c63e3b7a0 100644 --- a/docs/notebooks/api_user_guide/4_search.ipynb +++ b/docs/notebooks/api_user_guide/4_search.ipynb @@ -1286,7 +1286,7 @@ ")\n", "```\n", "\n", - "The location query (`continent=\"Europe\"`) is passed as a dictionary to the `locations` parameter. It accepts [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) which can come in handy when the query field has an underlying structure (e.g. see [this tutorial](../tutos/tuto_search_location_tile.ipynb) dedicated to search for products by tile(s)).\n", + "The location query (`continent=\"Europe\"`) is passed as a dictionary to the `locations` parameter. It accepts [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) which can come in handy when the query field has an underlying structure (e.g. see [this tutorial](../tutos/tuto_search_location_tile.ipynb) dedicated to search for products by tile(s)). As the `locations` parameter must be a string or a regex, please consider using a string even for names which are numbers like in the following example (`location_entity=\"1234\"`).\n", "\n", "The locations configuration is stored in the `locations_config` attribute of the `EODataAcessGateway` once instantiated. `eodag` provides a default location which is a [Natural Earth Countries](https://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-countries/) shapefile whose *ADM0_A3_US* field can be used to query specific countries by a short code such as *FRA* for *France* or *JPN* for *Japan*." ] diff --git a/eodag/utils/__init__.py b/eodag/utils/__init__.py index 44f13187cb..ad1e08abcc 100644 --- a/eodag/utils/__init__.py +++ b/eodag/utils/__init__.py @@ -1155,7 +1155,7 @@ def get_geometry_from_various( attr = locations_dict[arg]["attr"] with shapefile.Reader(locations_dict[arg]["path"]) as shp: for shaperec in shp.shapeRecords(): - if re.search(pattern, shaperec.record[attr]): + if re.search(pattern, str(shaperec.record[attr])): found = True new_geom = shape(shaperec.shape) # get geoms union