2

I'm trying to read ROIs from Landsat-8 overview using GDAL /vsicurl/ , but the image is ungeoreferenced. I have geotransform from full size image, which I can copy. Is there a way to pass geotransform to gdalwarp to handle ungeoreferenced image as georeferenced?

Here is the command I want to execute from Python:

ds_source = 'http://landsat-pds.s3.amazonaws.com/L8/044/034/LC80440342015224LGN00/LC80440342015224LGN00_B3.TIF.ovr'
# here I use -te_srs,-te to crop ROI; data should be taken from 2nd OVR level
warp_options = ' -of MEM -r cubic -te_srs "+proj=longlat +datum=WGS84 +no_defs " -te -123.75 31.952162238 -112.5 40.9798980696 -dstalpha -ovr 2'
output_dataset = gdal.Warp('', '/vsicurl/%s' % ds_source, options=warp_options)

Lines above produce error:

ERROR 1: -te_srs ignored since none of -t_srs, -s_srs is specified or the input dataset has no projection.
0

gdalwarp converts from one coordinate system to another coordinate system. In your case, the overview does not have a coordiante system, so gdalwarp is not usefull. if you know the coordinate system and the geotransform, you should instead use gdal_edit :

The [gdal_edit.py][1] script can be used to edit in place various information of an existing GDAL dataset (projection, geotransform, nodata, metadata).

It works only with raster formats that support update access to existing datasets.

you can use gdal_edit.py -a_srs EPSG:4326 -a_ullr ulx uly lrx lry

  • Thank you, but the problem is I don't have update access to existing datasets. – dr_times Jan 31 '17 at 15:20
  • what I want to do is to treat an OVR image as if it was georeferenced without changing it – dr_times Jan 31 '17 at 15:23
  • maybe I could build VRT from /vsicurl/ image and set SRS and geotransform for it? – dr_times Jan 31 '17 at 15:25
  • try -s_srs option to define the source coordinate system for gdalwarp or gdal_translate – radouxju Jan 31 '17 at 19:42
0

Came up with the following solution for my task: I open an original georeferenced scene with gdal.OpenEx() and set an overview file as a sibling file. Another problem was that in GDAL 2.1.0 gdal.Warp() doesn't seem to handle overview levels > 0 when dealing with external ovr files and passing "-ovr" option, so I had to calculate required overview level in advance and pass it into open_options. Following Python code snippet opens a georeferenced overview stored in external file via "/vsicurl/":

    from osgeo import gdal

    url = "http://landsat-pds.s3.amazonaws.com/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B5.TIF"
    ds = gdal.OpenEx('/vsicurl/' + url, allowed_drivers=['GTiff'], sibling_files=[url.split('/')[-1] + '.ovr'], open_options=['OVERVIEW_LEVEL=0']))
    # make sure the dataset is georeferenced
    gt = ds.GetGeoTransform()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.