Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warping multiple datasets to common grid error #7

Open
hashirilyas opened this issue Jan 23, 2020 · 5 comments
Open

Warping multiple datasets to common grid error #7

hashirilyas opened this issue Jan 23, 2020 · 5 comments

Comments

@hashirilyas
Copy link

I have tried to execute this method
`#Input DEM filenames
dem_1970_fn = '../data/rainier/19700901_ned1_2003_adj_warp.tif'
dem_2008_fn = '../data/rainier/20080901_rainierlidar_10m-adj.tif'
dem_2015_fn = '../data/rainier/20150818_rainier_summer-tile-0.tif'
dem_fn_list = [dem_1970_fn, dem_2008_fn, dem_2015_fn]

ds_list = warplib.memwarp_multi_fn(dem_fn_list, res='min', extent='intersection', t_srs=dem_2008_fn)
`

It gives me this error
Warping all inputs to the following:
Resolution: 8.598818836623543
Extent: [125349.01533479267, 5188936.160027057, 151869.01533479267, 5213641.54503958]
Projection: '+proj=utm +zone=11 +datum=NAD83 +units=m +no_defs'
Resampling alg: cubic

1 of 3: ../data/rainier/19700901_ned1_2003_adj_warp.tif
nl: 2873 ns: 3084 res: 8.599

RuntimeError Traceback (most recent call last)
in
----> 1 ds_list = warplib.memwarp_multi_fn(dem_fn_list, res='min')

~\Anaconda3\envs\rasterenv\lib\site-packages\pygeotools\lib\warplib.py in memwarp_multi_fn(src_fn_list, res, extent, t_srs, r, verbose, dst_ndv)
527 sys.exit('Missing input file(s)')
528 src_ds_list = [gdal.Open(fn, gdal.GA_ReadOnly) for fn in src_fn_list]
--> 529 return memwarp_multi(src_ds_list, res, extent, t_srs, r, verbose=verbose, dst_ndv=dst_ndv)
530
531 def diskwarp_multi(src_ds_list, res='first', extent='intersection', t_srs='first', r='cubic', verbose=True, outdir=None, dst_ndv=None):

~\Anaconda3\envs\rasterenv\lib\site-packages\pygeotools\lib\warplib.py in memwarp_multi(src_ds_list, res, extent, t_srs, r, verbose, dst_ndv)
518 """Helper function for memwarp of multiple input GDAL Datasets
519 """
--> 520 return warp_multi(src_ds_list, res, extent, t_srs, r, warptype=memwarp, verbose=verbose, dst_ndv=dst_ndv)
521
522 def memwarp_multi_fn(src_fn_list, res='first', extent='intersection', t_srs='first', r='cubic', verbose=True, dst_ndv=0):

~\Anaconda3\envs\rasterenv\lib\site-packages\pygeotools\lib\warplib.py in warp_multi(src_ds_list, res, extent, t_srs, r, warptype, outdir, dst_ndv, verbose, debug)
510 out_ds_list.append(ds)
511 else:
--> 512 dst_ds = warptype(ds, res, extent, t_srs, r, outdir, dst_ndv=dst_ndv, verbose=verbose)
513 out_ds_list.append(dst_ds)
514

~\Anaconda3\envs\rasterenv\lib\site-packages\pygeotools\lib\warplib.py in memwarp(src_ds, res, extent, t_srs, r, oudir, dst_ndv, verbose)
214 """
215 driver = iolib.mem_drv
--> 216 return warp(src_ds, res, extent, t_srs, r, driver=driver, dst_ndv=dst_ndv, verbose=verbose)
217
218 #Use this to warp directly to output file - no need to write to memory then CreateCopy

~\Anaconda3\envs\rasterenv\lib\site-packages\pygeotools\lib\warplib.py in warp(src_ds, res, extent, t_srs, r, driver, dst_fn, dst_ndv, verbose)
190
191 #Note: default maxerror=0.0, second 0.0 argument
--> 192 gdal.ReprojectImage(src_ds, dst_ds, src_srs.ExportToWkt(), t_srs.ExportToWkt(), gra, 0.0, 0.0, prog_func)
193
194 """

~\Anaconda3\envs\rasterenv\lib\site-packages\osgeo\gdal.py in ReprojectImage(*args, **kwargs)
3116 def ReprojectImage(*args, **kwargs):
3117 """ReprojectImage(Dataset src_ds, Dataset dst_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg, double WarpMemoryLimit=0.0, double maxerror=0.0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> CPLErr"""
-> 3118 return _gdal.ReprojectImage(*args, **kwargs)
3119
3120 def ComputeProximity(*args, **kwargs):

RuntimeError: Object given is not a Python function

can any light be shed on this matter

@ShashankBice
Copy link
Contributor

Hi @hashirilyas
Can you confirm the version of GDAL which you are using ? Looks like the problem is in reprojection, likely caused by the PROJ4 update in GDAL 3.x. Switching back to GDAL 2.4x should work.
Migrating to GDAL 3.x is in our TODO list !

@hashirilyas
Copy link
Author

Hi @ShashankBice thanks for the swift response.

I have downgraded to the gdal version 2.4.4 as per your suggestion but the problem still persists.

I am following a tutorial "https://geohackweek.github.io/raster/05-pygeotools_rainier/" and trying to recreate what they have done. The scripts and the relevant data are located on this address "https://github.com/geohackweek/ghw2017"
I am running the notebook given in the raster/notebook/rainer_dem_example

Can you please confirm and diagnose this issue.

Regards

@ShashankBice
Copy link
Contributor

Are you running this on a Windows machine ? I remember now that @jupflug had similar issues last year with the reproject function. This package was developed for/on NIX (Linux or Mac OS) machines. While most of the tools for this package should function on Windows, there are a few GDAL functions where the python binding for Windows and NIX are different, which breaks for example the reproject function here. We should update this in the readme, I must say :) .

@hashirilyas
Copy link
Author

thanks for pointing it out.
Indeed i am using windows but i will switch to Linux to see if it works.

Regards

@wubizhi
Copy link

wubizhi commented Apr 22, 2020

thanks for pointing it out.
Indeed i am using windows but i will switch to Linux to see if it works.

Regards

hi, @hashirilyas i am using windows now and running the code like you,there is the same issue to me.when you switch to Linux,the probelm is soloved or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants