johntruckenbrodt / spatialist

A Python module for spatial data handling
MIT License
30 stars 9 forks source link

GDAL warp error in stack when using same CRS and SRS #11

Closed system123 closed 5 years ago

system123 commented 5 years ago

I am trying to stack a collection of processed geotiffs together. The Geotiffs are processed using pyroSAR and the CRS is set to EPSG:4326. However, when stacking these images together I run into the following GDAL warp error in the stacking function.

Traceback (most recent call last):
  File "utils/process_s1.py", line 154, in <module>
    make_stack(args.outdir, roi, mosaic="daily")
  File "utils/process_s1.py", line 110, in make_stack
    shapefile=roi, sortfun=seconds, separate=True, overwrite=False)
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/raster.py", line 1268, in stack
    multicore(gdalwarp, cores=cores, multiargs={'src': srcfiles, 'dst': dstfiles}, options=options_warp)
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/ancillary.py", line 357, in multicore
    raise (item.re_raise())
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/ancillary.py", line 396, in re_raise
    reraise(self.ee, None, self.tb)
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/ancillary.py", line 393, in reraise
    raise tp.with_traceback(tb)
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/ancillary.py", line 335, in wrapper
    return function(**kwargs)
  File "/home/lloyd/anaconda3/envs/gdal/lib/python3.7/site-packages/spatialist/auxil.py", line 133, in gdalwarp
    raise RuntimeError('{}:\n  src: {}\n  dst: {}\n  options: {}'.format(str(e), src, dst, options))
RuntimeError: Cannot find coordinate operations from `EPSG:4326' to `EPSG:4326':
  src: /vsimem/S1A__IW___A_20190821T231125_VV_tnr_bnr_Orb_Cal_TC.vrt
  dst: /processed/stack/S1A__IW___A_20190821T231125_VV_tnr_bnr_Orb_Cal_TC.tif
  options: {'options': ['-q', '-co', 'COMPRESS=DEFLATE', '-co', 'PREDICTOR=2', '-of', 'GTiff', '-te', '-79.0411376953125', '25.7998911820883343', '-76.8878173828125', '27.029770731463536', '-tr', '10', '10', '-r', 'bilinear', '-srcnodata', '0', '-dstnodata', '0', '-multi', '-ovr', 'AUTO'], 'format': 'GTiff', 'outputBounds': (-79.0411376953125, 25.799891182088334, -76.8878173828125, 27.029770731463536), 'multithread': True, 'dstNodata': 0, 'xRes': 10, 'yRes': 10, 'resampleAlg': 'bilinear', 'srcNodata': 0}
(called function 'gdalwarp' with args {'src': '/vsimem/S1A__IW___A_20190821T231125_VV_tnr_bnr_Orb_Cal_TC.vrt', 'dst': '/processed/stack/S1A__IW___A_20190821T231125_VV_tnr_bnr_Orb_Cal_TC.tif', 'options': {'options': ['-q', '-co', 'COMPRESS=DEFLATE', '-co', 'PREDICTOR=2'], 'format': 'GTiff', 'outputBounds': (-79.0411376953125, 25.799891182088334, -76.8878173828125, 27.029770731463536), 'multithread': True, 'dstNodata': 0, 'xRes': 10, 'yRes': 10, 'resampleAlg': 'bilinear', 'srcNodata': 0}})
felixcremer commented 5 years ago

I am not sure, whether this is linked to your actual problem, but you are giving the target resolutions in meters and you should give it in degree. To get the actual resolution of your preprocessed files, you can use the following code:

    ras = Raster(srcfiles[1])
    targetres= [r for r in ras.res]
system123 commented 5 years ago

Ah right, that seems to have fixed it.

Thanks

On Mon, 16 Sep 2019, 23:08 Felix Cremer, notifications@github.com wrote:

I am not sure, whether this is linked to your actual problem, but you are giving the target resolutions in meters and you should give it in degree. To get the actual resolution of your preprocessed files, you can use the following code:

ras = Raster(srcfiles[1])
targetres= [r for r in ras.res]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johntruckenbrodt/spatialist/issues/11?email_source=notifications&email_token=AAAWK5NELCVQMSNIV57PLW3QJ7YULA5CNFSM4IXGJLP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62QZOQ#issuecomment-531958970, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAWK5PXRE5PL7J4UHOYVU3QJ7YULANCNFSM4IXGJLPQ .