New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Land-cover-map example: sentinelhub_service.py", line 133, in _add_data valid_mask = data[..., -1] IndexError: index -1 is out of bounds for axis 0 with size 0 #9

Closed
kvigulis opened this Issue Sep 7, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@kvigulis
Copy link

kvigulis commented Sep 7, 2018

Hi,

This is related to the 'Land Use and Land Cover (LULC) classification' example - more specifically 2_eopatch-L1C.ipynb notebook. When using a shape file of my own region, generated via 1_split-AOI.ipynb notebook - for example this geojson of California, I get the following error, when trying to execute the workflow in 2_eopatch-L1C.ipynb:

  File "/home/karlis/PythonProjects/sentinel_mining/L1C_patches.py", line 108, in <module>
    save:{'eopatch_folder':patch_name}})
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/core/eoworkflow.py", line 165, in execute
    _, intermediate_results = self._execute_tasks(input_args=input_args, out_degs=out_degs, monitor=monitor)
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/core/eoworkflow.py", line 188, in _execute_tasks
    monitor=monitor)
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/core/eoworkflow.py", line 215, in _execute_task
    return task(*inputs, **kw_inputs, monitor=monitor)
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/core/eotask.py", line 49, in __call__
    return self.execute(*eopatches, **kwargs)
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/io/sentinelhub_service.py", line 220, in execute
    self._add_data(eopatch, np.asarray(images))
  File "/home/karlis/PythonProjects/sentinel_mining/venv/lib/python3.6/site-packages/eolearn/io/sentinelhub_service.py", line 133, in _add_data
    valid_mask = data[..., -1]
IndexError: index -1 is out of bounds for axis 0 with size 0

In 1_split-AOI.ipynb notebook in BBoxSplitter() function I try to set the numbers, so that the patch sizes are approximately 1000x1000 pixels, which seemed to be the case in the original example with Slovenia.

I've tried multiple locations and have so far observed this with USA (California, Texas, Nevada, Maine), also North Korea. The time interval was usually set across several months in 2018, but changing it didn't seem to affect anything, so it might be related to location or the shapefiles coming from 1_split-AOI.ipynb notebook.

Thanks

@mlubej

This comment has been minimized.

Copy link
Contributor

mlubej commented Sep 10, 2018

Hi @kvigulis! The problem is related to the geojson file that you use. It has coordinates, but no CRS is defined. I assume this is in the national CRS for california, which would seem to be UTM_10N (@AleksMat is this info saved anywhere or does one have to look for it manually?)

In this case, it works for me and I'm able to obtain image data without any errors.

@kvigulis

This comment has been minimized.

Copy link
Author

kvigulis commented Sep 10, 2018

Thank you @mlubej. You're absolutely right. This was caused by incorrect CRS setting, when generating the shape file for bboxes of patches. Didn't know the idea behind UTM CRS.

For any beginner who stumbles upon this - GeoJson files will often use UTM CRS, which will be different depending on which zone/area of the Earth is described. So you have to set the UTM with the correct zone in 1_split-AOI.ipynb.

@kvigulis kvigulis closed this Sep 10, 2018

@NiRajlunavat

This comment has been minimized.

Copy link

NiRajlunavat commented Feb 2, 2019

Hi
I am facing the same issue....may i know where to find the CRC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment