Opening .img (Disk Image File) in Python

I would like to know the procedure for opening the .img file which is how we generally receive the processed image in SNAP. In addition to this the .HDR contains the geographic info which should also be imported for each pixel to have its own coordinate values.

Although Python offers ways to open an image in the GeoTiff format, saving the pre-processed image in the GeoTiff is time & space consuming.

Did you have a look at the following examples of using rasterio, and SNAPPY,

Source : https://www.hatarilabs.com/ih-en/sentinel2-images-explotarion-and-processing-with-python-and-rasterio

And use SNAPPY, the below link,

Source : https://senbox.atlassian.net/wiki/spaces/SNAP/pages/19300362/How+to+use+the+SNAP+API+from+Python#HowtousetheSNAPAPIfromPython-JythonApproach

I have the Anaconda Python 3.7.3 in my system.
Will the SNAP API function in this case?
It says somewhere in the following page that with the standard python approach ( use standard Python interpreter installed on computer) Python 3.5 (and more) is not supported ,
https://senbox.atlassian.net/wiki/spaces/SNAP/pages/19300362/How+to+use+the+SNAP+API+from+Python#HowtousetheSNAPAPIfromPython-Introduction

Are you working in Linux or windows os? I think in Linux the matter is simpler to configure SNAPPY, and it’s supported python 3.5 and up, also you could create an environment and different versions of python, for instance py2.7 and then cofi. with snappy, However under windows os, it’s a bit tricky, but it’s possible to solve it,

Please take a look at the following thread, Configuration SNAPPY with python under windows os

Source of the thread

Yes with Windows.
So I need to get rid of Anaconda 3.7 Python version and move back to 2.7?

Hello arnab.

I used to work on Windows and SNAPPY worked quite well using Python 3.7 (note that is was with SNAP 6, i didn’t try the newest SNAP version on windows). I talked about it here: Snappy requirements

Hope it helps.
Marcos.

Seems like an error here,

As I said it’s a bit tricky that’s why I only succeeded to configure using py3.4 and SNAP 7, I’m working in windows os. I don’t know if there is any other way to get cofi-ed with anaconda in windows os, but please take a look at the thread I referred to it in my previous post.

Dear @marfersel would you please to give explanation details if that possible! to be followed as an instructions.

Hi again

@arnab could you please show us the log file?

@falahfakhri i didn’t try to use it with anaconda but i suppose it is not the problem. I followed the instructions here: https://senbox.atlassian.net/wiki/spaces/SNAP/pages/50855941/Configure+Python+to+use+the+SNAP-Python+snappy+interface

I needed to install some dependencies such as JDK, Maven and Microsoft Visual C++ Build Tools (it is important to follow the same architecture, x64 or x86, in all the dependencies) , but while installing you are required to do so. May be someone has anything else to say.

Regards.

1 Like

This is what I found inside the text file,

INFO: Installing from Java module ‘C:\Users\ma6\AppData\Roaming\SNAP\modules\org-esa-snap-snap-python.jar’
INFO: Installing jpy…
ERROR: Traceback (most recent call last):
File “.\snappyutil.py”, line 280, in _main
force=args.force)
File “.\snappyutil.py”, line 154, in _configure_snappy
" $ cd jpy"
AttributeError: ‘list’ object has no attribute ‘join’

ERROR: Configuration failed with exit code 40

I got something different while trying out another way I remember I installed snappy and this is what I get. Do I need to get admin restrictions removed from my system?

It is strange that even when I run the SNAP command line as an Administrator the Access Denied thing still persists :thinking:

You have to choices now the one I mentioned in my previous post, Source of the post

And the the second option of @marfersel

Thanks, @falahfakhri and @marfersel, I will try to troubleshoot the Snappy Issue over the weekend and may even write back in case I am stuck.

@ABraun
Can you clarify why, even when I run the SNAP 7.0 Command Line as an Administrator, I am getting the Access is Denied error.

It is quite clearly mentioned in here that only Python 2.7, 3.3, and 3.4 are supported with SNAP 7.0.
SNAP_Python_Interface
This is a bit confusing since @marfersel employs Snappy with Python 3.7 & SNAP 6 and @falahfakhri does it with Python 3.4 & SNAP 7.

it is important that you name the location including the python.exe file, e.g.
snappy-conf.bat C:\user\ma6\AppData\Local\Continuum\anaconda3\python.exe

What about the Python version, is it only compatible till 3.4 as highlighted above.

I’m not sure - shouldn’t be too much differences.
If you want to go sure: You can create an environment of python 2.7 or 3.4 with the Anaconda Navigator and refer to the python.exe created there. https://docs.anaconda.com/anaconda/navigator/getting-started/ (see Managing Environments).
The location will be C:\user\ma6\AppData\Local\Continuum\anaconda3\envs\name_you_give\python.exe

@ABraun
The Python configuration is still failing

In that case it might be that Python 3.7 is not supported as you suggested.