Using snappy on jupyter notebook (over anaconda platform)

hi, I’m kind of new to programming in python so my question might be a bit novice.
In my daily work I write scripts using the jupyter notebook platform. My python (2.7 on win 64bit) and all its modules
and packages are installed over Anaconda (64 bit). I would like to implement in my scripts processing of ESA data (like Sentinel-3) and for that I would like to be able to use snappy on my jupyter notebook. I recently installed SNAP and on the python executable
option I inserted the path to python.exe on anaconda folder. However when I try to import snappy I get error massage that
there is no module named snappy. Is anyone using snappy on jupyter notebook that can advise me or direct me on how to do that?
I’m not a software engineer or an expert on these topics so an answer for the regular laymen would be appreciated.

Good Morning,

actually the STEP webpage offers something that could be really close to your needs.

If you look at this link :

https://github.com/techforspace/sentinel

you will find some jupyter notebooks exploiting the python module snappy for SNAP.

There you can find how to properly install the module, and then some interesting examples of application.

The repository is currently mantained and more tutorials and examples will be added soon by the staff of TFS

Hi ranp,

The error you received there is no module named snappy , is because snappy has not been properly installed. For installing the sanppy you need to:

  • Execute the python configuration file which is the snappy-conf located at the directory snap/bin. Once you are in that folder, you just need to do the following: ./snappy-conf < location of your python executable>

  • Once this step is completed, you need to find snappy.ini located at .snap/snap-pyhton/snappy/snappy.ini , open the text editor and set the java maximum memory (that depends on your machine). In my case this text file looks like:
    [DEFAULT]
    snap_home = /home/io/snap
    java_max_mem: 43G

  • Finally, you have to export the snappy path in the bashrc file.
    export PYTHONPATH=$PYTHONPATH:

If you are interested in automating some steps from SNAP GUI into snappy, I suggest you not to use jupyter notebook at it is slow (expect if you are running something light ). Jupyter notebook is more for demonstration purposes rather than running something heavy

hi antonio19812 and johngan,
Thanks you very much for the quick responses.
This is a lot of information for me :slight_smile: so I need some time to process…

A small question for johngan - you mentioned that jupyter is quite slow for running “heavy” scripts. Which python platform would you recommend for running scripts that process large amounts of data?

Thanks

For me, one of the best python platform you can install in your machine is PyCharm. It is recommended by many people.

have a look at the link below on how to install it:

2 Likes

I have found a clean way to install snappy i.e via two ways : (Here, I have created an Anaconda virtual environment called sentinel which supports python 3.4.)

A.) If SNAP is under installation i.e. first time installation from .sh file (Linux installation):

a) The dialog box will ask to configure snappy, enter the path where the python executable resides i.e. /home/shubham/anaconda3/envs/sentinel/bin/python. The user can also get this path by activating a conda environment and using command which python where python 3.4 resides.

B.) Still if the user is not able to import snappy ,try the following steps :

b.) Now go to the path /home/shubham/.snap/snap-python copy snappy folder to the path where python site-packages reside i.e. /home/shubham/anaconda3/envs/sentinel/lib/python3.4/site-packages.(.snap folder is hidden, so unhide it by clicking Ctrl+H in the Home directory)

c.) Now go to the directory where snappy-conf is there(i.e. at path /home/shubham/snap/bin) and from terminal launch ./snappy-conf /home/shubham/anaconda3/envs/sentinel/bin/python. (NOTE : This snap folder is not hidden)

d) open python IDE or through terminal and try to run import snappy,which should definitely run. This approach is tried and tested on Ubuntu 16.04LTS and SNAP 7.

2 Likes

Thanks a lot for this big effort you did.

Config. snappy under Linux environment has been discussed and there is no problem, however, the problem is under windows.