PYTHON ArcGIS API (Error Code: 400)

311
0
04-02-2020 10:46 PM
GustavoColmenares
New Contributor

HI all,

I was trying to work with one of the jupyter notebooks from Esri/ arcgis-python-api hosted in Github and I got the following exception: Exception: Unable to complete operation. Invalid band index. (Error Code: 400), in the last block of code.

The jupyter notebook building_a_change_detection_app_using_jupyter_dashboard, runs correctly with no errors, but when clicking in the widget "Detect changes" created with the last cell of code it returns the previous exception mentioned.

Any idea of how to solve this would be very appreciated

# create the action button
diffbtn = widgets.Button(description='Detect changes'
                         ,disabled=False
                         ,button_style='success'
                         ,tooltip= 'Show Different Image'
                         ,icon='check')

def on_diffbutton_clicked(b):
    # m.clear_graphics()
    first = df.iloc[oldslider.value].OBJECTID
    last = df.iloc[newslider.value].OBJECTID
    old = landsat.filter_by('OBJECTID='+str(first))
    new = landsat.filter_by('OBJECTID='+str(last))
    diff = stretch(composite_band([ndvi(old, '5 4')
                                   ,ndvi(new, '5 4')
                                   ,ndvi(old, '5 4')])
                   ,stretch_type='stddev'
                   ,num_stddev=3
                   ,min=0
                   ,max=255
                   ,dra=True
                   ,astype='u8')
    
    m.add_layer(diff)
    
diffbtn.on_click(on_diffbutton_clicked)
diffbtn

Error prompted

Exception                                 Traceback (most recent call last)<ipython-input-34-316a52ed9501> in on_diffbutton_clicked(b)     13     old = landsat.filter_by('OBJECTID='+str(first))     14     new = landsat.filter_by('OBJECTID='+str(last))---> 15     diff = stretch(composite_band([ndvi(old, [5, 4])     16                                    ,ndvi(new, [5, 4])     17                                    ,ndvi(old, [5, 4])
0 Kudos
0 Replies