How to Install SNAPHU on Mac OSX and Windows for Unwrapping InSAR Images?

How to install SNAPHU on Mac OS X?
How to install SNAPHU on Macbook OS X for SAR Interferometry?
How to do dInSAR Phase Unwrapping using SNAPHU on Mac OSX?
How to Configure SNAPHU for SNAP on Mac OS X?

On Mac OS X:
After making the interferogram and filtering it inside the ESA Sentinel Application Toolbox (SNAP)

  1. Go to Radar > Interferometric > Unwrapping > Snaphu Export
    and select the interferogram file in the Source Product. The click on “Snaphu Export Tab” and chose the output file directory.

Sometimes when you select the “Target Folder” it opens it and doesn’t returns to Snaphu Export Menu. For that just type filename as any random characters you like and click on select. For instance, I have typed abc and then clicked on Select

After doing that remove the /abc suffix from the directory path

Leave the rest of the settings be and click on Run and wait for the export to complete.

  1. Now close SNAP and download this file and extract the tarball tar.gz file
    https://web.stanford.edu/group/radar/softwareandlinks/sw/snaphu/snaphu-v2.0.3.tar.gz

Open Terminal on Mac and access extracted tarball folder on terminal like so.
Mine is on Desktop so I did this way. Your path may vary
cd /Users/muddasirshah/Desktop/snaphu-v2.0.3 and press enter

Type ls to show the list of items inside the folder

Now type cd src to access the src folder

Type sudo make install and press enter. SNAPHU will be installed and copied to system binaries (bin) folder

Once done type which snaphu and press enter it has to show you snaphu in bin directory and show you this path /usr/local/bin/snaphu If error prompts that means snaphu is not installed and change your system permissions. But that happens rarely. Here’s what should appear when you type which snaphu command

Type cd to navigate to home directory also type clear to keep the terminal interface clean.

  1. Minimize Terminal and navigate to the directory where you exported the files using snaphu export wizard. You will find a file named snaphu.conf
    Open it with a text editor
    just copy the code below the #command to call snaphu for your respective image and close the file. Don’t save any changes. The code should be like this snaphu -f snaphu.conf Phase_ifg_VV_28Mar2010_02May2010.snaphu.img 5191

now maximize the Terminal Window and paste the code you copied and press enter. The unwrapping process will start and will take some time depending on the image and processing parameters you gave while exporting the interferogram files. Mine took about one and a half hour for a single look complex SLC image. Close other tasks like browser music etc

  1. Once the process finishes close terminal and navigate to your Home Directory. The unwrapped img and Header (hdr) file are inside this folder. Close this folder

  2. Now open SNAP again and go to Radar > Interferometric > Unwrapping > Snaphu Import

In the Read Phase Menu select the original file wrapped file (interferogram file) phase hdr not the snaphu exported version.
In the Read Unwrapped Phase Menu select the unwrapped file hdr it will have the prefix unw
and is present in the home directory not to mention again
In the SnaphuImport Menu tick the box
In the Write Menu just chose the output folder and file name of your choice.

Give the process some time and SNAP will load the file in product explorer.
Import the Wrapped phase image and open the phase bands
Tile them evenly by Clicking Window > Tile Evenly
Here’s my result Left : Unwrapped Phase, Right : Wrapped Phase

On Windows:

  1. Download and extract SNAPHU v2.0.3.tar.gz from the link standfored link provided above

  2. Open SNAP and go to Radar>Interferometric>Unwrapping>SNAPHU Export

  3. Select the Interferogram file and give the output Target folder and click on Run

  4. Once the Export Process completes Minimize SNAP and go to the folder where you Exported.
    Copy all the files (not the folder)

  5. Open the extracted SNAPHU folder that you downloaded and paste the copied files inside the bin folder. A file named snaphu.conf will be inside the bin folder. Open it with a text editor and just copy the code shown

  6. Click on the address bar and type cmd. MS DOS prompt will open, paste the code you copied from conf (config) file and press enter.

  7. Unwrapping process will start and will take time

  8. When complete new files with the prefixes unw will be present inside this folder

  9. Now open SNAP again and go to Radar > Interferometric > Unwrapping > Snaphu Import

  10. In the Read Phase Menu select the original file wrapped file (interferogram file) phase hdr not the snaphu exported version.
    In the Read Unwrapped Phase Menu select the unwrapped file hdr it will have the prefix unw
    and is present in the home directory not to mention again
    In the SnaphuImport Menu tick the box
    In the Write Menu just chose the output folder and file name of your choice.

Give the process some time and SNAP will load the file in product explorer.
Import the Wrapped phase image and open the phase bands
Tile them evenly by Clicking Window > Tile Evenly
Here’s my result Left : Unwrapped Phase, Right : Wrapped Phase

Thank you

Credits:
Muddasir Shah (MS in Remote Sensing & GIS | Institute of Space Technology, Islamabad)
For Queries please send an email
muddasirshah@outlook.com

Special Thanks to
Prof. Dr. Waqas A. Qazi (GREL - Institute of Space Technology)
waqas.qazi@grel.ist.edu.pk

3 Likes

Thank you for sharing these nice instructions.

1 Like

I am trying the same method. But it doesn’t work
Screen Shot 2020-09-13 at 1.45.24 AM

1 Like

Hey Tamanna!
Have you downloaded this zip file?
https://web.stanford.edu/group/radar/softwareandlinks/sw/snaphu/snaphu-v2.0.3.tar.gz

download it and place it on desktop, and then extract there. then open terminal and type

cd Desktop

type ls

terminal will show list of all available folders on Desktop

I think you have not placed the folder on desktop so that’s why it is showing that message.

I have made a video for you. Watch it
How to install SNAPHU

2 Likes

Thanks for your response, but it shows error.
Screen Shot 2020-09-13 at 3.11.49 PM

the directory you name here must exist before compiling. You can either create it yourself or change this line:

grafik

I am not able to understand what are you saying, how can I creat or change the directory and where?

before you compile snaphu have a look in the makefile in the source folder. All directories and specifications are defined here. If the script tells you that a folder does not exist (like in your first screenshot), it is because the directory defined in the makefile does not exist.
So you either change that line to an existing folder or you create the folder manually at this location.

but the directory is already exist.
Screen Shot 2020-09-13 at 4.41.30 PM

it exists within the downloaded snaphu package but not under usr/local/man/man1

grafik

So, what should I write here??
should i creat the directory in snaphu folder?

simply create the folder usr/local/man/man1 so snaphu can put the manual in there.

1 Like

I did the same thing but it didn’t work.

i creat folder

sorry, this is not correct. You created it inside the snaphu folder but, the usr folder is a system directory which already exists at a higher level.

You have to go some levels up. Or simply enter usr in the navigation

1 Like

Its working. Thanks for giving your precious time.

good job - congratulations on sticking at it until it worked :+1:

I think it doesn’t work properly.
Can you please help me in this.

Screen Shot 2020-09-13 at 10.42.59 PM

25000 lines is quite huge.
It is recommended to set some overlap (200 pixels) for such large files. Delete all temporary files, modify the config file (maybe also set MST instead of MCF) and run the command again.

1 Like