From e66607878a980d018b72bba52364e0706579740e Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 16 Oct 2024 10:47:52 -0600 Subject: [PATCH] Release v0.8.4 (#742) * release: v0.8.4 * fix: keep hvplot.pandas import * fix: another import --- .pre-commit-config.yaml | 8 +- CHANGELOG.md | 5 +- docs/tutorials/aoi-coverage.ipynb | 34 ++++--- docs/tutorials/cql2-filter.ipynb | 90 +++++++------------ docs/tutorials/item-search-intersects.ipynb | 81 +++++++---------- .../pystac-client-introduction.ipynb | 80 ++++++++--------- docs/tutorials/stac-metadata-viz.ipynb | 78 ++++++++-------- pystac_client/version.py | 2 +- 8 files changed, 173 insertions(+), 205 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bef593e7..71034939 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,12 +3,12 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.5.0" + rev: "v0.6.9" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/codespell-project/codespell @@ -18,14 +18,14 @@ repos: args: [--ignore-words=.codespellignore] types_or: [jupyter, markdown, python, shell] - repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 + rev: v1.1.2 hooks: - id: doc8 args: [--ignore=D004] additional_dependencies: - importlib_metadata < 5; python_version == "3.7" - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.12.0 hooks: - id: mypy files: ".*\\.py$" diff --git a/CHANGELOG.md b/CHANGELOG.md index 340607e4..49cf6918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.8.4] - 2024-10-16 + ### Added - Support for collection search via `CollectionSearch` class and associated client methods [#735](https://github.com/stac-utils/pystac-client/pull/735) @@ -393,7 +395,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Initial release. -[Unreleased]: https://github.com/stac-utils/pystac-client/compare/v0.8.3...main +[Unreleased]: https://github.com/stac-utils/pystac-client/compare/v0.8.4...main +[v0.8.4]: https://github.com/stac-utils/pystac-client/compare/v0.8.3...v0.8.4 [v0.8.3]: https://github.com/stac-utils/pystac-client/compare/v0.8.2...v0.8.3 [v0.8.2]: https://github.com/stac-utils/pystac-client/compare/v0.8.1...v0.8.2 [v0.8.1]: https://github.com/stac-utils/pystac-client/compare/v0.8.0...v0.8.1 diff --git a/docs/tutorials/aoi-coverage.ipynb b/docs/tutorials/aoi-coverage.ipynb index d26b16f9..fb6ee174 100644 --- a/docs/tutorials/aoi-coverage.ipynb +++ b/docs/tutorials/aoi-coverage.ipynb @@ -17,13 +17,13 @@ "metadata": {}, "outputs": [], "source": [ - "from pystac_client import Client\n", + "from typing import Any, Dict\n", "\n", "import matplotlib.pyplot as plt\n", - "from shapely.geometry import shape\n", - "from pystac_client import Client\n", "from pystac.item import Item\n", - "from typing import Dict, Any" + "from shapely.geometry import shape\n", + "\n", + "from pystac_client import Client" ] }, { @@ -34,9 +34,9 @@ "outputs": [], "source": [ "def intersection_percent(item: Item, aoi: Dict[str, Any]) -> float:\n", - " '''The percentage that the Item's geometry intersects the AOI. An Item that\n", + " \"\"\"The percentage that the Item's geometry intersects the AOI. An Item that\n", " completely covers the AOI has a value of 100.\n", - " '''\n", + " \"\"\"\n", " geom_item = shape(item.geometry)\n", " geom_aoi = shape(aoi)\n", "\n", @@ -48,7 +48,7 @@ "\n", "\n", "# STAC API root URL\n", - "URL = 'https://planetarycomputer.microsoft.com/api/stac/v1'\n", + "URL = \"https://planetarycomputer.microsoft.com/api/stac/v1\"\n", "\n", "# geometry of the AOI to search over\n", "intersects_geometry = {\n", @@ -79,7 +79,12 @@ "metadata": {}, "outputs": [], "source": [ - "print([f\"{intersection_percent(item, intersects_geometry):.2f}\" for item in item_search.items()])" + "print(\n", + " [\n", + " f\"{intersection_percent(item, intersects_geometry):.2f}\"\n", + " for item in item_search.items()\n", + " ]\n", + ")" ] }, { @@ -105,19 +110,20 @@ "# Render the AOI and Item results\n", "# The green shape is the AOI\n", "# The blue shapes are the Item geometries\n", - "# If there are no blue shapes, adjust the intersection percent filter above until there are\n", + "# If there are no blue shapes, adjust the intersection percent filter above\n", + "# until there are\n", "\n", - "cm = plt.get_cmap('RdBu')\n", + "cm = plt.get_cmap(\"RdBu\")\n", "fig, axs = plt.subplots()\n", - "axs.set_aspect('equal', 'datalim')\n", + "axs.set_aspect(\"equal\", \"datalim\")\n", "\n", "for item in items_gt_5_percent:\n", - " xs, ys = shape(item.geometry).exterior.xy\n", - " axs.fill(xs, ys, alpha=0.5, fc='b', ec='none')\n", + " xs, ys = shape(item.geometry).exterior.xy\n", + " axs.fill(xs, ys, alpha=0.5, fc=\"b\", ec=\"none\")\n", "\n", "geom_intersects = shape(intersects_geometry)\n", "xs, ys = geom_intersects.exterior.xy\n", - "axs.fill(xs, ys, alpha=0.5, fc='g', ec='none')\n", + "axs.fill(xs, ys, alpha=0.5, fc=\"g\", ec=\"none\")\n", "\n", "plt.show()" ] diff --git a/docs/tutorials/cql2-filter.ipynb b/docs/tutorials/cql2-filter.ipynb index 0c4fafa7..5e05ee21 100644 --- a/docs/tutorials/cql2-filter.ipynb +++ b/docs/tutorials/cql2-filter.ipynb @@ -20,32 +20,33 @@ "metadata": {}, "outputs": [], "source": [ - "from pystac_client import Client\n", - "\n", "# set pystac_client logger to DEBUG to see API calls\n", "import logging\n", - "logging.basicConfig()\n", - "logger = logging.getLogger('pystac_client')\n", - "logger.setLevel(logging.INFO)\n", - "\n", - "# function for creating GeoDataFrame from Items\n", "from copy import deepcopy\n", + "\n", "import geopandas as gpd\n", "import pandas as pd\n", "from shapely.geometry import shape\n", "\n", + "from pystac_client import Client\n", + "\n", + "logging.basicConfig()\n", + "logger = logging.getLogger(\"pystac_client\")\n", + "logger.setLevel(logging.INFO)\n", + "\n", + "\n", "# convert a list of STAC Items into a GeoDataFrame\n", "def items_to_geodataframe(items):\n", " _items = []\n", " for i in items:\n", " _i = deepcopy(i)\n", - " _i['geometry'] = shape(_i['geometry'])\n", + " _i[\"geometry\"] = shape(_i[\"geometry\"])\n", " _items.append(_i)\n", " gdf = gpd.GeoDataFrame(pd.json_normalize(_items))\n", - " for field in ['properties.datetime', 'properties.created', 'properties.updated']:\n", + " for field in [\"properties.datetime\", \"properties.created\", \"properties.updated\"]:\n", " if field in gdf:\n", " gdf[field] = pd.to_datetime(gdf[field])\n", - " gdf.set_index('properties.datetime', inplace=True)\n", + " gdf.set_index(\"properties.datetime\", inplace=True)\n", " return gdf" ] }, @@ -57,7 +58,7 @@ "outputs": [], "source": [ "# STAC API root URL\n", - "URL = 'https://planetarycomputer.microsoft.com/api/stac/v1'\n", + "URL = \"https://planetarycomputer.microsoft.com/api/stac/v1\"\n", "\n", "# custom headers\n", "headers = []\n", @@ -82,33 +83,22 @@ "metadata": {}, "outputs": [], "source": [ + "import json\n", + "\n", + "import hvplot.pandas # noqa: F401\n", + "\n", "# AOI around Delfzijl, in the north of The Netherlands\n", "geom = {\n", " \"type\": \"Polygon\",\n", " \"coordinates\": [\n", - " [\n", - " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", - " ],\n", - " [\n", - " 7.344360351562499,\n", - " 53.174765470134616\n", - " ],\n", - " [\n", - " 7.344360351562499,\n", - " 53.67393435835391\n", - " ],\n", - " [\n", - " 6.42425537109375,\n", - " 53.67393435835391\n", - " ],\n", " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", + " [6.42425537109375, 53.174765470134616],\n", + " [7.344360351562499, 53.174765470134616],\n", + " [7.344360351562499, 53.67393435835391],\n", + " [6.42425537109375, 53.67393435835391],\n", + " [6.42425537109375, 53.174765470134616],\n", " ]\n", - " ]\n", - " ]\n", + " ],\n", "}\n", "\n", "params = {\n", @@ -118,20 +108,20 @@ " \"datetime\": \"2018-01-01/2020-12-31\",\n", "}\n", "\n", - "import hvplot.pandas\n", - "import json\n", "\n", "# reusable search function\n", "def search_fetch_plot(params, filt):\n", " # limit sets the # of items per page so we can see multiple pages getting fetched\n", - " params['filter'] = filt\n", + " params[\"filter\"] = filt\n", " search = cat.search(**params)\n", - " items = list(search.items_as_dicts()) # safe b/c we set max_items = 100\n", + " items = list(search.items_as_dicts()) # safe b/c we set max_items = 100\n", " # DataFrame\n", " items_df = pd.DataFrame(items_to_geodataframe(items))\n", " print(f\"{len(items_df.index)} items found\")\n", - " field = 'properties.eo:cloud_cover'\n", - " return items_df.hvplot(y=field, label=json.dumps(filt), frame_height=500, frame_width=800) " + " field = \"properties.eo:cloud_cover\"\n", + " return items_df.hvplot(\n", + " y=field, label=json.dumps(filt), frame_height=500, frame_width=800\n", + " )" ] }, { @@ -151,10 +141,7 @@ "metadata": {}, "outputs": [], "source": [ - "filt = {\n", - " \"op\": \"lte\",\n", - " \"args\": [{\"property\": \"eo:cloud_cover\"}, 10]\n", - "}\n", + "filt = {\"op\": \"lte\", \"args\": [{\"property\": \"eo:cloud_cover\"}, 10]}\n", "\n", "search_fetch_plot(params, filt)" ] @@ -166,10 +153,7 @@ "metadata": {}, "outputs": [], "source": [ - "filt = {\n", - " \"op\": \"gte\",\n", - " \"args\" : [{\"property\": \"eo:cloud_cover\"}, 80]\n", - "}\n", + "filt = {\"op\": \"gte\", \"args\": [{\"property\": \"eo:cloud_cover\"}, 80]}\n", "\n", "search_fetch_plot(params, filt)" ] @@ -181,18 +165,12 @@ "metadata": {}, "outputs": [], "source": [ - "filt = { \n", + "filt = {\n", " \"op\": \"and\",\n", " \"args\": [\n", - " { \n", - " \"op\":\"lte\", \n", - " \"args\": [{\"property\": \"eo:cloud_cover\"}, 60]\n", - " },\n", - " { \n", - " \"op\": \"gte\", \n", - " \"args\": [{\"property\": \"eo:cloud_cover\"}, 40]\n", - " }\n", - " ]\n", + " {\"op\": \"lte\", \"args\": [{\"property\": \"eo:cloud_cover\"}, 60]},\n", + " {\"op\": \"gte\", \"args\": [{\"property\": \"eo:cloud_cover\"}, 40]},\n", + " ],\n", "}\n", "\n", "search_fetch_plot(params, filt)" diff --git a/docs/tutorials/item-search-intersects.ipynb b/docs/tutorials/item-search-intersects.ipynb index 6870879e..bd177dc9 100644 --- a/docs/tutorials/item-search-intersects.ipynb +++ b/docs/tutorials/item-search-intersects.ipynb @@ -29,12 +29,13 @@ }, "outputs": [], "source": [ - "from pystac_client import Client\n", - "from typing import Any, Dict\n", "import json\n", + "from typing import Any, Dict\n", + "\n", + "from pystac_client import Client\n", "\n", "# STAC API root URL\n", - "URL = 'https://planetarycomputer.microsoft.com/api/stac/v1'\n", + "URL = \"https://planetarycomputer.microsoft.com/api/stac/v1\"\n", "\n", "client = Client.open(URL)" ] @@ -79,36 +80,13 @@ "# AOI around Delfzijl, in northern Netherlands\n", "aoi_as_dict: Dict[str, Any] = {\n", " \"type\": \"Polygon\",\n", - " \"coordinates\": [\n", - " [\n", - " [\n", - " 6,\n", - " 53\n", - " ],\n", - " [\n", - " 7,\n", - " 53\n", - " ],\n", - " [\n", - " 7,\n", - " 54\n", - " ],\n", - " [\n", - " 6,\n", - " 54\n", - " ],\n", - " [\n", - " 6,\n", - " 53\n", - " ]\n", - " ]\n", - " ]\n", + " \"coordinates\": [[[6, 53], [7, 53], [7, 54], [6, 54], [6, 53]]],\n", "}\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_dict,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_dict,\n", ")\n", "\n", "print(f\"AOI as dictionary, found {len(list(search.items()))} items\")" @@ -131,12 +109,12 @@ }, "outputs": [], "source": [ - "aoi_as_str: str = json.dumps(aoi_as_dict)\n", + "aoi_as_str: str = json.dumps(aoi_as_dict)\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_str,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_str,\n", ")\n", "\n", "print(f\"AOI as string, found {len(list(search.items()))} items\")" @@ -164,22 +142,28 @@ "aoi_as_shapely_shape = shapely.geometry.shape(aoi_as_dict)\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_shapely_shape,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_shapely_shape,\n", ")\n", "\n", - "print(f\"AOI as Shapely Geometry object from shape(), found {len(list(search.items()))} items\")\n", + "print(\n", + " \"AOI as Shapely Geometry object from shape(), \"\n", + " f\"found {len(list(search.items()))} items\"\n", + ")\n", "\n", "aoi_as_shapely_polygon = shapely.geometry.Polygon(aoi_as_dict[\"coordinates\"][0])\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_shapely_polygon,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_shapely_polygon,\n", ")\n", "\n", - "print(f\"AOI as Shapely Geometry object with Polygon, found {len(list(search.items()))} items\")" + "print(\n", + " \"AOI as Shapely Geometry object with Polygon, \"\n", + " f\"found {len(list(search.items()))} items\"\n", + ")" ] }, { @@ -204,9 +188,9 @@ "aoi_as_geojson_polygon = geojson.Polygon(aoi_as_dict[\"coordinates\"])\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_geojson_polygon,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_geojson_polygon,\n", ")\n", "\n", "print(f\"AOI as geojson Polygon, found {len(list(search.items()))} items\")" @@ -230,12 +214,13 @@ "outputs": [], "source": [ "import pygeoif\n", + "\n", "aoi_as_pygeoif_polygon = pygeoif.geometry.Polygon(aoi_as_dict[\"coordinates\"][0])\n", "\n", "search = client.search(\n", - " max_items = 25,\n", - " collections = \"aster-l1t\",\n", - " intersects = aoi_as_pygeoif_polygon,\n", + " max_items=25,\n", + " collections=\"aster-l1t\",\n", + " intersects=aoi_as_pygeoif_polygon,\n", ")\n", "\n", "print(f\"AOI as pygeoif Polygon, found {len(list(search.items()))} items\")" diff --git a/docs/tutorials/pystac-client-introduction.ipynb b/docs/tutorials/pystac-client-introduction.ipynb index 894c9e8a..7cff52af 100644 --- a/docs/tutorials/pystac-client-introduction.ipynb +++ b/docs/tutorials/pystac-client-introduction.ipynb @@ -17,12 +17,13 @@ "metadata": {}, "outputs": [], "source": [ - "from pystac_client import Client\n", - "\n", "# set pystac_client logger to DEBUG to see API calls\n", "import logging\n", + "\n", + "from pystac_client import Client\n", + "\n", "logging.basicConfig()\n", - "logger = logging.getLogger('pystac_client')\n", + "logger = logging.getLogger(\"pystac_client\")\n", "logger.setLevel(logging.DEBUG)" ] }, @@ -46,7 +47,7 @@ "outputs": [], "source": [ "# STAC API root URL\n", - "URL = 'https://planetarycomputer.microsoft.com/api/stac/v1'\n", + "URL = \"https://planetarycomputer.microsoft.com/api/stac/v1\"\n", "\n", "# custom headers\n", "headers = []\n", @@ -125,7 +126,7 @@ "metadata": {}, "outputs": [], "source": [ - "collection = cat.get_collection('aster-l1t')\n", + "collection = cat.get_collection(\"aster-l1t\")\n", "collection" ] }, @@ -148,6 +149,7 @@ "source": [ "items = collection.get_items()\n", "\n", + "\n", "# flush stdout so we can see the exact order that things happen\n", "def get_ten_items(items):\n", " for i, item in enumerate(items):\n", @@ -155,10 +157,11 @@ " if i == 9:\n", " return\n", "\n", - "print('First page', flush=True)\n", + "\n", + "print(\"First page\", flush=True)\n", "get_ten_items(items)\n", "\n", - "print('Second page', flush=True)\n", + "print(\"Second page\", flush=True)\n", "get_ten_items(items)" ] }, @@ -183,38 +186,23 @@ "geom = {\n", " \"type\": \"Polygon\",\n", " \"coordinates\": [\n", - " [\n", " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", - " ],\n", - " [\n", - " 7.344360351562499,\n", - " 53.174765470134616\n", - " ],\n", - " [\n", - " 7.344360351562499,\n", - " 53.67393435835391\n", - " ],\n", - " [\n", - " 6.42425537109375,\n", - " 53.67393435835391\n", - " ],\n", - " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", + " [6.42425537109375, 53.174765470134616],\n", + " [7.344360351562499, 53.174765470134616],\n", + " [7.344360351562499, 53.67393435835391],\n", + " [6.42425537109375, 53.67393435835391],\n", + " [6.42425537109375, 53.174765470134616],\n", " ]\n", - " ]\n", - " ]\n", + " ],\n", "}\n", "\n", "# limit sets the # of items per page so we can see multiple pages getting fetched\n", "search = cat.search(\n", - " max_items = 15,\n", - " limit = 5,\n", - " collections = \"aster-l1t\",\n", - " intersects = geom,\n", - " datetime = \"2000-01-01/2010-12-31\",\n", + " max_items=15,\n", + " limit=5,\n", + " collections=\"aster-l1t\",\n", + " intersects=geom,\n", + " datetime=\"2000-01-01/2010-12-31\",\n", ")\n", "\n", "items = list(search.items())\n", @@ -233,7 +221,6 @@ "\n", "import IPython.display\n", "\n", - "\n", "IPython.display.JSON([i.to_dict() for i in items])" ] }, @@ -248,7 +235,9 @@ "\n", "import json\n", "import uuid\n", - "from IPython.display import display_javascript, display_html, display\n", + "\n", + "from IPython.display import display_html, display_javascript\n", + "\n", "\n", "class RenderJSON(object):\n", " def __init__(self, json_data):\n", @@ -259,13 +248,22 @@ " self.uuid = str(uuid.uuid4())\n", "\n", " def _ipython_display_(self):\n", - " display_html('
'.format(self.uuid), raw=True)\n", - " display_javascript(\"\"\"\n", - " require([\"https://rawgit.com/caldwell/renderjson/master/renderjson.js\"], function() {\n", - " renderjson.set_show_to_level(2);\n", - " document.getElementById('%s').appendChild(renderjson(%s))\n", + " display_html(\n", + " '
'.format(self.uuid),\n", + " raw=True,\n", + " )\n", + " display_javascript(\n", + " \"\"\"\n", + " require([\"https://rawgit.com/caldwell/renderjson/master/renderjson.js\"],\n", + " function() {\n", + " renderjson.set_show_to_level(2);\n", + " document.getElementById('%s').appendChild(renderjson(%s))\n", " });\n", - " \"\"\" % (self.uuid, self.json_str), raw=True)\n", + " \"\"\"\n", + " % (self.uuid, self.json_str),\n", + " raw=True,\n", + " )\n", "\n", "\n", "RenderJSON([i.to_dict() for i in items])" diff --git a/docs/tutorials/stac-metadata-viz.ipynb b/docs/tutorials/stac-metadata-viz.ipynb index 88d35b1a..9bf62710 100644 --- a/docs/tutorials/stac-metadata-viz.ipynb +++ b/docs/tutorials/stac-metadata-viz.ipynb @@ -19,12 +19,13 @@ "metadata": {}, "outputs": [], "source": [ - "from pystac_client import Client\n", - "\n", "# set pystac_client logger to DEBUG to see API calls\n", "import logging\n", + "\n", + "from pystac_client import Client\n", + "\n", "logging.basicConfig()\n", - "logger = logging.getLogger('pystac_client')\n", + "logger = logging.getLogger(\"pystac_client\")\n", "logger.setLevel(logging.DEBUG)" ] }, @@ -44,7 +45,7 @@ "outputs": [], "source": [ "# STAC API root URL\n", - "URL = 'https://planetarycomputer.microsoft.com/api/stac/v1'\n", + "URL = \"https://planetarycomputer.microsoft.com/api/stac/v1\"\n", "\n", "# custom headers\n", "headers = []\n", @@ -76,37 +77,22 @@ "geom = {\n", " \"type\": \"Polygon\",\n", " \"coordinates\": [\n", - " [\n", - " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", - " ],\n", " [\n", - " 7.344360351562499,\n", - " 53.174765470134616\n", - " ],\n", - " [\n", - " 7.344360351562499,\n", - " 53.67393435835391\n", - " ],\n", - " [\n", - " 6.42425537109375,\n", - " 53.67393435835391\n", - " ],\n", - " [\n", - " 6.42425537109375,\n", - " 53.174765470134616\n", + " [6.42425537109375, 53.174765470134616],\n", + " [7.344360351562499, 53.174765470134616],\n", + " [7.344360351562499, 53.67393435835391],\n", + " [6.42425537109375, 53.67393435835391],\n", + " [6.42425537109375, 53.174765470134616],\n", " ]\n", - " ]\n", - " ]\n", + " ],\n", "}\n", "\n", "# limit sets the # of items per page so we can see multiple pages getting fetched\n", "search = cat.search(\n", - " max_items = 50,\n", - " collections = \"aster-l1t\",\n", - " intersects = geom,\n", - " datetime = \"2000-01-01/2010-12-31\",\n", + " max_items=50,\n", + " collections=\"aster-l1t\",\n", + " intersects=geom,\n", + " datetime=\"2000-01-01/2010-12-31\",\n", ")\n", "\n", "# retrieve the items as dictionaries, rather than Item objects\n", @@ -134,22 +120,24 @@ "outputs": [], "source": [ "from copy import deepcopy\n", + "\n", "import geopandas as gpd\n", "import pandas as pd\n", "from shapely.geometry import shape\n", "\n", + "\n", "# convert a list of STAC Items into a GeoDataFrame\n", "def items_to_geodataframe(items):\n", " _items = []\n", " for i in items:\n", " _i = deepcopy(i)\n", - " _i['geometry'] = shape(_i['geometry'])\n", + " _i[\"geometry\"] = shape(_i[\"geometry\"])\n", " _items.append(_i)\n", " gdf = gpd.GeoDataFrame(pd.json_normalize(_items))\n", - " for field in ['properties.datetime', 'properties.created', 'properties.updated']:\n", + " for field in [\"properties.datetime\", \"properties.created\", \"properties.updated\"]:\n", " if field in gdf:\n", " gdf[field] = pd.to_datetime(gdf[field])\n", - " gdf.set_index('properties.datetime', inplace=True)\n", + " gdf.set_index(\"properties.datetime\", inplace=True)\n", " return gdf" ] }, @@ -161,7 +149,7 @@ "outputs": [], "source": [ "# convert geometry to a GeoDataFrame\n", - "aoi_gdf = gpd.GeoDataFrame([{'geometry': shape(geom)}])\n", + "aoi_gdf = gpd.GeoDataFrame([{\"geometry\": shape(geom)}])\n", "aoi_gdf" ] }, @@ -194,13 +182,23 @@ "metadata": {}, "outputs": [], "source": [ - "import hvplot.pandas\n", + "import hvplot.pandas # noqa: F401\n", + "\n", "\n", "# plot polygons on a map with background tiles.\n", "def plot_polygons(data, *args, **kwargs):\n", - " return data.hvplot.polygons(*args, geo=True, projection=\"GOOGLE_MERCATOR\", xaxis=None, yaxis=None,\n", - " frame_width=600, frame_height=600, fill_alpha=0,\n", - " line_width=4, **kwargs)" + " return data.hvplot.polygons(\n", + " *args,\n", + " geo=True,\n", + " projection=\"GOOGLE_MERCATOR\",\n", + " xaxis=None,\n", + " yaxis=None,\n", + " frame_width=600,\n", + " frame_height=600,\n", + " fill_alpha=0,\n", + " line_width=4,\n", + " **kwargs,\n", + " )" ] }, { @@ -253,9 +251,9 @@ "items_df = pd.DataFrame(items_gdf)\n", "\n", "plot_fields = [\n", - " 'properties.eo:cloud_cover',\n", - " 'properties.view:sun_azimuth',\n", - " 'properties.view:sun_elevation'\n", + " \"properties.eo:cloud_cover\",\n", + " \"properties.view:sun_azimuth\",\n", + " \"properties.view:sun_elevation\",\n", "]\n", "\n", "items_df[plot_fields].hvplot(height=500, width=800).opts(legend_position=\"top_right\")" diff --git a/pystac_client/version.py b/pystac_client/version.py index 732155f8..fa3ddd8c 100644 --- a/pystac_client/version.py +++ b/pystac_client/version.py @@ -1 +1 @@ -__version__ = "0.8.3" +__version__ = "0.8.4"