<div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>Answer in English although I understand French (after all an english speaking list here)</div><div><br></div><div>You can:</div><div><br></div><div>Instead of</div><div><br></div><div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">vsistr</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"/vsicurl?pc_url_signing=yes&pc_collection=sentinel-2-l2a&url="</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(156,220,254)">vsistr</span><span style="color:rgb(212,212,212)"> + </span><span style="color:rgb(78,201,176)">planetary_computer</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">sign</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(156,220,254)">item</span><span style="color:rgb(212,212,212)">).assets[</span><span style="color:rgb(206,145,120)">"B04"</span><span style="color:rgb(212,212,212)">].href </span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">cogtif</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(78,201,176)">gdal</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">Open</span><span style="color:rgb(212,212,212)">( </span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"> )</span></div></div></div><div><br></div><div>use<br></div></div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(212,212,212)">    <span style="color:rgb(212,212,212)"></span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"></span></span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">f"/vsicurl/{<span style="color:rgb(212,212,212)"></span><span style="color:rgb(78,201,176)">planetary_computer</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">sign</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(156,220,254)">item</span><span style="color:rgb(212,212,212)">).assets[</span><span style="color:rgb(206,145,120)">"B04"</span><span style="color:rgb(212,212,212)">].href</span>}&pc_url_signing=yes&pc_collection=sentinel-2-l2a"</span><span style="color:rgb(212,212,212)"></span><span style="color:rgb(212,212,212)"></span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">cogtif</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(78,201,176)">gdal</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">Open</span><span style="color:rgb(212,212,212)">( </span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"> )</span></div></div></div></div><div><br></div><div>Regards</div><div><br></div><div>Thomas Gratier<br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 28 sept. 2022 à 10:12, Loïc Lozac'h <<a href="mailto:loic.lozach@inrae.fr">loic.lozach@inrae.fr</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div>
    <p>Bonjour,</p>
    <p>Est-il possible d'utiliser la signature de la librairie python
      Planetary_Computer pour lire des COG depuis le catalogue STAC
      Microsoft ?</p>
    <p>J'ai essayé plusieurs méthode en utilisant /vsicurl/ mais les
      extended filenames associé à la signature ne sont pas reconnu.</p>
    <p>Est-il possible de lire ces données à la manière de RasterIO ?</p>
    <p>J'utilise gdal version 3.5.2</p>
    <p>code python en erreur :</p>
    <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">vsistr</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"/vsicurl?pc_url_signing=yes&pc_collection=sentinel-2-l2a&url="</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(156,220,254)">vsistr</span><span style="color:rgb(212,212,212)"> + </span><span style="color:rgb(78,201,176)">planetary_computer</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">sign</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(156,220,254)">item</span><span style="color:rgb(212,212,212)">).assets[</span><span style="color:rgb(206,145,120)">"B04"</span><span style="color:rgb(212,212,212)">].href </span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(156,220,254)">cogtif</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(78,201,176)">gdal</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">Open</span><span style="color:rgb(212,212,212)">( </span><span style="color:rgb(156,220,254)">red_href</span><span style="color:rgb(212,212,212)"> )</span></div></div>
    <p>response :<br>
    </p>
    <pre>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
</pre>
    <p>code python ok :</p>
    <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(212,212,212)">    </span>
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">with</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(78,201,176)">fiona</span><span style="color:rgb(212,212,212)">.open(</span><span style="color:rgb(156,220,254)">shp</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(206,145,120)">"r"</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(197,134,192)">as</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">shapefile</span><span style="color:rgb(212,212,212)">:</span></div><div><span style="color:rgb(212,212,212)">       </span><span style="color:rgb(156,220,254)">shapes</span><span style="color:rgb(212,212,212)"> = [</span><span style="color:rgb(156,220,254)">feature</span><span style="color:rgb(212,212,212)">[</span><span style="color:rgb(206,145,120)">"geometry"</span><span style="color:rgb(212,212,212)">] </span><span style="color:rgb(197,134,192)">for</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">feature</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">in</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">shapefile</span><span style="color:rgb(212,212,212)">]</span></div><div><span style="color:rgb(212,212,212)">
</span></div></div><span style="color:rgb(212,212,212)"></span></div><div><span style="color:rgb(212,212,212)">       </span><span style="color:rgb(197,134,192)">with</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(78,201,176)">rasterio</span><span style="color:rgb(212,212,212)">.open(</span><span style="color:rgb(78,201,176)">planetary_computer</span><span style="color:rgb(212,212,212)">.</span><span style="color:rgb(220,220,170)">sign</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(156,220,254)">item</span><span style="color:rgb(212,212,212)">).assets[</span><span style="color:rgb(206,145,120)">"B04"</span><span style="color:rgb(212,212,212)">].href ) </span><span style="color:rgb(197,134,192)">as</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">ds</span><span style="color:rgb(212,212,212)">:</span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(156,220,254)">out_image</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">out_transform</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(78,201,176)">rasterio</span><span style="color:rgb(212,212,212)">.mask.mask(</span><span style="color:rgb(156,220,254)">ds</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">shapes</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">crop</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(86,156,214)">True</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(156,220,254)">out_meta</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(156,220,254)">ds</span><span style="color:rgb(212,212,212)">.meta</span></div><div><span style="color:rgb(212,212,212)">            </span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(156,220,254)">out_meta</span><span style="color:rgb(212,212,212)">.update({</span><span style="color:rgb(206,145,120)">"driver"</span><span style="color:rgb(212,212,212)">: </span><span style="color:rgb(206,145,120)">"GTiff"</span><span style="color:rgb(212,212,212)">,</span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(206,145,120)">"height"</span><span style="color:rgb(212,212,212)">: </span><span style="color:rgb(156,220,254)">out_image</span><span style="color:rgb(212,212,212)">.shape[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">],</span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(206,145,120)">"width"</span><span style="color:rgb(212,212,212)">: </span><span style="color:rgb(156,220,254)">out_image</span><span style="color:rgb(212,212,212)">.shape[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(212,212,212)">],</span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(206,145,120)">"transform"</span><span style="color:rgb(212,212,212)">: </span><span style="color:rgb(156,220,254)">out_transform</span><span style="color:rgb(212,212,212)">})                                           </span></div>
<div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">with</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(78,201,176)">rasterio</span><span style="color:rgb(212,212,212)">.open(</span><span style="color:rgb(156,220,254)">out</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(206,145,120)">"w"</span><span style="color:rgb(212,212,212)">, **</span><span style="color:rgb(156,220,254)">out_meta</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(197,134,192)">as</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">dest</span><span style="color:rgb(212,212,212)">:</span></div><div><span style="color:rgb(212,212,212)">        </span><span style="color:rgb(156,220,254)">dest</span><span style="color:rgb(212,212,212)">.write(</span><span style="color:rgb(156,220,254)">out_image</span><span style="color:rgb(212,212,212)">)</span></div></div>
    <p>Merci pour vos réponses</p>
    <p>Bien cordialement,</p>
    <p>Loïc<br>
    </p>
  </div>

_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div></div>