[gdal-dev] Utilisation de Planetary Computer

Thomas Gratier osgeo.mailinglist at gmail.com
Fri Sep 30 03:46:11 PDT 2022


Hi,

Answer in English although I understand French (after all an english
speaking list here)

You can:

Instead of

vsistr = "/vsicurl?pc_url_signing=yes&pc_collection=sentinel-2-l2a&url="
red_href = vsistr + planetary_computer.sign(item).assets["B04"].href
cogtif = gdal.Open( red_href )

use

red_href = f"/vsicurl/{planetary_computer.sign(item).assets["B04"].href
}&pc_url_signing=yes&pc_collection=sentinel-2-l2a"
cogtif = gdal.Open( red_href )

Regards

Thomas Gratier

Le mer. 28 sept. 2022 à 10:12, Loïc Lozac'h <loic.lozach at inrae.fr> a écrit :

> Bonjour,
>
> Est-il possible d'utiliser la signature de la librairie python
> Planetary_Computer pour lire des COG depuis le catalogue STAC Microsoft ?
>
> J'ai essayé plusieurs méthode en utilisant /vsicurl/ mais les extended
> filenames associé à la signature ne sont pas reconnu.
>
> Est-il possible de lire ces données à la manière de RasterIO ?
>
> J'utilise gdal version 3.5.2
>
> code python en erreur :
> vsistr = "/vsicurl?pc_url_signing=yes&pc_collection=sentinel-2-l2a&url="
> red_href = vsistr + planetary_computer.sign(item).assets["B04"].href
> cogtif = gdal.Open( red_href )
>
> response :
>
> Warning 6: Unsupported option: se
> Warning 6: Unsupported option: sp
> Warning 6: Unsupported option: sv
> Warning 6: Unsupported option: sr
> Warning 6: Unsupported option: skoid
> Warning 6: Unsupported option: sktid
> Warning 6: Unsupported option: skt
> Warning 6: Unsupported option: ske
> Warning 6: Unsupported option: sks
> Warning 6: Unsupported option: skv
> Warning 6: Unsupported option: sig
> ERROR 11: HTTP response code: 403
>
> code python ok :
> with fiona.open(shp, "r") as shapefile:
> shapes = [feature["geometry"] for feature in shapefile]
> with rasterio.open(planetary_computer.sign(item).assets["B04"].href ) as
> ds:
> out_image, out_transform = rasterio.mask.mask(ds, shapes, crop=True)
> out_meta = ds.meta
> out_meta.update({"driver": "GTiff",
> "height": out_image.shape[1],
> "width": out_image.shape[2],
> "transform": out_transform})
> with rasterio.open(out, "w", **out_meta) as dest:
> dest.write(out_image)
>
> Merci pour vos réponses
>
> Bien cordialement,
>
> Loïc
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220930/0db86dce/attachment.htm>


More information about the gdal-dev mailing list