Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The easiest way to configure your Python installation for the usage SNAP-Python (snappy) interface is to do it during the installation of SNAP. Within the installer you can simply activate a checkbox and select the path to the python executable.

...

This will generate the Python module snappy configured for the current SNAP installation and your Python interpreter <python-exe> into the .snap/snap-python
directory of the user home directory. The parameter <python-exe> must be the full path to the Python interpreter executable which you want to use with SNAP (supported versions are 2.7, 3,.3 and to 3.46).  If you want the snappy module to be placed somewhere else use:

...

This approach only works if the current working directory is located in the <snappy-dir>. To generally make use of snappy you need to do one of the following configuration steps.

...

To effectively use the SNAP Python API from Python, the  the snappy module must be detectable by your Python interpreter. There are a number of ways to achieve this. 

...

Code Block
languagepy
import sys
sys.path.append('<snappy-dir>') # or sys.path.insert(1, '<snappy-dir>')
import snappy
  • In case you seek for a generic solution without needing to set <snappy-dir> you may automatically find snappy through the 'USERPROFILE' environment variable. Note that this solution requires snappy to be located at the value of 'USERPROFILE':
Code Block
languagepy
import os
snappy_envar = 'USERPROFILE'
envs = os.environ
if not snappy_envar in envs.keys():
	raise Exception('Can’t find snappy')
else:
	snappy_dir = os.path.join(envs.get(snappy_envar), '.snap', 'snap-python')
sys.path.append(snappy_dir)
import snappy


Change the Memory Settings

...

This means that snappy can use 6GB of you your RAM. A recommended value is 70%-80% of the available RAM in your system.

...