pydem: KeyError upon Instantiating an instance of the DEMProcessor class --Projection
I am running PyDEM (0.2.0) on Python (2.7.14) and trying to follow the instructions on the readme.md file. Below I have listed the commands I used, the output, and the input elevation file. I am getting the KeyError with the third command. It looks like it has something to do with the projection files. Has anyone else had this issue and if so, how did you solve it. I tried to search this error with Google but did not find anything useful.
Here are the commands I typed in the Python Console:
from pydem.dem_processing import DEMProcessor
boy = 'elevationUTM.tif'
dem_proc = DEMProcessor(boy)
Then I receive the messages including the key error at the end:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python27\lib\site-packages\pydem\dem_processing.py", line 565, in __init__
elev, = elev_file.raster_layers
File "C:\Python27\lib\site-packages\traits\has_traits.py", line 895, in decorator
self.__dict__[ name ] = result = function( self )
File "C:\Python27\lib\site-packages\pydem\reader\gdal_reader.py", line 195, in _get_raster_layers
for raster_band in raster_bands]
File "C:\Python27\lib\site-packages\pydem\reader\gdal_reader.py", line 143, in _raster_layer_from_raster_band
layer.grid_coordinates = self.grid_coordinates
File "C:\Python27\lib\site-packages\traits\has_traits.py", line 895, in decorator
self.__dict__[ name ] = result = function( self )
File "C:\Python27\lib\site-packages\pydem\reader\gdal_reader.py", line 130, in _get_grid_coordinates
wkt = d_wkt_to_name[wkt_]
KeyError: 'PROJCS["WGS_1984_UTM_Zone_16N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32616"]]'
Here is the input elevation model I used (this file was created with ArcGISPro using the project raster command and the projection was WGS_1984_UTM_Zone_16N):
elevationUTM.tif.zip
I have tried the solution recommended by mpu-creare but this did not work. Here is the link for that GitHub Issue. https://github.com/creare-com/pydem/issues/1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (9 by maintainers)
Hurray, progress!
It looks like it’s failing when trying to import
gdal
, so you’regdal
installation is likely broken. It can be a bear getting that to work on windows, sometimes.Have a look at the Install.md for some hints.
Recently I’ve been having better luck with the
conda-forge
anaconda channel… something like:… if you’re using conda.
But I can’t help much beyond this on a gdal installation.
On you’re second question, feel free to put out another issue and I’ll mark it as a feature request. No idea when someone will be able to get to it. I’m not that familiar with that part of the pydem, but epsg:4269 might actually work – you could give it a try once you get the gdal matters sorted out.
You are correct about TauDEM – in fact that’s one of the motivations for PyDEM.
So yes, PyDEM uses
geopy
to calculate the distances between grid cells, code for that is here: https://github.com/creare-com/pydem/blob/master/pydem/utils.py#L145