<div dir="ltr"><div>Greetings,<br><br></div>I want to shift the UL x, UL y of an image.<br><div><br></div><div>I am trying to find out what the <b>dx_dy + dy_dx</b> is.<br><br></div><div>The code is:<br><pre style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(0,51,179)">import </span>gdal<br><span style="color:rgb(140,140,140);font-style:italic">### open dataset with update permission<br></span>ds = gdal.Open(<span style="color:rgb(6,125,23)">'/data/coastal-2020.tif'</span>, gdal.GA_Update)<br><span style="color:rgb(140,140,140);font-style:italic">### get the geotransform as a tuple of 6<br></span>gt = ds.GetGeoTransform()<br><span style="color:rgb(140,140,140);font-style:italic">### unpack geotransform into variables<br></span>x_tl = (-<span style="color:rgb(23,80,235)">180.0000000</span>)<br>x_res = <span style="color:rgb(23,80,235)">0.000800000000000<br></span><b>dx_dy</b> =<br>y_tl = (<span style="color:rgb(23,80,235)">90.0000000</span>)<br><b>dy_dx</b> =<br>y_res = -<span style="color:rgb(23,80,235)">0.000800000000000<br></span><span style="color:rgb(23,80,235)"><br></span>x_tl, x_res, <b>dx_dy</b>, y_tl, <b>dy_dx</b>, y_res = gt<br><br><span style="color:rgb(140,140,140);font-style:italic"># compute shift of 1 pixel RIGHT in X direction<br></span>shift_x = <span style="color:rgb(23,80,235)">1 </span>* x_res<br><span style="color:rgb(140,140,140);font-style:italic"># compute shift of 2 pixels UP in Y direction<br></span><span style="color:rgb(140,140,140);font-style:italic"># y_res likely negative, because Y decreases with increasing Y index<br></span>shift_y = -<span style="color:rgb(23,80,235)">2 </span>* y_res<br><br><span style="color:rgb(140,140,140);font-style:italic"># make new geotransform<br></span>gt_update = (x_tl + shift_x, x_res, dx_dy, y_tl + shift_y, dy_dx, y_res)</pre><br></div><div>From gdalinfo:<br>Size is 450000, 225000<br>Coordinate System is:<br>GEOGCRS["WGS 84",<br> DATUM["World Geodetic System 1984",<br> ELLIPSOID["WGS 84",6378137,298.257223563,<br> LENGTHUNIT["metre",1]]],<br> PRIMEM["Greenwich",0,<br> ANGLEUNIT["degree",0.0174532925199433]],<br> CS[ellipsoidal,2],<br> AXIS["geodetic latitude (Lat)",north,<br> ORDER[1],<br> ANGLEUNIT["degree",0.0174532925199433]],<br> AXIS["geodetic longitude (Lon)",east,<br> ORDER[2],<br> ANGLEUNIT["degree",0.0174532925199433]],<br> ID["EPSG",4326]]<br>Data axis to CRS axis mapping: 2,1<br>Origin = (-180.000000000000000,90.000000000000000)<br>Pixel Size = (0.000800000000000,-0.000800000000000)<br><br>Image Structure Metadata:<br> COMPRESSION=LZW<br> INTERLEAVE=BAND<br> PREDICTOR=3<br>Corner Coordinates:<br>Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)<br>Lower Left (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)<br>Upper Right ( 180.0000000, 90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)<br>Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)<br>Center ( 0.0000000, 0.0000000) ( 0d 0' 0.01"E, 0d 0' 0.01"N)</div><div><br></div><div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p style="margin:0cm 0cm 0pt"><span style="font-family:Calibri;font-size:8pt"> Regards,</span></p><p style="margin:0cm 0cm 0pt"><span style="font-family:Calibri;font-size:8pt"><br></span></p><p style="margin:0cm 0cm 0pt"><span style="font-family:Calibri;font-size:8pt">Clive Swan</span></p>
<p style="margin:0cm 0cm 0pt"><span><font size="3"><font face="Calibri">--</font></font></span></p></div></div></div></div></div></div></div></div>