[gdal-dev] Reprojecting image with lat/lon bands - best practice?

Conrad Bielski conrad_bielski at yahoo.com
Wed Oct 23 02:59:27 PDT 2024


 Hi,
so I've tried everything that was suggested and I'm not sure why I'm constantly getting this error when I try to run the gdalwarp command: 
ERROR 1: Unable to compute a GEOLOC_ARRAY based transformation between pixel/line and georeferenced coordinates for b1.vrt.
For clarity, this is the full command that I'm using:gdalwarp Oa01_radiance.nc b1.tif -to X_DATASET=lon.tif -to X_BAND=1 -to Y_DATASET=lat.tif -to Y_BAND=1 -to PIXEL_OFFSET=0 -to PIXEL_STEP=1 -to LINE_OFFSET=0 -to LINE_STEP=1 -to SRS=EPSG:4326  -overwrite
ERROR 1: The transformation is already "north up" or a transformation between pixel/line and georeferenced coordinates cannot be computed for Oa01_radiance.nc. There is no affine transformation and no GCPs. Specify transformation option SRC_METHOD=NO_GEOTRANSFORM to bypass this check.

Of course if I add the 'NO_GEOTRANSFORM' the wanted geo information is lost and the output is not correct.

The image sizes are the same so I'm wondering what's missing.
I have found the list of options here: gdal_alg.h: GDAL Algorithms C API — GDAL documentation 


| 
| 
|  | 
gdal_alg.h: GDAL Algorithms C API — GDAL documentation


 |

 |

 |

which is quite nice but many have version requirements. At the moment, I'm using GDAL 3.4.3, released 2022/04/22 and wondering whether I need to update in order for this to work?
Or am I just missing something? Ideas?
Thanks for your help,Conrad



    On Saturday, October 19, 2024 at 04:44:19 AM GMT+1, Even Rouault <even.rouault at spatialys.com> wrote:  
 
  

 
 Le 18/10/2024 à 23:32, Michael Sumner a écrit :
  
 

I didn't know you could do that with -to!! That's awesome 
 
🤟
 
Hum, sorry for giving a wrong track, it seems the newly LLM module implemented in my brain has hallucinated... 
 
 
So you have rather to create a geoloc.vrt file with
 
gdal_translate input.tif geoloc.vrt -b 2 -b 1
 
 
and then;
 
gdal_translate input.tif imagery.vrt -b 3
 
 gdalwarp imagery.vrt imagery_warped.tif -geoloc -to GEOLOC_ARRAY=geoloc.vrt -a_srs EPSG:4326  -overwrite
 
 
 
  On Sat, 19 Oct 2024, 05:01 Even Rouault via gdal-dev, <gdal-dev at lists.osgeo.org> wrote:
  
  
Conrad,
 
Try something like:
 
gdal_translate input.tif imagery.vrt -b 3
 
 
gdalwarp imagery.vrt imagery_warped.tif -geoloc -to X_DATASET=input.tif -to X_BAND=2 -to Y_DATASET=input.tif -to Y_BAND=1 -to PIXEL_OFFSET=0 -to PIXEL_STEP=1 -to LINE_OFFSET=0 -to LINE_STEP=1 -to SRS=EPSG:4326 -a_srs EPSG:4326  -overwrite
 
 
Obviously I have most certainly got something wrong in the above, but hopefully with a tiny tweaking that should put you on the right track.
 
 
Reference: https://gdal.org/en/latest/development/rfc/rfc4_geolocate.html
 
 
Even
 
 Le 18/10/2024 à 12:37, Javier Jimenez Shaw via gdal-dev a écrit :
  
  Is it an actual grid? in the meaning of having constant step size in X and Y. In that case the geolocation is just the corner and the x and y sizes. You can convert to a georeference raster, and warp it.
  If it is not the case, you have something more like a 2D pointcloud, or a bunch of poins in a strange vector format.
   
  On Fri, 18 Oct 2024 at 12:20, Conrad Bielski via gdal-dev <gdal-dev at lists.osgeo.org> wrote:
  
   Hello GDAL-experts, 
  normally when I use GDAL for reprojecting imagery, the projection information that I use is the source spatial reference (SRS) associated with the imagery. However, now I have imagery which is lat/lon geographic and I have two separate bands which also carry the pixel geographic information. So the following raster inputs all the same size: 1. Band 1 = latitude 2. Band 2 = longitude 3. Band 3 = imagery 
  The question I have is how best to integrate this information into a reprojection workflow? 
  I presume that gdalwarp is the best option here, but how can I take advantage of the individual pixel location information (rather than just the extents for example)? I know that I can mosaic into an existing file that I have already created in the target projection. Is this the best way to apply gdalwarp in this context? 
  I'm just wondering what is the best way to integrate the lat/lon pixel information into my warping using gdalwarp. 
  Thanks in advance for your help, Conrad
    _______________________________________________
 gdal-dev mailing list
 gdal-dev at lists.osgeo.org
 https://lists.osgeo.org/mailman/listinfo/gdal-dev
 
  
  _______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
 
 -- 
http://www.spatialys.com
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.  _______________________________________________
 gdal-dev mailing list
 gdal-dev at lists.osgeo.org
 https://lists.osgeo.org/mailman/listinfo/gdal-dev
 
  
 -- 
http://www.spatialys.com
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241023/9132adfa/attachment.htm>


More information about the gdal-dev mailing list