dshean / demcoreg

Utilities for DEM and point cloud co-registration
MIT License
114 stars 45 forks source link

RuntimeError: Object given is not a Python function #53

Closed cc863 closed 1 year ago

cc863 commented 1 year ago

When I run dem_align.py, the following error occurs. Is there anyone who knows how to solve it

Reference: ref_dem.tif Source: src_dem.tif Mode: nuth Output: src_dem_dem_align\src_dem_ref_dem

Warping all inputs to the following: Resolution: 0.0002777777777777829 Extent: [75.89041678772851, 35.88458367232465, 76.36625000000001, 36.28958333333334] Projection: '+proj=longlat +datum=WGS84 +no_defs' Resampling alg: cubic

1 of 2: ref_dem.tif nl: 1458 ns: 1713 res: 0.000 Traceback (most recent call last): File "D:\iceprogram\demcoreg-master\demcoreg-master\d\dem_align.py", line 608, in main() File "D:\iceprogram\demcoreg-master\demcoreg-master\d\dem_align.py", line 271, in main ref_dem_ds, src_dem_ds_align = warplib.memwarp_multi([ref_dem_ds, src_dem_ds_align], File "C:\Anaconda3\lib\site-packages\pygeotools\lib\warplib.py", line 520, in memwarp_multi return warp_multi(src_ds_list, res, extent, t_srs, r, warptype=memwarp, verbose=verbose, dst_ndv=dst_ndv) File "C:\Anaconda3\lib\site-packages\pygeotools\lib\warplib.py", line 512, in warp_multi dst_ds = warptype(ds, res, extent, t_srs, r, outdir, dst_ndv=dst_ndv, verbose=verbose) File "C:\Anaconda3\lib\site-packages\pygeotools\lib\warplib.py", line 216, in memwarp return warp(src_ds, res, extent, t_srs, r, driver=driver, dst_ndv=dst_ndv, verbose=verbose) File "C:\Anaconda3\lib\site-packages\pygeotools\lib\warplib.py", line 192, in warp gdal.ReprojectImage(src_ds, dst_ds, src_srs.ExportToWkt(), t_srs.ExportToWkt(), gra, 0.0, 0.0, prog_func) File "C:\Anaconda3\lib\site-packages\osgeo\gdal.py", line 3915, in ReprojectImage return _gdal.ReprojectImage(*args, **kwargs) RuntimeError: Object given is not a Python function

Process finished with exit code 1

dshean commented 1 year ago

It looks like your reference DEM has geographic coordinates in decimal degrees. It needs to have a projection with units of meters, like UTM. You can do this with gdalwarp or other coordinate transformation software.

I believe there are closed issues and other discussion around this topic.

WeiQi82 commented 1 year ago

When I run dem_msak.py, the following error occurs. Is there anyone who knows how to solve it python dem_mask.py --outdir dataout --writeout --toa --toa_thresh 0.5 --snodas --snodas_thresh 0.2 --modscag --modscag_thresh 60 --bareground --bareground_thresh 80 --glaciers --nlcd --nlcd_filter ice+water --dilate 2 E:\ArcGisPro\ArcGisPro\DEmproject0421\demcoreg\demcoreg\demdate\2020_01_01AW3D_wan_UTM.tif Traceback (most recent call last): File "dem_mask.py", line 777, in main() File "dem_mask.py", line 755, in main newmask = get_mask(dem_ds, mask_list, dem_fn=dem_fn, writeout=args.writeout, outdir=args.outdir, args=args) File "dem_mask.py", line 507, in get_mask nlcd_ds_warp = warplib.memwarp_multi([nlcd_ds, ], res=dem_ds, extent=dem_ds, t_srs=dem_ds, r=rs)[0] File "D:\Python\lib\site-packages\pygeotools\lib\warplib.py", line 520, in memwarp_multi return warp_multi(src_ds_list, res, extent, t_srs, r, warptype=memwarp, verbose=verbose, dst_ndv=dst_ndv) File "D:\Python\lib\site-packages\pygeotools\lib\warplib.py", line 512, in warp_multi dst_ds = warptype(ds, res, extent, t_srs, r, outdir, dst_ndv=dst_ndv, verbose=verbose) File "D:\Python\lib\site-packages\pygeotools\lib\warplib.py", line 216, in memwarp return warp(src_ds, res, extent, t_srs, r, driver=driver, dst_ndv=dst_ndv, verbose=verbose) File "D:\Python\lib\site-packages\pygeotools\lib\warplib.py", line 192, in warp gdal.ReprojectImage(src_ds, dst_ds, src_srs.ExportToWkt(), t_srs.ExportToWkt(), gra, 0.0, 0.0, prog_func) File "D:\Python\lib\site-packages\osgeo\gdal.py", line 3916, in ReprojectImage return _gdal.ReprojectImage(*args, **kwargs) RuntimeError: Object given is not a Python function

dshean commented 1 year ago

@ShashankBice , this sounds like a similar issue to https://github.com/dshean/demcoreg/issues/53

dshean commented 1 year ago

@WeiQi82 you are running with a lot of flags, including the --toa option, which assumes you have prepared a top-of-atmosphere reflectance image with a specific filename structure accompanying the DEM. And all of the others require multiple sidecar datasets (e.g., SNODAS model output, MODSCAG products, bareground datasets, RGI glaciers, NLCD). These are not tested and maintained, some require authentication to retrieve, and if they are not available, then dem_mask.py may not handle in the ways you expect. In short, this tool was developed for specific use case, assuming that a lot of additional files would be available.

I suggest you try running a simple case first to test the tool (e.g., just mask areas over glaciers as defined by RGI polygons), before combining all of these options.

ShashankBice commented 1 year ago

Yes, so 2 things.