GithubHelp home page GithubHelp logo

Issue setting up environment about coastsat HOT 14 CLOSED

kvos avatar kvos commented on June 12, 2024
Issue setting up environment

from coastsat.

Comments (14)

kvos avatar kvos commented on June 12, 2024

@huyquangt
I don't know what is causing that error, I was not able to reproduce it and line 207 of SDS_download.py doesn't seem to have an invalid syntax. I suggest you go into the /coastsat subfolder and delete the pycache folder. Then open spyder (within the coastsat env) and try to run example.py again.

Let me know how it goes,

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Hi @kvos,

Sorry for a late reply & I have not sorted this out..

The error message only happens with Spyder on Windows (Spyder on Linux works fine). However, on windows, I can run this script using Command Prompt (e.g. python example.py). Therefore, I guess Spyder requires additional packages.

Any more suggestions?

from coastsat.

chrisleaman avatar chrisleaman commented on June 12, 2024

@huyquangt, my guess would be that Spyder is using python2 instead of python3. Can you run the following commands in Spyder and let us know what you get?

>>> import sys
>>> print(sys.version)
3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]

It should be showing python version 3.x, rather than 2.x.

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Hi @chrisleaman ,

my spyder is 3.7.3 actually.

I have reinstalled anaconda, then now example.py can run a halft way ( all files were succesfully downloaded and saved in 'reprocessed' folder), then another error message appears:

Reloaded modules: coastsat, coastsat.SDS_download, coastsat.gdal_merge, coastsat.SDS_preprocess, coastsat.SDS_tools, coastsat.SDS_shoreline, coastsat.SDS_transects
Downloading images:
S2: 7 images
100%
0 pairs of overlapping Sentinel-2 images were merged
Satellite images saved as .jpg in C:\CoastSat-master\data\NARRA\jpg_files\preprocessed
Traceback (most recent call last):

File "", line 1, in
runfile('C:/CoastSat-master/example.py', wdir='C:/CoastSat-master')

File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)

File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/CoastSat-master/example.py", line 81, in
settings['reference_shoreline'] = SDS_preprocess.get_reference_sl(metadata, settings)

File "C:\CoastSat-master\coastsat\SDS_preprocess.py", line 793, in get_reference_sl
pts_coords = SDS_tools.convert_epsg(pts_sl, image_epsg, settings['output_epsg'])

File "C:\CoastSat-master\coastsat\SDS_tools.py", line 144, in convert_epsg
points_converted = np.array(coordTransform.TransformPoints(points))

File "C:\Anaconda3\lib\site-packages\osgeo\osr.py", line 1288, in TransformPoints
return _osr.CoordinateTransformation_TransformPoints(self, *args)

TypeError: in method 'CoordinateTransformation_TransformPoints', argument 1 of type 'OSRCoordinateTransformationShadow *'

from coastsat.

chrisleaman avatar chrisleaman commented on June 12, 2024

Can we check which versions of the packages you have installed? Make sure you have the coastsat environment activated (conda activate coastsat), then can you provide the output of conda list?

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Yes.. I did run conda activate coastsat and the conda list is attached.
conda_list.txt

from coastsat.

kvos avatar kvos commented on June 12, 2024

hi @huyquangt , is this error still happening or you found a way around it?
I looked at your conda_list.txt file and you have a lot of packages in there that are not required for CoastSat, some of these may be conflicting with GDAL. I suggest you create a new environment with only the packages listed in environment.yml and try again. Let me know how it goes

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Hi @kvos,

sorry for a late reply as I was working on another task..

I have not solved this problem yet. Attached is the list of packages I am currently having after activating coastsat program.

Another error message comes out when I specify several satellite at the same time below is also attached.

Traceback (most recent call last):

File "", line 1, in
runfile('C:/CoastSat-master/example.py', wdir='C:/CoastSat-master')

File "C:\Anaconda3\envs\coastsat\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\Anaconda3\envs\coastsat\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/CoastSat-master/example.py", line 53, in
metadata = SDS_download.retrieve_images(inputs)

File "C:\CoastSat-master\coastsat\SDS_download.py", line 207, in retrieve_images
print('\r%d%%' % (int(((i+1)/n_img)*100)), end='')

UnboundLocalError: local variable 'i' referenced before assignment

conda_list_COASTSAT.txt

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

For example,

For a test, I specify:

#date range

dates = ['2012-04-01', '2012-05-01']

# Sat missions

sat_list = ['L5', 'L7', 'L8', 'S2']

The error message is:

File "C:\CoastSat-master\coastsat\SDS_download.py", line 207, in retrieve_images
print('\r%d%%' % (int(((i+1)/n_img)*100)), end='')

UnboundLocalError: local variable 'i' referenced before assignment

from coastsat.

kvos avatar kvos commented on June 12, 2024

I don't really know what may be going wrong here as the line that you mention is correct and is sitting inside a loop for i in range(n_img) so i is always defined. I saw that your coastsat environment still has additional packages that are not needed, since those may be causing conflicts you could run conda clean -all and then re-install the CoastSat environment.

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Ok... it is solved....thanks kvos..

from coastsat.

kvos avatar kvos commented on June 12, 2024

ok, just out of curiosity, what solved the problem? re-installing the environment?

from coastsat.

huyquangtranaus avatar huyquangtranaus commented on June 12, 2024

Yes @kvos I deleted everything and downloaded the current codes in GitHub and run new environment.

from coastsat.

kvos avatar kvos commented on June 12, 2024

perfect, I will close the issue then.
cheers,
Kilian

from coastsat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.