<div dir="auto">This may be a helpful resource: <a href="https://github.com/rasterio/affine">https://github.com/rasterio/affine</a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 17, 2022, 9:08 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    <p><br>
    </p>
    <div>Le 17/11/2022 à 16:01, Brendan
      Heberlein a écrit :<br>
    </div>
    <blockquote type="cite">
      
      
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        Thank you, Mike & Even.</div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        <br>
      </div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        Supposing I wanted to have the output grid origin &
        dimensions computed automatically, but with a specified rotation
        angle, is that possible?</div>
    </blockquote>
    <p>There's no API in GDAL for it. You indeed have to set something
      like the following<br>
    </p>
    <p><br>
    </p>
    <p>gt[1] = cos(angle) * pixel_x_size</p>
    <p>gt[2] = -sin(angle) * pixel_x_size</p>
    <p>gt[4] = sin(angle) * pixel_y_size</p>
    <p>gt[5] = cos(angle) * pixel_y_size</p>
    <p><br>
    </p>
    <p>I assume the above only works if the origin (gt[0], gt[3]) is the
      lower-left corner coordinate, not the upper-one. And I might
      certainly have got some signs wrong :-)</p>
    <p><br>
    </p>
    <p>Slightly related code in the ENVI driver to transform the
      rotation angle from its header file to a geotransform matrix (but
      conventions might be slightly different):</p>
    <p><a href="https://github.com/OSGeo/gdal/blob/66d9fe0b1a34a8992c804c2444f7f23c2436b937/frmts/raw/envidataset.cpp#L1536" target="_blank" rel="noreferrer">https://github.com/OSGeo/gdal/blob/66d9fe0b1a34a8992c804c2444f7f23c2436b937/frmts/raw/envidataset.cpp#L1536</a><br>
    </p>
    <blockquote type="cite">
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        <br>
      </div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        Anyway I can calculate these parameters myself, so it is not a
        big issue. Your suggestion worked for me.</div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        <br>
      </div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        Cheers!</div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        Brendan</div>
      <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
        <br>
      </div>
      <hr style="display:inline-block;width:98%">
      <div id="m_-3692796033474229474divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Even
          Rouault <a href="mailto:even.rouault@spatialys.com" target="_blank" rel="noreferrer"><even.rouault@spatialys.com></a><br>
          <b>Sent:</b> Saturday, November 5, 2022 4:36 AM<br>
          <b>To:</b> Michael Sumner <a href="mailto:mdsumner@gmail.com" target="_blank" rel="noreferrer"><mdsumner@gmail.com></a>; Brendan
          Heberlein <a href="mailto:bheberlein@wisc.edu" target="_blank" rel="noreferrer"><bheberlein@wisc.edu></a><br>
          <b>Cc:</b> gdal-dev <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer"><gdal-dev@lists.osgeo.org></a><br>
          <b>Subject:</b> Re: [gdal-dev] Specify Grid Rotation for
          gdal.Warp() with Geolocation Arrays</font>
        <div> </div>
      </div>
      <div>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          <br>
        </p>
        <div>Le 05/11/2022 à 04:33, Michael
          Sumner a écrit :<br>
        </div>
        <blockquote type="cite">
          <div dir="ltr">yes I see, well you can probably set a target
            GeoTIFF with the geotransform that you want - and gdalwarp
            to that as the target.
            <br>
          </div>
        </blockquote>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          something like</p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          out_ds = gdal.GetDriverByName("GTiff").Create("output.tif",
          width, height, number_of_bands, data_type, options =
          ["TILED=YES"])</p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          out_ds.SetGeoTransform([ some geotransform with rotational
          terms ])</p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          srs = osr.SpatialReference()</p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          srs.ImportFromEPSG( xxx ) / srs.ImportFromWkt( xxx )<br>
        </p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          out_ds.SetSpatialRef( srs )</p>
        gdal.Warp(out_ds, src_ds, .... )<br>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          <br>
        </p>
        <p style="margin-top:0px;margin-bottom:0px;margin-top:0px;margin-bottom:0px">
          <br>
        </p>
        <blockquote type="cite">
          <div dir="ltr">I don't believe you can do that with gdalwarp
            directly, and I have no idea with python - and finally I'm
            sorry to add irrelevant discussion - but this is interesting
            and I'm going to try it out in R and C++ and would love to
            see a python example too. 
            <div><br>
            </div>
            <div>Cheers, Mike</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
              <div><br>
              </div>
            </div>
          </div>
          <br>
          <div>
            <div dir="ltr">On Sat, Nov 5, 2022 at
              2:21 PM Brendan Heberlein <<a href="mailto:bheberlein@wisc.edu" target="_blank" rel="noreferrer">bheberlein@wisc.edu</a>>
              wrote:<br>
            </div>
            <blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div>
                <div dir="ltr">
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    Hi Mike,</div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    <br>
                  </div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    regardless of the map projection, it may be
                    desirable to have the grid oriented in one direction
                    or another, e.g. due to the spatial distribution of
                    data points. Although the CRS/SRS designates the
                    coordinate axes, these are not always aligned with
                    the desired grid orientation.</div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    <br>
                  </div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    So, basically I want to be able to specify an
                    arbitrary geotransform array for the output grid.
                    This would allow the grid to be assigned an
                    arbitrary orientation within the CRS frame.</div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    <br>
                  </div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    Thanks,</div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                    Brendan</div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                  </div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                  </div>
                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                  </div>
                  <hr style="display:inline-block;width:98%">
                  <div id="m_-3692796033474229474x_m_-4105275956097184085divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b>
                      Michael Sumner <<a href="mailto:mdsumner@gmail.com" target="_blank" rel="noreferrer">mdsumner@gmail.com</a>><br>
                      <b>Sent:</b> Friday, November 4, 2022 6:57 PM<br>
                      <b>To:</b> Brendan Heberlein <<a href="mailto:bheberlein@wisc.edu" target="_blank" rel="noreferrer">bheberlein@wisc.edu</a>><br>
                      <b>Cc:</b> gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a>><br>
                      <b>Subject:</b> Re: [gdal-dev] Specify Grid
                      Rotation for gdal.Warp() with Geolocation Arrays</font>
                    <div> </div>
                  </div>
                  <div>
                    <div dir="auto">well, the map projection does this -
                      there are many possibilities. Or, do you have
                      another geolocation array you want as the target? 
                      <div dir="auto"><br>
                      </div>
                      <div dir="auto">If you have an example I'm happy
                        to try a few things, but I'd assumed you had a
                        target map projection in mind. What kind of crs
                        to choose depends on your goal, or is purely to
                        not have north up? </div>
                      <div dir="auto"><br>
                      </div>
                      <div dir="auto">Perhaps there's something
                        terminology wise I'm missing ...</div>
                      <div dir="auto"><br>
                      </div>
                      <div dir="auto">Mike</div>
                    </div>
                    <br>
                    <div>
                      <div dir="ltr">On Sat, 5 Nov 2022, 10:50 Brendan
                        Heberlein, <<a href="mailto:bheberlein@wisc.edu" target="_blank" rel="noreferrer">bheberlein@wisc.edu</a>>
                        wrote:<br>
                      </div>
                      <blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                        <div dir="ltr">
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            Hi Mike,</div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            <br>
                          </div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            thanks for the response.</div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            <br>
                          </div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            Can you clarify how I would go about
                            specifying the grid orientation for the
                            output raster? None of -te, -ts or -t_srs
                            address this.</div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                          </div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            <br>
                          </div>
                          <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                            <br>
                          </div>
                          <hr style="display:inline-block;width:98%">
                          <div id="m_-3692796033474229474x_m_-4105275956097184085x_m_219862940684509146divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b>
                              Michael Sumner <<a href="mailto:mdsumner@gmail.com" target="_blank" rel="noreferrer">mdsumner@gmail.com</a>><br>
                              <b>Sent:</b> Friday, November 4, 2022 6:41
                              PM<br>
                              <b>To:</b> Brendan Heberlein <<a href="mailto:bheberlein@wisc.edu" target="_blank" rel="noreferrer">bheberlein@wisc.edu</a>><br>
                              <b>Cc:</b> gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a>><br>
                              <b>Subject:</b> Re: [gdal-dev] Specify
                              Grid Rotation for gdal.Warp() with
                              Geolocation Arrays</font>
                            <div> </div>
                          </div>
                          <div>
                            <div dir="auto">that's exactly what the
                              warper does with geolocation arrays, set
                              the target extent, dimension, and crs with
                              -te, -ts, -t_srs with gdalwarp.
                              <div dir="auto"><br>
                              </div>
                              <div dir="auto">python will have those
                                analogous controls for the warper.</div>
                              <div dir="auto"><br>
                              </div>
                              <div dir="auto">Cheers, Mike</div>
                              <div dir="auto"><br>
                              </div>
                              <div dir="auto"><br>
                              </div>
                            </div>
                            <br>
                            <div>
                              <div dir="ltr">On Sat, 5 Nov 2022, 01:23
                                Brendan Heberlein via gdal-dev, <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a>>
                                wrote:<br>
                              </div>
                              <blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                <div dir="ltr">
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    Hello,</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    I would like to be able to warp an
                                    image dataset using a geolocation
                                    array, while specifying the grid to
                                    which the output dataset is sampled.
                                    Specifically, I want to be able to
                                    warp the dataset to a grid which is
                                    not oriented North-up.</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    Can GDAL support this currently? Or,
                                    what is the likelihood this could be
                                    supported in the future?</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    I primarily rely on the Python
                                    bindings, so a solution within that
                                    framework would be ideal for me.</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    Thanks!</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                         — Brendan</div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                  <div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
                                    <br>
                                  </div>
                                </div>
_______________________________________________<br>
                                gdal-dev mailing list<br>
                                <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a><br>
                                <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank" rel="noreferrer">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
                              </blockquote>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div dir="ltr">Michael Sumner<br>
            Software and Database Engineer<br>
            Australian Antarctic Division<br>
            Hobart, Australia<br>
            e-mail: <a href="mailto:mdsumner@gmail.com" target="_blank" rel="noreferrer">
              mdsumner@gmail.com</a></div>
          <br>
          <fieldset></fieldset>
          <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank" rel="noreferrer">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
        </blockquote>
        <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank" rel="noreferrer">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
      </div>
    </blockquote>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank" rel="noreferrer">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

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