Last active
October 22, 2023 07:06
-
-
Save Prithwis-2023/32af11b43ce041b2a5815f6fbe6a3c36 to your computer and use it in GitHub Desktop.
OpenScientia Planetary Computer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pystac_client\n", | |
| "import planetary_computer\n", | |
| "\n", | |
| "catalog = pystac_client.Client.open(\n", | |
| " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", | |
| " modifier=planetary_computer.sign_inplace,\n", | |
| ")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stderr", | |
| "output_type": "stream", | |
| "text": [ | |
| "c:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\pystac_client\\item_search.py:835: FutureWarning: get_items() is deprecated, use items() instead\n", | |
| " warnings.warn(\n" | |
| ] | |
| }, | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Returned 1 items\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "grand_canyon = [-112.15, 36.05]\n", | |
| "search = catalog.search(\n", | |
| " collections=[\"cop-dem-glo-30\"],\n", | |
| " intersects={\"type\": \"Point\", \"coordinates\": grand_canyon},\n", | |
| ")\n", | |
| "items = list(search.get_items())\n", | |
| "print(f\"Returned {len(items)} items\")\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "['data', 'tilejson', 'rendered_preview']" | |
| ] | |
| }, | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "list(items[0].assets)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import planetary_computer\n", | |
| "import rioxarray\n", | |
| "\n", | |
| "signed_asset = planetary_computer.sign(items[0].assets[\"data\"])\n", | |
| "data = (\n", | |
| " rioxarray.open_rasterio(signed_asset.href)\n", | |
| " .squeeze()\n", | |
| " .drop(\"band\")\n", | |
| " .coarsen({\"y\": 5, \"x\": 5})\n", | |
| " .mean()\n", | |
| ")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment