python (scipy) TypeError

Peter Pearson pkpearson at nowhere.invalid
Mon Oct 3 12:38:18 EDT 2016


On Mon, 3 Oct 2016 09:14:23 -0700 (PDT), chrischris201444 at gmail.com wrote:
[snip]
>
> i try to follow some tutorial but i have that error :
>
> Traceback (most recent call last):
>   File "C:\Python27\test\test\earth.py", line 42, in <module>
>     slope_array = np.ones_like(data_array) * nodataval
> TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
>
>
> first i define that lines of code :
>
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
>
> and the line with error :
>
> slope_array = np.ones_like(data_array) * nodataval
>
> how can i fix this error ?i change type field ?
>
> on the four prints:
>
> print(resolution)
> print(nodataval)
> print(type(data_array))
> print(data_array.shape)
>
> i take that exports :
>
> {'east-west': 0.0002777777777777778, 'north-south': 0.0002777777777777778}
> None
><type 'numpy.ndarray'>
> (3601, 3601)

The TypeError error message is telling you that in the line

     slope_array = np.ones_like(data_array) * nodataval

you're attempting to multiply something of type "int" by something 
of type "NoneType".  And look, when you printed nodataval, you got "None".

So, the real question is why getNoDataValue is returning None.  To
answer that question, I would have to know something about the osgeo
package and your input file dem.tif, but unfortunately I don't.

-- 
To email me, substitute nowhere->runbox, invalid->com.



More information about the Python-list mailing list