# ValueError: zero-size array to reduction operation minimum which has no identity

**URL:** <https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291>\
**Category:** Python\
**Tags:** wradlib\
**Created:** [August 27, 2023, 4:22pm UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291 "2023-08-27T16:22:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pikuljena](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/pikuljena/32/198_2.png) [@pikuljena](https://openradar.discourse.group/u/pikuljena)\
**Post date:** [August 27, 2023, 4:22pm UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291/1 "2023-08-27T16:22:08Z")

</div>

Hy  
i am trying to calculate beam blockage using srtm data . i am getting following error .

code:  
rasterfile = “D:\FINAL YEAR PROJECT\Wradlib\gt30e060n40.dem”  
ds = wrl.io.open\_raster(rasterfile)  
rastervalues, rastercoords, proj = wrl.georef.extract\_raster\_dataset(  
ds, nodata=-32768.0  
)

# Clip the region inside our bounding box

ind = wrl.util.find\_bbox\_indices(rastercoords, rlimits)  
rastercoords = rastercoords[ind[1] : ind[3], ind[0] : ind[2], …]  
rastervalues = rastervalues[ind[1] : ind[3], ind[0] : ind[2]]

# Map rastervalues to polar grid points

polarvalues = wrl.ipol.cart\_to\_irregular\_spline(  
rastercoords, rastervalues, polcoords, order=3, prefilter=False  
)

error:

ValueError Traceback (most recent call last)  
Cell In[8], line 15  
12 rastervalues = rastervalues[ind[1] : ind[3], ind[0] : ind[2]]  
14 # Map rastervalues to polar grid points  
—\> 15 polarvalues = wrl.ipol.cart\_to\_irregular\_spline(  
16 rastercoords, rastervalues, polcoords, order=3, prefilter=False  
17 )

File ~\anaconda3\envs\pyart\_env\lib\site-packages\wradlib\ipol.py:1690, in cart\_to\_irregular\_spline(cartgrid, values, newgrid, \*\*kwargs)  
1687 nx = cartgrid.shape[1]  
1688 ny = cartgrid.shape[0]  
 → 1690 cxmin = np.min(cartgrid[…, 0])  
1691 cxmax = np.max(cartgrid[…, 0])  
1692 cymin = np.min(cartgrid[…, 1])

File ~\anaconda3\envs\pyart\_env\lib\site-packages\numpy\core\fromnumeric.py:2953, in min(a, axis, out, keepdims, initial, where)  
2836 @array\_function\_dispatch(\_min\_dispatcher)  
2837 def min(a, axis=None, out=None, keepdims=np.\_NoValue, initial=np.\_NoValue,  
2838 where=np.\_NoValue):  
2839 “”"  
2840 Return the minimum of an array or minimum along an axis.  
2841  
(…)  
2951 6  
2952 “”"  
 → 2953 return \_wrapreduction(a, np.minimum, ‘min’, axis, None, out,  
2954 keepdims=keepdims, initial=initial, where=where)

File ~\anaconda3\envs\pyart\_env\lib\site-packages\numpy\core\fromnumeric.py:88, in \_wrapreduction(obj, ufunc, method, axis, dtype, out, \*\*kwargs)  
85 else:  
86 return reduction(axis=axis, out=out, \*\*passkwargs)  
—\> 88 return ufunc.reduce(obj, axis, dtype, out, \*\*passkwargs)

ValueError: zero-size array to reduction operation minimum which has no identity  
anybody have idea how to fix this ?

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [August 28, 2023, 6:17am UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291/2 "2023-08-28T06:17:41Z")

</div>

Hello @pikuljena,

welcome to openradar discourse.

I’m assuming a problem with `rlimits` not fitting your actual data projection.

Can you please report the contents of `rlimits` you are using? The content of `proj` would also be interesting, to see which projection the DEM data is in. `rlimits` and `rastercoords` have to be in the same projection.

---

<div class="post-metadata">

**Author:** ![pikuljena](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/pikuljena/32/198_2.png) [@pikuljena](https://openradar.discourse.group/u/pikuljena)\
**Post date:** [August 29, 2023, 12:48pm UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291/3 "2023-08-29T12:48:32Z")

</div>

rlimits  
(-0.9529142728897741, 74.71267576099122, 18.012914272889773, 79.00693742464783)

rastercoords  
array([[[60.00416667, 39.99583333],  
[60.0125 , 39.99583333],  
[60.02083333, 39.99583333],  
…,  
[99.97916667, 39.99583333],  
[99.9875 , 39.99583333],  
[99.99583333, 39.99583333]],

```
   [[60.00416667, 39.9875],
    [60.0125 , 39.9875],
    [60.02083333, 39.9875],
    ...,
    [99.97916667, 39.9875],
    [99.9875 , 39.9875],
    [99.99583333, 39.9875]],

   [[60.00416667, 39.97916667],
    [60.0125 , 39.97916667],
    [60.02083333, 39.97916667],
    ...,
    [99.97916667, 39.97916667],
    [99.9875 , 39.97916667],
    [99.99583333, 39.97916667]],

   ...,

   [[60.00416667, -9.97916667],
    [60.0125 , -9.97916667],
    [60.02083333, -9.97916667],
    ...,
    [99.97916667, -9.97916667],
    [99.9875 , -9.97916667],
    [99.99583333, -9.97916667]],

   [[60.00416667, -9.9875],
    [60.0125 , -9.9875],
    [60.02083333, -9.9875],
    ...,
    [99.97916667, -9.9875],
    [99.9875 , -9.9875],
    [99.99583333, -9.9875]],

   [[60.00416667, -9.99583333],
    [60.0125 , -9.99583333],
    [60.02083333, -9.99583333],
    ...,
    [99.97916667, -9.99583333],
    [99.9875 , -9.99583333],
    [99.99583333, -9.99583333]]])

```

proj  
\<osgeo.osr.SpatialReference; proxy of \<Swig Object of type ‘OSRSpatialReferenceShadow \*’ at 0x0000028D800E8360\> \>  
wkt = proj.ExportToWkt()  
‘GEOGCS[“WGS 84”,DATUM[“WGS\_1984”,SPHEROID[“WGS 84”,6378137,298.257223563,AUTHORITY[“EPSG”,“7030”]],AUTHORITY[“EPSG”,“6326”]],PRIMEM[“Greenwich”,0,AUTHORITY[“EPSG”,“8901”]],UNIT[“degree”,0.0174532925199433,AUTHORITY[“EPSG”,“9122”]],AXIS[“Latitude”,NORTH],AXIS[“Longitude”,EAST],AUTHORITY[“EPSG”,“4326”]]’

ind  
(0, 6000, 0, 6000)  
after indexing rastercoords becomes an empty array

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [August 29, 2023, 1:23pm UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291/4 "2023-08-29T13:23:28Z")

</div>

> [@pikuljena](#):
>
> (-0.9529142728897741, 74.71267576099122, 18.012914272889773, 79.00693742464783)

It looks like your rlimits is (latmin, lonmin, latmax, lonmax) but it should be (lonmin, latmin, lonmax, latmax) → (74.71267576099122, -0.9529142728897741, 79.00693742464783, 18.012914272889773).

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [October 27, 2023, 12:27pm UTC](https://openradar.discourse.group/t/valueerror-zero-size-array-to-reduction-operation-minimum-which-has-no-identity/291/5 "2023-10-27T12:27:09Z")

</div>


