'''********************************************************** PCI Geomatics(C) - SAR Change Detection Workflow **********************************************************''' print "" print "" print "***************************************************************" print "" print " -= PCI Geomatics(C) =-" print " SAR Full Quad Ship 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 a single RADARSAT-2 Image # 1. SARINGEST # 2. PSPOLFIL # 3. BURNMASK # 4. EXPOLRAS # Download the freely available image used in this analysis from this link: # http://gs.mdacorporation.com/SatelliteData/Radarsat2/samples/Fine_Quad-Pol_Dataset/StOfGibraltar_R2_FineQuad3_HH_VV_HV_VH_SLC.zip # The land mask created 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 rough outline of the land - draw two separate polygons (one for the north, one for the south) # 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.pspolfil import pspolfil from pci.burnmask import burnmask from pci.expolras import expolras from pci.exceptions import * print "" print "STEP 1" print "Ingesting SAR Image" # ------------------------------------------------ # Ingest Image # ------------------------------------------------ # Parameters for saringest img1_in = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Gibraltar\product.xml" img1_out = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Mar31_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 "Now Applying filtering" # ------------------------------------------------ # Perform Adaptive Lee Filtering # ------------------------------------------------ # Parameters for pspolfil fili = img1_out filtered = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Mar31_2008_filtered.pix" flsz = [7] # Integer nlook = [1] # Float pspolfil(fili, filtered, flsz, nlook) print "Done" print "" print "STEP 3" print "Now masking the land prior to final ship detection analysis" # ------------------------------------------------ # Perform BURNMASK # ------------------------------------------------ # Parameters for Burnmask fili = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Mar31_2008_filtered.pix" dbic = [1,2,3,4] # Integer mask = [2] # This is the location of the vector segment maskfile = r"D:\data_001\Python_Workflows\Ship_Detection\land.pix" burnval = [-10] # Float water_only = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Mar31_2008_filtered_intensity_no_land.pix" dboc = [] # Integer ftype = u"" foptions = u"" burnmask(fili, dbic, mask, maskfile, burnval, water_only, dboc, ftype, foptions) print "Done" print "" print "STEP 4" print "Final step, now detecting ships" # ------------------------------------------------ # Perform EXPOLRAS # ------------------------------------------------ # Parameters for Expolras FILI = water_only DBIC = [2] #Note that for the analysis we are only using the HV channel (best for ship detection) THRTYPE = "PixelValue" TVAL = [0.007] #Be sure to experiment with this value by loading the imagery in Focus AREAVAL = [5] # Setting a minimum number of pixels to include - to reduce some noise COMPVAL = [] Detected_ships = r"D:\data_001\Python_Workflows\Ship_Detection\FQ13_Mar31_2008_ships.pix" FTYPE = "" FOPTIONS = "" expolras( FILI, DBIC, THRTYPE, TVAL, AREAVAL, COMPVAL, Detected_ships, FTYPE, FOPTIONS ) print "Done" print "" print "STEP 5" print "Cleaning up temporary files" os.remove(filtered) os.remove(water_only) print "Done" print "" print "End of Workflow" print "" print "Get more Python help at http://github.com/pcigeomatics"
Ship Detection Workflow
PCI Geomatics -
Comments