Take me to pcigeomatics.com

PCI Geomatics Help Center

How can we help you today?

SAR Change Detection

PCI Geomatics -

'''**********************************************************

	PCI Geomatics(C) - SAR Change Detection Workflow
	Last updated May 01, 2015
**********************************************************'''

print ""
print ""
print "***************************************************************"
print ""
print "       -= PCI Geomatics(C) =-"
print "     SAR Change Detection Workflow"
print "     Last modified May 01, 2015"
print "     Developed on Geomatica 2015, Build 2015-04-27 Commercial Release"
print ""
print "***************************************************************"

# This script runs the following PPFs in a top-down sequence on two RADARSAT-2 Images
# 1. SARINGEST
# 2. AUTOSHIFT
# 3. CLIP
# 4. CCDINTEN
# 5. EXPOLRAS

# Download the freely available image used in this analysis from this link:
# http://gs.mdacorporation.com/SatelliteData/Radarsat2/samples/Ultra-Fine_Interferometric_Pair/Phoenix_R2_UltraFine12_20080504_HH_SLC.zip
# http://gs.mdacorporation.com/SatelliteData/Radarsat2/samples/Ultra-Fine_Interferometric_Pair/Phoenix_R2_UltraFine12_20080528_HH_SLC.zip
# The AOI.shp file used in this example can be easily re-created in Focus:
  # Load the R2 image in focus
  # On the Maps tab, right click on New Area and select New Vector Layer - choose Whole Polygon and Use the Layer Georeferencing from the R2 image
  # Use the Vector drawing tools and draw a a polygon where you would like to look at changes
  # Right click on the Polygon layer, and save it to disk

import os # This Python library is needed to delete temporary files from disk
from pci.saringest import saringest
from pci.autoshift import autoshift
from pci.clip import clip
from pci.ccdinten import ccdinten
from pci.expolras import expolras
from pci.exceptions import *

print ""
print "STEP 1"
print "Ingesting SAR Image 1"

# ------------------------------------------------
#  Ingest First Image
# ------------------------------------------------

# Parameters for saringest
img1_in = r"D:\data_001\Python_Workflows\SAR_Change_Detection\Phoenix_R2_UltraFine12_20080504_HH_SLC\product.xml"
img1_out = r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May04_2008.pix"
dbiw = []
poption = 'OFF'
dblayout = 'BAND'
calibtyp = 'SIGMA'

saringest(img1_in, img1_out, dbiw, poption, dblayout, calibtyp)

print "Done"
print ""
print "STEP 2"
print "Ingesting SAR Image 2"

# ------------------------------------------------
#  Ingest Second Image
# ------------------------------------------------

# Parameters for saringest
img2_in = r"D:\data_001\Python_Workflows\SAR_Change_Detection\Phoenix_R2_UltraFine12_20080528_HH_SLC\product.xml"
img2_out_temp = r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May28_2008_temp.pix"
dbiw = []
poption = 'OFF'
dblayout = 'BAND'
calibtyp = 'SIGMA'

saringest(img2_in, img2_out_temp, dbiw, poption, dblayout, calibtyp)

print "Done"
print ""
print "STEP 3"
print "Perfoming Autoshift- Image Alignment"

# ------------------------------------------------
#  Perform Autoshift on second image
# ------------------------------------------------

# Parameters for autoshift
fili = img2_out_temp
filref	= img1_out
dbic	=	[]	# Uses all input image channels to compute the correlation
img2_out = r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May28_2008.pix"
searchr	= []
numtiles= [4,4]					#Use 4 tiles in the X- and Y-directions

autoshift( fili, filref, dbic, img2_out, searchr, numtiles )

print "Done"
print ""
print "STEP 4"
print "Perfoming Coherent Change Detection"

# ------------------------------------------------
#  Perform CCDINTEN
# ------------------------------------------------

# Parameters for ccdinten
file = img1_out # Input image file name
filref = img2_out 	# Reference image file name
dbic = [] 					# Uses all channels to detect change
ccd_out = r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May4_May28_2008_CCDINTEN.pix" 	# Output file name
winsize = [5] 					# Use a processing window of 5 by 5

ccdinten ( file, filref, dbic, ccd_out, winsize )

print "Done"
print ""
print "STEP 5"
print "Clipping smaller areas of interest"

# ------------------------------------------------
#  Perform CLIP
# ------------------------------------------------

# Parameters for clip

clip_file = ccd_out
dbic = [1,2,3,4]
dbsl = []
sltype = ""
ccdinten_clipped = r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May4_May28_2008_CCDINTEN_clipped.pix"
ftype = "PIX"
foptions = ""
clipmeth = "LAYERVEC"
clipfil = r"D:\data_001\Python_Workflows\SAR_Change_Detection\AOI.pix"
cliplay = [2]
laybnds = "SHAPES"
coordtyp = ""
clipul = ""
cliplr = ""
clipwh = ""
initvalu = [0]
setnodat = "Y";
oclipbdy = "Y"

clip (clip_file, dbic, dbsl, sltype, ccdinten_clipped, ftype, foptions, clipmeth, clipfil, cliplay, laybnds, coordtyp, clipul, cliplr, clipwh, initvalu, setnodat, oclipbdy )

print "Done"
print ""
print "STEP 6"
print "Extracting change polygons"

# ------------------------------------------------
#  Perform EXPOLRAS
# ------------------------------------------------

# Parameters for Expolras

FILI	=	ccdinten_clipped
DBIC	=	[4]
THRTYPE	=	"PixelValue"
TVAL	=	[95]
AREAVAL	=	[25]	# only features larger than 25 pixels are retained
COMPVAL	=	[]
CHANGES	=	r"D:\data_001\Python_Workflows\SAR_Change_Detection\U12_May4_May28_2008_changes.pix"
FTYPE	=	""
FOPTIONS	=	""

expolras( FILI, DBIC, THRTYPE, TVAL, AREAVAL, COMPVAL, CHANGES, FTYPE, FOPTIONS )

print "Done"
print ""
print "STEP 7"
print "Cleaning up temporary files"
os.remove(img2_out_temp)
os.remove(ccd_out)
os.remove(ccdinten_clipped)
print "Done"
print ""
print "End of Workflow"
print ""
print "Get more Python help at http://github.com/pcigeomatics"
Have more questions? Submit a request

Comments

Powered by Zendesk