Downloading landsat data and uploading shapefile #228
Replies: 1 comment
|
Thanks for the reproducible example! The first thing to note is that the URLs to download data from are in the assets of an item. Each item (in this case a Landsat scene) has multiple assets (in this case, different bands and some extra metadata files). So you would want something like filename, _ = urllib.request.urlretrieve(selected_item.assets["red"].href)to download a single file. Pete Gadomski (@gadomski) put together a little library for downloading assets of a STAC item at https://github.com/gadomski/stac-asset. (Note that our landsat STAC items currently have an issue where we have an asset for a JSON file that doesn't actually exist in blob storage).
Not currently.
I've used
Our quickstarts and tutorials are the best Planetary Computer resources. If you're looking for a general introduction to the scientific Python ecosystem, Project Pythia is a great resource. One quick note: we generally recommend computing on the data in-place and not downloading the data locally. It's fine to download small amounts of data, especially for prototyping. But if you want to run a large workload processing a lot of data, moving data out of Azure will quickly become a bottleneck. For these medium- or larger-scale workloads, you're better of putting your compute in Azure next to the data. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi All,
I am very new to MPC and currently playing around with it. I was following the documentation of Reading Data from the STACK API : https://planetarycomputer.microsoft.com/docs/quickstarts/reading-stac/. I would like to know if it's possible to download a particular data to my local drive.
Like in my case I am trying to download a single Landsat image by using urllib library however, it's not working and am getting error: Item object has no attribute href.
Here is the complete code :
``
import pystac_client
import planetary_computer
catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,)
time_range = "2023-04-01/2023-04-30"
bbox = [76.640625, 28.844674, 81.188965, 31.774878]
search = catalog.search(collections=["landsat-c2-l2"], bbox=bbox, datetime = time_range, query={"platform":{"in": ["landsat-8"]}})
items = search.get_all_items()
len(items)
import geopandas
df = geopandas.GeoDataFrame.from_features(items.to_dict(), crs="epsg:4326")
df
selected_item = min(items, key=lambda item: item.properties["eo:cloud_cover"])
print(selected_item)
from IPython.display import Image
Image(url=selected_item.assets["rendered_preview"].href, width=500)
import urllib.request
filename, _ = urllib.request.urlretrieve(selected_item.href)
``
I would also like to know if there is a way to upload custom data like admin boundaries shapefile. I was hoping to use a shapefile and clip the Landsat imagery according to it.
Additionally, are there any particular resources that one can use to get started with MPC.
All reactions