kvos / CoastSat

Global shoreline mapping tool from satellite imagery
http://coastsat.space
GNU General Public License v3.0
696 stars 252 forks source link

Cannot locate module 'coastsat' #42

Closed dragonDaddy2012 closed 5 years ago

dragonDaddy2012 commented 5 years ago

Followed the README: created new env and activated 'coastsat' via .yml tried in both Jupyter and Spyder, continue to get error when attempting to import the required scripts from 'coastsat'

from coastsat import SDS_download, SDS_preprocess, SDS_shoreline, SDS_tools, SDS_transects

"No module named coastsat"

When running via jupyter:

EEException                               Traceback (most recent call last)
<ipython-input-3-81739100d1f3> in <module>
----> 1 metadata = SDS_download.retrieve_images(inputs)

~/Downloads/CoastSat-master/coastsat/SDS_download.py in retrieve_images(inputs)
     98 
     99     # initialise connection with GEE server
--> 100     ee.Initialize()
    101 
    102     # read inputs dictionnary

~/anaconda3/envs/coastsat/lib/python3.7/site-packages/ee/__init__.py in Initialize(credentials, opt_url, use_cloud_api, cloud_api_key)
    103       cloud_api_key=cloud_api_key)
    104   # Initialize the dynamically loaded functions on the objects that want them.
--> 105   ApiFunction.initialize()
    106   Element.initialize()
    107   Image.initialize()

~/anaconda3/envs/coastsat/lib/python3.7/site-packages/ee/apifunction.py in initialize(cls)
    150     """Initializes the list of signatures from the Earth Engine front-end."""
    151     if not cls._api:
--> 152       signatures = data.getAlgorithms()
    153       api = {}
    154       for name, sig in signatures.items():

~/anaconda3/envs/coastsat/lib/python3.7/site-packages/ee/data.py in getAlgorithms()
    648                 is not specified.
    649   """
--> 650   return send_('/algorithms', {}, 'GET')
    651 
    652 

~/anaconda3/envs/coastsat/lib/python3.7/site-packages/ee/data.py in send_(path, params, opt_method, opt_raw)
   1194     # error above rather than this generic one.
   1195     raise ee_exception.EEException(
-> 1196         'Server returned HTTP code: %d' % response.status)
   1197 
   1198   # Now known not to be an error response...

EEException: Server returned HTTP code: 404

kvos commented 5 years ago

hi @dragonDaddy2012, there are 4 current issues (#41 #40 #33 ) with the same error message when initialising the ee package and that HTTP code 404....I'm not sure at the moment what can be going wrong as it works fine on my coastsat environment but I am sure that this can be fixed easily. (for the spyder error "No module named coastsat", this is because you are not in the correct directory. You can navigate through directories on the top right panel of spyder and go to the directory that contains the /coastsat folder)

But this will not solve the second error with HTTP code 404. To debug this issue, could you please try the type the following commands on the anaconda prompt:

This should prompt the same error. To fix this I propose you remove the coastsat environment already installed (conda env remove --name coastsat and then conda clean --all) and re-install a new one with more updated versions of the packages. The you can open the environment.yml file with a text editor and replace its content with the following:

channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.7
  - matplotlib
  - earthengine-api
  - gdal
  - geopandas
  - pytz
  - scikit-image
  - scikit-learn
  - shapely
  - spyder
  - notebook

Then run conda env create -f environment.yml -n coastsat again and install the new environment. This should fix the issue, let me know. Cheers, Kilian

ghost commented 5 years ago

hi @dragonDaddy2012, there are 4 current issues (#41 #40 #33 ) with the same error message when initialising the ee package and that HTTP code 404....I'm not sure at the moment what can be going wrong as it works fine on my coastsat environment but I am sure that this can be fixed easily. (for the spyder error "No module named coastsat", this is because you are not in the correct directory. You can navigate through directories on the top right panel of spyder and go to the directory that contains the /coastsat folder)

But this will not solve the second error with HTTP code 404. To debug this issue, could you please try the type the following commands on the anaconda prompt:

* `conda activate coastsat`

* `python`

* `import ee`
  -`ee.Initialize()`

This should prompt the same error. To fix this I propose you remove the coastsat environment already installed (conda env remove --name coastsat and then conda clean --all) and re-install a new one with more updated versions of the packages. The you can open the environment.yml file with a text editor and replace its content with the following:

channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.7
  - matplotlib
  - earthengine-api
  - gdal
  - geopandas
  - pytz
  - scikit-image
  - scikit-learn
  - shapely
  - spyder
  - notebook

Then run conda env create -f environment.yml -n coastsat again and install the new environment. This should fix the issue, let me know. Cheers, Kilian

I think I discovered the 404 error. Google manual approves account requests to access the images. I have put the request in and will re-attempt upon approval. I will navigate to the directory as well and see how that works.

kvos commented 5 years ago

did you get it working? Did you link your credentials with earthengine authenticate? you may need a Google account for this

ghost commented 5 years ago

Hello @kvos , Still awaiting approval by Google for Earth Engine. Please see earlier reply [Google manually approves]. I will let you know once I get approval :)

kvos commented 5 years ago

Ok thanks for the info, this must be new because we never had to wait for approval from google before

dragonDaddy2012 commented 5 years ago

@kvos , got access - so, making progress. However, now we are getting stalled at: output = SDS_shoreline.extract_shorelines(metadata, settings)

Error Message:

File "./CoastSat-master/coastsat/SDS_shoreline.py", line 525, in show_detection
    mng.window.showMaximized()

**AttributeError: 'FigureManagerBase' object has no attribute 'window'**

Running "example.py", changed the following:

polygon = [[[12.7408410319,45.5212666771],
            [12.7264214762,45.5381024608 ],
            [12.839717985,45.5984293404],
            [12.8737069376,45.5753637629],
            [12.7408410319,45.5212666771]]]

To see the full edited "example.py" and the data-specific pulls, please see the temp repo: https://github.com/dragonDaddy2012/CoastSat_Linked

kvos commented 5 years ago

ok @dragonDaddy2012 I think this is an easy fix...in Spyder go under Preferences>IPython console> Graphics andchange the Grapgics Backend to Automatic (instead of Inline), then restart Spyder. This will make the figures interactive and solve that issue.

By the way, could you shortly describe the process of getting access to GEE as I think other users are having the same problem, thanks

dragonDaddy2012 commented 5 years ago

@kvos That seemed to have worked (it does, on the example.py). However, I have tried two sets of polygons, and in both instances, get the following error:

metadata = SDS_download.retrieve_images(inputs)
Downloading images:
Traceback (most recent call last):

  File "<ipython-input-3-81739100d1f3>", line 1, in <module>
    metadata = SDS_download.retrieve_images(inputs)

  File "/CoastSat-master/coastsat/SDS_download.py", line 538, in retrieve_images
    utm_zone_selected =  np.max(np.unique(utm_zones))

  File "/anaconda3/envs/coastsat/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 2505, in amax
    initial=initial)

  File "/anaconda3/envs/coastsat/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

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

(I will post actual script on same temp repo).

Regarding GEE, I'd be happy to describe:

You need to register for GEE via the GEE portal: https://signup.earthengine.google.com. This is free, however, you will need to provide some details (e.g. What you plan on using GEE for, etc.).

Google manually approves GEE requests as they are received. Once the form is submitted, Google will process and send a confirmation email. After approval, you will receive another email notification. That simple!

kvos commented 5 years ago

I just had a look at your script and it looks like you have inverted longitudes and latitudes. Thanks for describing the process, I have now added this to the documentation

kvos commented 5 years ago

closing this issue as it is solved