Compare View

switch
from
...
to
 
Commits (16)
scripts/common/New_ProcessingChain.py
... ... @@ -36,42 +36,101 @@ def PreProcessS2(config,tileFolder,workingDirectory):
36 36 cfg = Config(args.config)
37 37 struct = cfg.Sentinel_2.arbo
38 38 outputPath = Config(file(config)).chain.outputPath
  39 + outRes = Config(file(config)).chain.spatialResolution
39 40 projOut = Config(file(config)).GlobChain.proj
40 41 projOut = projOut.split(":")[-1]
41 42 arbomask = Config(file(config)).Sentinel_2.arbomask
42 43 cloud = Config(file(config)).Sentinel_2.nuages
43 44 sat = Config(file(config)).Sentinel_2.saturation
44 45 div = Config(file(config)).Sentinel_2.div
45   - #cloud_reproj = Config(file(config)).Sentinel_2.nuages_reproj
46   - #sat_reproj = Config(file(config)).Sentinel_2.saturation_reproj
47   - #div_reproj = Config(file(config)).Sentinel_2.div_reproj
48   - """
49   - B5 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B5.tif")
50   - B6 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B6.tif")
51   - B7 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B7.tif")
52   - B8A = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B8A.tif")
53   - B11 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B11.tif")
54   - B12 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B12.tif")
  46 + cloud_reproj = Config(file(config)).Sentinel_2.nuages_reproj
  47 + sat_reproj = Config(file(config)).Sentinel_2.saturation_reproj
  48 + div_reproj = Config(file(config)).Sentinel_2.div_reproj
  49 +
  50 + needReproj = False
  51 + B5 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B5*.tif")
  52 + B6 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B6*.tif")
  53 + B7 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B7*.tif")
  54 + B8A = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B8A*.tif")
  55 + B11 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B11*.tif")
  56 + B12 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B12*.tif")
55 57  
56 58 AllBands = B5+B6+B7+B8A+B11+B12#AllBands to resample
57 59 #Resample
58 60 for band in AllBands:
  61 + x,y = fu.getRasterResolution(band)
59 62 folder = "/".join(band.split("/")[0:len(band.split("/"))-1])
60 63 pathOut = folder
61 64 nameOut = band.split("/")[-1].replace(".tif","_10M.tif")
62 65 if workingDirectory: #HPC
63 66 pathOut = workingDirectory
64 67 cmd = "otbcli_RigidTransformResample -in "+band+" -out "+pathOut+"/"+nameOut+" int16 -transform.type.id.scalex 2 -transform.type.id.scaley 2 -interpolator bco -interpolator.bco.radius 2"
65   - if not os.path.exists(folder+"/"+nameOut):
  68 + if str(x)!=str(outRes):needReproj = True
  69 + if str(x)!=str(outRes) and not os.path.exists(folder+"/"+nameOut) and not "10M_10M.tif" in nameOut:
66 70 print cmd
67 71 os.system(cmd)
68 72 if workingDirectory: #HPC
69 73 shutil.copy(pathOut+"/"+nameOut,folder+"/"+nameOut)
70   - """
  74 + os.remove(pathOut+"/"+nameOut)
  75 +
71 76 #Datas reprojection and buid stack
72 77 dates = os.listdir(tileFolder)
73 78 for date in dates:
  79 + print date
  80 + #Masks reprojection
  81 +
  82 + AllCloud = fu.FileSearch_AND(tileFolder+"/"+date,True,cloud)
  83 + AllSat = fu.FileSearch_AND(tileFolder+"/"+date,True,sat)
  84 + AllDiv = fu.FileSearch_AND(tileFolder+"/"+date,True,div)
  85 +
  86 + for Ccloud,Csat,Cdiv in zip(AllCloud,AllSat,AllDiv):
  87 + cloudProj = fu.getRasterProjectionEPSG(Ccloud)
  88 + satProj = fu.getRasterProjectionEPSG(Csat)
  89 + divProj = fu.getRasterProjectionEPSG(Cdiv)
  90 + if cloudProj != int(projOut):
  91 + outFolder = os.path.split(Ccloud)[0]
  92 + cloudOut = os.path.split(Ccloud)[1].replace(".tif","_reproj.tif")
  93 + tmpInfo = outFolder+"/ImgInfo.txt"
  94 + spx,spy = fu.getRasterResolution(Ccloud)
  95 + cmd = 'gdalwarp -wo INIT_DEST=0 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Ccloud+' '+workingDirectory+"/"+cloudOut
  96 + if not os.path.exists(outFolder+"/"+cloudOut):
  97 + print cmd
  98 + os.system(cmd)
  99 + print outFolder+"/"+cloudOut
  100 + shutil.copy(workingDirectory+"/"+cloudOut,outFolder+"/"+cloudOut)
  101 +
  102 + if satProj != int(projOut):
  103 + outFolder = os.path.split(Csat)[0]
  104 + satOut = os.path.split(Csat)[1].replace(".tif","_reproj.tif")
  105 + tmpInfo = outFolder+"/ImgInfo.txt"
  106 + spx,spy = fu.getRasterResolution(Csat)
  107 + cmd = 'gdalwarp -wo INIT_DEST=0 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Csat+' '+workingDirectory+"/"+satOut
  108 + if not os.path.exists(outFolder+"/"+satOut):
  109 + print cmd
  110 + os.system(cmd)
  111 + shutil.copy(workingDirectory+"/"+satOut,outFolder+"/"+satOut)
  112 +
  113 + if divProj != int(projOut):
  114 + outFolder = os.path.split(Cdiv)[0]
  115 + tmpInfo = outFolder+"/ImgInfo.txt"
  116 + divOut = os.path.split(Cdiv)[1].replace(".tif","_reproj.tif")
  117 +
  118 + reverse = workingDirectory+"/"+divOut.replace(".tif","_reverse.tif")
  119 + spx,spy = fu.getRasterResolution(Cdiv)
  120 +
  121 + if not os.path.exists(outFolder+"/"+divOut):
  122 + #cmd = 'otbcli_BandMath -il '+Cdiv+' -out '+reverse+' -exp "im1b1==0?1:0"'
  123 + #print cmd
  124 + #os.system(cmd)
  125 +
  126 + cmd = 'gdalwarp -wo INIT_DEST=1 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Cdiv+' '+workingDirectory+"/"+divOut
  127 + print cmd
  128 + os.system(cmd)
  129 + shutil.copy(workingDirectory+"/"+divOut,outFolder+"/"+divOut)
74 130  
  131 +
  132 + ####################################
  133 +
75 134 B2 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B2*.tif")[0]
76 135 B3 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B3*.tif")[0]
77 136 B4 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B4*.tif")[0]
... ... @@ -82,37 +141,51 @@ def PreProcessS2(config,tileFolder,workingDirectory):
82 141 B8A = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8A_*.tif")[0]
83 142 B11 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B11_*.tif")[0]
84 143 B12 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B12_*.tif")[0]
  144 +
  145 + if needReproj:
  146 + B5 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B5*_10M.tif")[0]
  147 + B6 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B6*_10M.tif")[0]
  148 + B7 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B7*_10M.tif")[0]
  149 + B8 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8.tif")[0]
  150 + B8A = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8A*_10M.tif")[0]
  151 + B11 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B11*_10M.tif")[0]
  152 + B12 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B12*_10M.tif")[0]
85 153 listBands = B2+" "+B3+" "+B4+" "+B5+" "+B6+" "+B7+" "+B8+" "+B8A+" "+B11+" "+B12
86   -
  154 + #listBands = B3+" "+B4+" "+B8
  155 + print listBands
87 156 currentProj = fu.getRasterProjectionEPSG(B3)
88 157 stackName = "_".join(B3.split("/")[-1].split("_")[0:7])+"_STACK.tif"
89 158 stackNameProjIN = "_".join(B3.split("/")[-1].split("_")[0:7])+"_STACK_EPSG"+str(currentProj)+".tif"
90 159 if os.path.exists(tileFolder+"/"+date+"/"+stackName):
91 160 stackProj = fu.getRasterProjectionEPSG(tileFolder+"/"+date+"/"+stackName)
92 161 if int(stackProj) != int(projOut):
  162 + print "stack proj : "+str(stackProj)+" outproj : "+str(projOut)
93 163 tmpInfo = tileFolder+"/"+date+"/ImgInfo.txt"
94 164 spx,spy = fu.getGroundSpacing(tileFolder+"/"+date+"/"+stackName,tmpInfo)
95   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(stackProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+tileFolder+"/"+date+"/"+stackName+' '+workingDirectory+"/"+stackName
  165 + cmd = 'gdalwarp -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(stackProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+tileFolder+"/"+date+"/"+stackName+' '+workingDirectory+"/"+stackName
96 166 print cmd
97   - os.remove(tileFolder+"/"+date+"/"+stackName)
98 167 os.system(cmd)
99   - if workingDirectory : shutil.copy(workingDirectory+"/"+stackName,tileFolder+"/"+date+"/"+stackName)
  168 + os.remove(tileFolder+"/"+date+"/"+stackName)
  169 + shutil.copy(workingDirectory+"/"+stackName,tileFolder+"/"+date+"/"+stackName)
  170 + os.remove(workingDirectory+"/"+stackName)
100 171 else:
101   - cmd = "otbcli_ConcatenateImages -il "+listBands+" -out "+workingDirectory+"/"+stackNameProjIN
  172 +
  173 + cmd = "otbcli_ConcatenateImages -il "+listBands+" -out "+workingDirectory+"/"+stackNameProjIN+" int16"
102 174 print cmd
103 175 os.system(cmd)
104 176 currentProj = fu.getRasterProjectionEPSG(workingDirectory+"/"+stackNameProjIN)
105 177 tmpInfo = workingDirectory+"/ImgInfo.txt"
106   - spx,spy = fu.getGroundSpacing(workingDirectory+"/"+stackNameProjIN,tmpInfo)
  178 + spx,spy = fu.getRasterResolution(workingDirectory+"/"+stackNameProjIN)
107 179 if str(currentProj) == str(projOut):
108   - shutil.copy(workingDirectory+"/"+stackNameProjIN,tileFolder+"/"+date+"/"+stackName)
  180 + shutil.copy(workingDirectory+"/"+stackNameProjIN,tileFolder+"/"+date+"/"+stackName)
109 181 os.remove(workingDirectory+"/"+stackNameProjIN)
110   - else:
111   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(currentProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+workingDirectory+"/"+stackNameProjIN+' '+workingDirectory+"/"+stackName
112   - print cmd
113   - os.system(cmd)
114   -
115   - if workingDirectory : shutil.copy(workingDirectory+"/"+stackName,tileFolder+"/"+date+"/"+stackName)
  182 + else :
  183 + cmd = 'gdalwarp -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(currentProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+workingDirectory+"/"+stackNameProjIN+' '+workingDirectory+"/"+stackName
  184 + print cmd
  185 + os.system(cmd)
  186 + shutil.copy(workingDirectory+"/"+stackName,tileFolder+"/"+date+"/"+stackName)
  187 +
  188 + #######################
116 189  
117 190 if len(sys.argv) == 1:
118 191 prog = os.path.basename(sys.argv[0])
... ...
scripts/common/Sensors.py
... ... @@ -398,13 +398,14 @@ class Sentinel_2(Sensor):
398 398 self.proj = conf2.proj
399 399  
400 400 #MASK INFO
401   - #self.nuages = conf.nuages_reproj
402   - #self.saturation = conf.saturation_reproj
403   - #self.div = conf.div_reproj
404 401 self.nuages = conf.nuages
405 402 self.saturation = conf.saturation
406 403 self.div = conf.div
407 404  
  405 + if conf.nuages_reproj : self.nuages = conf.nuages_reproj
  406 + if conf.saturation_reproj : self.saturation = conf.saturation_reproj
  407 + if conf.div_reproj : self.div = conf.div_reproj
  408 +
408 409 self.nodata = conf.nodata
409 410 self.pathmask = self.path+conf.arbomask
410 411 if conf.nodata_Mask == 'False':
... ...
scripts/common/bPy_ImageClassifier.py
... ... @@ -27,7 +27,8 @@ def launchClassification(tempFolderSerie,Classifmask,model,stats,outputClassif,c
27 27 featuresPath = Config(file(pathConf)).chain.featuresPath
28 28 outputPath = Config(file(pathConf)).chain.outputPath
29 29 tile = outputClassif.split("/")[-1].split("_")[1]
30   -
  30 + userFeatPath = Config(file(pathConf)).chain.userFeatPath
  31 + if userFeatPath == "None" : userFeatPath = None
31 32 AllRefl = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"REFL.tif"))
32 33 AllMask = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"MASK.tif"))
33 34 datesInterp = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"DatesInterp"))
... ... @@ -88,15 +89,37 @@ def launchClassification(tempFolderSerie,Classifmask,model,stats,outputClassif,c
88 89 classifier.SetParameterString("ram","512")
89 90 print "AllRefl"
90 91 print AllRefl
91   - if len(AllRefl) >1:
  92 + #if len(AllRefl) >1:
  93 + # concatSensors.Execute()
  94 + # classifier.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
  95 + #else:
  96 + # classifier.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
  97 + #classifier.ExecuteAndWriteOutput()
  98 + if len(AllRefl) > 1:
92 99 concatSensors.Execute()
93   - classifier.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
94   - else:
95   - classifier.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
  100 + allFeatures = concatSensors.GetParameterOutputImage("out")
  101 + else : allFeatures = features[0].GetParameterOutputImage("out")
  102 +
  103 + if userFeatPath :
  104 + print "Add user features"
  105 + userFeat_arbo = Config(file(pathConf)).userFeat.arbo
  106 + userFeat_pattern = (Config(file(pathConf)).userFeat.patterns).split(",")
  107 + concatFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  108 + userFeatures = fu.getUserFeatInTile(userFeatPath,tile,userFeat_arbo,userFeat_pattern)
  109 + concatFeatures.SetParameterStringList("il",userFeatures)
  110 + concatFeatures.Execute()
  111 +
  112 + concatAllFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  113 + concatAllFeatures.AddImageToParameterInputImageList("il",allFeatures)
  114 + concatAllFeatures.AddImageToParameterInputImageList("il",concatFeatures.GetParameterOutputImage("out"))
  115 + concatAllFeatures.Execute()
  116 +
  117 + allFeatures = concatAllFeatures.GetParameterOutputImage("out")
96 118  
97   - classifier.ExecuteAndWriteOutput()
  119 + classifier.SetParameterInputImage("in",allFeatures)
  120 + classifier.ExecuteAndWriteOutput()
98 121  
99   - expr = "im2b1==1?im1b1:0"
  122 + expr = "im2b1>=1?im1b1:0"
100 123 cmd = 'otbcli_BandMath -il '+outputClassif+' '+Classifmask+' -out '+outputClassif.replace("_TMP.tif",".tif")+' -exp "'+expr+'"'
101 124 print cmd
102 125 os.system(cmd)
... ...
scripts/common/fileUtils.py
... ... @@ -71,7 +71,7 @@ def getUserFeatInTile(userFeat_path,tile,userFeat_arbo,userFeat_pattern):
71 71 allFeat+=fileSearchRegEx(userFeat_path+"/"+tile+"/"+userFeat_arbo+currentPattern+"*")
72 72 return allFeat
73 73  
74   -def getFieldElement(shape,driverName="ESRI Shapefile",field = "CODE",mode = "all"):
  74 +def getFieldElement(shape,driverName="ESRI Shapefile",field = "CODE",mode = "all",elemType = "int"):
75 75 """
76 76 IN :
77 77 shape [string] : shape to compute
... ... @@ -87,11 +87,16 @@ def getFieldElement(shape,driverName="ESRI Shapefile",field = "CODE",mode = "all
87 87 getFieldElement("./MyShape.sqlite","SQLite","CODE",mode = "unique")
88 88 >> [1,2,3,4]
89 89 """
  90 + def getElem(elem,elemType):
  91 + if elemType == "int" : return int(elem)
  92 + elif elemType == "str" : return str(elem)
  93 + else:
  94 + raise Exception("elemType must be 'int' or 'str'")
90 95 driver = ogr.GetDriverByName(driverName)
91 96 dataSource = driver.Open(shape, 0)
92 97 layer = dataSource.GetLayer()
93   - if mode == "all" : return [ currentFeat.GetField(field) for currentFeat in layer]
94   - elif mode == "unique" : return list(set([currentFeat.GetField(field) for currentFeat in layer]))
  98 + if mode == "all" : return [ getElem(currentFeat.GetField(field),elemType) for currentFeat in layer]
  99 + elif mode == "unique" : return list(set([ getElem(currentFeat.GetField(field),elemType) for currentFeat in layer]))
95 100 else:
96 101 raise Exception("mode parameter must be 'all' or 'unique'")
97 102  
... ...
scripts/common/genAnnualSamples.py
... ... @@ -129,7 +129,8 @@ def genAnnualShapePoints(coord,gdalDriver,workingDirectory,rasterResolution,clas
129 129 for y,x in zip(Y,X):
130 130 X_c,Y_c = pixCoordinates(x,y,x_origin,y_origin,sizeX,sizeY)
131 131 XYcoordinates.append((X_c,Y_c))
132   - for Xc,Yc in random.sample(XYcoordinates,nbSamples):
  132 + if nbSamples>len(XYcoordinates):nbSamples=len(XYcoordinates)
  133 + for Xc,Yc in random.sample(XYcoordinates,nbSamples):#"0" for nbSamples allready manage ?
133 134 if coord and not (Xc,Yc) in coord:
134 135 feature = ogr.Feature(layerOUT.GetLayerDefn())
135 136 feature.SetField(dataField, int(currentVal))
... ...
scripts/common/genCmdFeatures.py
... ... @@ -51,6 +51,7 @@ def getDateS2(pathS2,tiles):
51 51 Get the min and max dates for the given tile.
52 52 """
53 53 datePos = 2
  54 + if "T" in tiles[0]:datePos = 1
54 55 dateMin = 30000000000
55 56 dateMax = 0 #JC
56 57 for tile in tiles:
... ...
scripts/common/genJobVectorSampler.py
... ... @@ -37,7 +37,7 @@ def genJob(jobPath,testPath,logPath,pathConf):
37 37 #PBS -J 0-%s:1\n\
38 38 #PBS -l select=1:ncpus=5:mem=10000mb\n\
39 39 #PBS -m be\n\
40   -#PBS -l walltime=10:00:00\n\
  40 +#PBS -l walltime=40:00:00\n\
41 41 \n\
42 42 \n\
43 43 module load python/2.7.5\n\
... ...
scripts/common/processingFeat_hpc.py
... ... @@ -37,17 +37,18 @@ def PreProcessS2(config,tileFolder,workingDirectory):
37 37 cfg = Config(args.config)
38 38 struct = cfg.Sentinel_2.arbo
39 39 outputPath = Config(file(config)).chain.outputPath
  40 + outRes = Config(file(config)).chain.spatialResolution
40 41 projOut = Config(file(config)).GlobChain.proj
41 42 projOut = projOut.split(":")[-1]
42 43 arbomask = Config(file(config)).Sentinel_2.arbomask
43 44 cloud = Config(file(config)).Sentinel_2.nuages
44 45 sat = Config(file(config)).Sentinel_2.saturation
45 46 div = Config(file(config)).Sentinel_2.div
46   - #cloud_reproj = Config(file(config)).Sentinel_2.nuages_reproj
47   - #sat_reproj = Config(file(config)).Sentinel_2.saturation_reproj
48   - #div_reproj = Config(file(config)).Sentinel_2.div_reproj
  47 + cloud_reproj = Config(file(config)).Sentinel_2.nuages_reproj
  48 + sat_reproj = Config(file(config)).Sentinel_2.saturation_reproj
  49 + div_reproj = Config(file(config)).Sentinel_2.div_reproj
49 50  
50   - """
  51 + needReproj = False
51 52 B5 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B5*.tif")
52 53 B6 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B6*.tif")
53 54 B7 = fu.fileSearchRegEx(tileFolder+"/"+struct+"/*FRE_B7*.tif")
... ... @@ -58,25 +59,27 @@ def PreProcessS2(config,tileFolder,workingDirectory):
58 59 AllBands = B5+B6+B7+B8A+B11+B12#AllBands to resample
59 60 #Resample
60 61 for band in AllBands:
  62 + x,y = fu.getRasterResolution(band)
61 63 folder = "/".join(band.split("/")[0:len(band.split("/"))-1])
62 64 pathOut = folder
63 65 nameOut = band.split("/")[-1].replace(".tif","_10M.tif")
64 66 if workingDirectory: #HPC
65 67 pathOut = workingDirectory
66 68 cmd = "otbcli_RigidTransformResample -in "+band+" -out "+pathOut+"/"+nameOut+" int16 -transform.type.id.scalex 2 -transform.type.id.scaley 2 -interpolator bco -interpolator.bco.radius 2"
67   - if not os.path.exists(folder+"/"+nameOut) and not "10M_10M.tif" in nameOut:
  69 + if str(x)!=str(outRes):needReproj = True
  70 + if str(x)!=str(outRes) and not os.path.exists(folder+"/"+nameOut) and not "10M_10M.tif" in nameOut:
68 71 print cmd
69 72 os.system(cmd)
70 73 if workingDirectory: #HPC
71 74 shutil.copy(pathOut+"/"+nameOut,folder+"/"+nameOut)
72 75 os.remove(pathOut+"/"+nameOut)
73   - """
  76 +
74 77 #Datas reprojection and buid stack
75 78 dates = os.listdir(tileFolder)
76 79 for date in dates:
77 80 print date
78 81 #Masks reprojection
79   - """
  82 +
80 83 AllCloud = fu.FileSearch_AND(tileFolder+"/"+date,True,cloud)
81 84 AllSat = fu.FileSearch_AND(tileFolder+"/"+date,True,sat)
82 85 AllDiv = fu.FileSearch_AND(tileFolder+"/"+date,True,div)
... ... @@ -87,10 +90,10 @@ def PreProcessS2(config,tileFolder,workingDirectory):
87 90 divProj = fu.getRasterProjectionEPSG(Cdiv)
88 91 if cloudProj != int(projOut):
89 92 outFolder = os.path.split(Ccloud)[0]
90   - cloudOut = os.path.split(Ccloud)[1].replace(cloud,cloud_reproj)
  93 + cloudOut = os.path.split(Ccloud)[1].replace(".tif","_reproj.tif")
91 94 tmpInfo = outFolder+"/ImgInfo.txt"
92   - spx,spy = fu.getGroundSpacing(Ccloud,tmpInfo)
93   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Ccloud+' '+workingDirectory+"/"+cloudOut
  95 + spx,spy = fu.getRasterResolution(Ccloud)
  96 + cmd = 'gdalwarp -wo INIT_DEST=0 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Ccloud+' '+workingDirectory+"/"+cloudOut
94 97 if not os.path.exists(outFolder+"/"+cloudOut):
95 98 print cmd
96 99 os.system(cmd)
... ... @@ -99,10 +102,10 @@ def PreProcessS2(config,tileFolder,workingDirectory):
99 102  
100 103 if satProj != int(projOut):
101 104 outFolder = os.path.split(Csat)[0]
102   - satOut = os.path.split(Csat)[1].replace(sat,sat_reproj)
  105 + satOut = os.path.split(Csat)[1].replace(".tif","_reproj.tif")
103 106 tmpInfo = outFolder+"/ImgInfo.txt"
104   - spx,spy = fu.getGroundSpacing(Csat,tmpInfo)
105   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Csat+' '+workingDirectory+"/"+satOut
  107 + spx,spy = fu.getRasterResolution(Csat)
  108 + cmd = 'gdalwarp -wo INIT_DEST=0 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Csat+' '+workingDirectory+"/"+satOut
106 109 if not os.path.exists(outFolder+"/"+satOut):
107 110 print cmd
108 111 os.system(cmd)
... ... @@ -111,23 +114,24 @@ def PreProcessS2(config,tileFolder,workingDirectory):
111 114 if divProj != int(projOut):
112 115 outFolder = os.path.split(Cdiv)[0]
113 116 tmpInfo = outFolder+"/ImgInfo.txt"
114   - divOut = os.path.split(Cdiv)[1].replace(div,div_reproj)
  117 + divOut = os.path.split(Cdiv)[1].replace(".tif","_reproj.tif")
115 118  
116 119 reverse = workingDirectory+"/"+divOut.replace(".tif","_reverse.tif")
117   - spx,spy = fu.getGroundSpacing(Cdiv,tmpInfo)
  120 + spx,spy = fu.getRasterResolution(Cdiv)
118 121  
119 122 if not os.path.exists(outFolder+"/"+divOut):
120   - cmd = 'otbcli_BandMath -il '+Cdiv+' -out '+reverse+' -exp "im1b1==0?1:0"'
121   - print cmd
122   - os.system(cmd)
  123 + #cmd = 'otbcli_BandMath -il '+Cdiv+' -out '+reverse+' -exp "im1b1==0?1:0"'
  124 + #print cmd
  125 + #os.system(cmd)
123 126  
124   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+reverse+' '+workingDirectory+"/"+divOut
  127 + cmd = 'gdalwarp -wo INIT_DEST=1 -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(cloudProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+Cdiv+' '+workingDirectory+"/"+divOut
125 128 print cmd
126 129 os.system(cmd)
127 130 shutil.copy(workingDirectory+"/"+divOut,outFolder+"/"+divOut)
128   - """
  131 +
129 132  
130 133 ####################################
  134 + print tileFolder+"/"+date+"/*FRE_B2*.tif"
131 135 B2 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B2*.tif")[0]
132 136 B3 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B3*.tif")[0]
133 137 B4 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B4*.tif")[0]
... ... @@ -138,6 +142,15 @@ def PreProcessS2(config,tileFolder,workingDirectory):
138 142 B8A = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8A_*.tif")[0]
139 143 B11 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B11_*.tif")[0]
140 144 B12 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B12_*.tif")[0]
  145 +
  146 + if needReproj:
  147 + B5 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B5*_10M.tif")[0]
  148 + B6 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B6*_10M.tif")[0]
  149 + B7 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B7*_10M.tif")[0]
  150 + B8 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8.tif")[0]
  151 + B8A = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B8A*_10M.tif")[0]
  152 + B11 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B11*_10M.tif")[0]
  153 + B12 = fu.fileSearchRegEx(tileFolder+"/"+date+"/*FRE_B12*_10M.tif")[0]
141 154 listBands = B2+" "+B3+" "+B4+" "+B5+" "+B6+" "+B7+" "+B8+" "+B8A+" "+B11+" "+B12
142 155 #listBands = B3+" "+B4+" "+B8
143 156 print listBands
... ... @@ -150,7 +163,7 @@ def PreProcessS2(config,tileFolder,workingDirectory):
150 163 print "stack proj : "+str(stackProj)+" outproj : "+str(projOut)
151 164 tmpInfo = tileFolder+"/"+date+"/ImgInfo.txt"
152 165 spx,spy = fu.getGroundSpacing(tileFolder+"/"+date+"/"+stackName,tmpInfo)
153   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(stackProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+tileFolder+"/"+date+"/"+stackName+' '+workingDirectory+"/"+stackName
  166 + cmd = 'gdalwarp -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(stackProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+tileFolder+"/"+date+"/"+stackName+' '+workingDirectory+"/"+stackName
154 167 print cmd
155 168 os.system(cmd)
156 169 os.remove(tileFolder+"/"+date+"/"+stackName)
... ... @@ -163,12 +176,12 @@ def PreProcessS2(config,tileFolder,workingDirectory):
163 176 os.system(cmd)
164 177 currentProj = fu.getRasterProjectionEPSG(workingDirectory+"/"+stackNameProjIN)
165 178 tmpInfo = workingDirectory+"/ImgInfo.txt"
166   - spx,spy = fu.getGroundSpacing(workingDirectory+"/"+stackNameProjIN,tmpInfo)
  179 + spx,spy = fu.getRasterResolution(workingDirectory+"/"+stackNameProjIN)
167 180 if str(currentProj) == str(projOut):
168 181 shutil.copy(workingDirectory+"/"+stackNameProjIN,tileFolder+"/"+date+"/"+stackName)
169 182 os.remove(workingDirectory+"/"+stackNameProjIN)
170 183 else :
171   - cmd = 'gdalwarp -tr '+spx+' '+spx+' -s_srs "EPSG:'+str(currentProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+workingDirectory+"/"+stackNameProjIN+' '+workingDirectory+"/"+stackName
  184 + cmd = 'gdalwarp -tr '+str(spx)+' '+str(spx)+' -s_srs "EPSG:'+str(currentProj)+'" -t_srs "EPSG:'+str(projOut)+'" '+workingDirectory+"/"+stackNameProjIN+' '+workingDirectory+"/"+stackName
172 185 print cmd
173 186 os.system(cmd)
174 187 shutil.copy(workingDirectory+"/"+stackName,tileFolder+"/"+date+"/"+stackName)
... ...
scripts/common/vectorSampler.py
... ... @@ -264,7 +264,8 @@ def generateSamples_simple(folderSample,workingDirectory,trainShape,pathWd,featu
264 264 print cmd
265 265 os.system(cmd)
266 266 if pathWd:shutil.copy(samples,folderSample+"/"+trainShape.split("/")[-1].replace(".shp","_Samples.sqlite"))
267   -
  267 + os.remove(sampleSelection)
  268 + os.remove(stats)
268 269  
269 270 def generateSamples_cropMix(folderSample,workingDirectory,trainShape,pathWd,featuresPath,samplesOptions,prevFeatures,annualCrop,AllClass,dataField,pathConf):
270 271  
... ... @@ -272,12 +273,15 @@ def generateSamples_cropMix(folderSample,workingDirectory,trainShape,pathWd,feat
272 273 bindingPy = Config(file(pathConf)).GlobChain.bindingPython
273 274 samplesClassifMix = Config(file(pathConf)).argTrain.samplesClassifMix
274 275  
  276 + userFeatPath = Config(file(pathConf)).chain.userFeatPath
  277 + if userFeatPath == "None" : userFeatPath = None
  278 +
275 279 stack = "/Final/"+fu.getFeatStackName(pathConf)
276 280 NA_img = featuresPath+"/"+currentTile+"/"+stack
277 281 A_img = prevFeatures+"/"+currentTile+"/"+stack
278 282 if bindingPy == "True":
279   - NA_img = fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"ST_MASK")[0]
280   - A_img = fu.FileSearch_AND(prevFeatures+"/"+tile+"/tmp/",True,"ST_MASK")[0]
  283 + NA_img = fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"ST_MASK")[0]
  284 + A_img = fu.FileSearch_AND(prevFeatures+"/"+currentTile+"/tmp/",True,"ST_MASK")[0]
281 285 #Step 1 : filter trainShape in order to keep non-annual class
282 286 nameNonAnnual = trainShape.split("/")[-1].replace(".shp","_NonAnnu.shp")
283 287 nonAnnualShape = workingDirectory+"/"+nameNonAnnual
... ... @@ -332,10 +336,10 @@ def generateSamples_cropMix(folderSample,workingDirectory,trainShape,pathWd,feat
332 336 else:
333 337 #Step 7 : Sample extraction NonAnnual
334 338 concatSensors= otb.Registry.CreateApplication("ConcatenateImages")
335   - AllRefl = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"REFL.tif"))
336   - AllMask = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"MASK.tif"))
337   - datesInterp = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"DatesInterp"))
338   - realDates = sorted(fu.FileSearch_AND(featuresPath+"/"+tile+"/tmp/",True,"imagesDate"))
  339 + AllRefl = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"REFL.tif"))
  340 + AllMask = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"MASK.tif"))
  341 + datesInterp = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"DatesInterp"))
  342 + realDates = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"imagesDate"))
339 343 features = []
340 344 for refl,mask,datesInterp,realDates in zip(AllRefl,AllMask,datesInterp,realDates):
341 345 gapFill = otb.Registry.CreateApplication("ImageTimeSeriesGapFilling")
... ... @@ -360,19 +364,42 @@ def generateSamples_cropMix(folderSample,workingDirectory,trainShape,pathWd,feat
360 364 sampleExtr.SetParameterString("vec",SampleSel_NA)
361 365 sampleExtr.SetParameterString("field",dataField)
362 366 sampleExtr.SetParameterString("out",SampleExtr_NA)
  367 + #if len(AllRefl) > 1:
  368 + # concatSensors.Execute()
  369 + # sampleExtr.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
  370 + #else:
  371 + # sampleExtr.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
  372 + #sampleExtr.ExecuteAndWriteOutput()
363 373 if len(AllRefl) > 1:
364   - concatSensors.Execute()
365   - sampleExtr.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
366   - else:
367   - sampleExtr.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
368   - sampleExtr.ExecuteAndWriteOutput()
  374 + concatSensors.Execute()
  375 + allFeatures = concatSensors.GetParameterOutputImage("out")
  376 + else : allFeatures = features[0].GetParameterOutputImage("out")
  377 +
  378 + if userFeatPath :
  379 + print "Add user features"
  380 + userFeat_arbo = Config(file(pathConf)).userFeat.arbo
  381 + userFeat_pattern = (Config(file(pathConf)).userFeat.patterns).split(",")
  382 + concatFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  383 + userFeatures = fu.getUserFeatInTile(userFeatPath,currentTile,userFeat_arbo,userFeat_pattern)
  384 + concatFeatures.SetParameterStringList("il",userFeatures)
  385 + concatFeatures.Execute()
  386 +
  387 + concatAllFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  388 + concatAllFeatures.AddImageToParameterInputImageList("il",allFeatures)
  389 + concatAllFeatures.AddImageToParameterInputImageList("il",concatFeatures.GetParameterOutputImage("out"))
  390 + concatAllFeatures.Execute()
  391 +
  392 + allFeatures = concatAllFeatures.GetParameterOutputImage("out")
  393 +
  394 + sampleExtr.SetParameterInputImage("in",allFeatures)
  395 + sampleExtr.ExecuteAndWriteOutput()
369 396  
370 397 #Step 8 : Sample extraction Annual
371 398 concatSensors= otb.Registry.CreateApplication("ConcatenateImages")
372   - AllRefl = sorted(fu.FileSearch_AND(prevFeatures+"/"+tile+"/tmp/",True,"REFL.tif"))
373   - AllMask = sorted(fu.FileSearch_AND(prevFeatures+"/"+tile+"/tmp/",True,"MASK.tif"))
374   - datesInterp = sorted(fu.FileSearch_AND(prevFeatures+"/"+tile+"/tmp/",True,"DatesInterp"))
375   - realDates = sorted(fu.FileSearch_AND(prevFeatures+"/"+tile+"/tmp/",True,"imagesDate"))
  399 + AllRefl = sorted(fu.FileSearch_AND(prevFeatures+"/"+currentTile+"/tmp/",True,"REFL.tif"))
  400 + AllMask = sorted(fu.FileSearch_AND(prevFeatures+"/"+currentTile+"/tmp/",True,"MASK.tif"))
  401 + datesInterp = sorted(fu.FileSearch_AND(prevFeatures+"/"+currentTile+"/tmp/",True,"DatesInterp"))
  402 + realDates = sorted(fu.FileSearch_AND(prevFeatures+"/"+currentTile+"/tmp/",True,"imagesDate"))
376 403 features = []
377 404 for refl,mask,datesInterp,realDates in zip(AllRefl,AllMask,datesInterp,realDates):
378 405 gapFill = otb.Registry.CreateApplication("ImageTimeSeriesGapFilling")
... ... @@ -397,11 +424,29 @@ def generateSamples_cropMix(folderSample,workingDirectory,trainShape,pathWd,feat
397 424 sampleExtr.SetParameterString("vec",SampleSel_A)
398 425 sampleExtr.SetParameterString("field",dataField)
399 426 sampleExtr.SetParameterString("out",SampleExtr_A)
  427 +
400 428 if len(AllRefl) > 1:
401   - concatSensors.Execute()
402   - sampleExtr.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
403   - else:
404   - sampleExtr.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
  429 + concatSensors.Execute()
  430 + allFeatures = concatSensors.GetParameterOutputImage("out")
  431 + else : allFeatures = features[0].GetParameterOutputImage("out")
  432 +
  433 + if userFeatPath :
  434 + print "Add user features"
  435 + userFeat_arbo = Config(file(pathConf)).userFeat.arbo
  436 + userFeat_pattern = (Config(file(pathConf)).userFeat.patterns).split(",")
  437 + concatFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  438 + userFeatures = fu.getUserFeatInTile(userFeatPath,currentTile,userFeat_arbo,userFeat_pattern)
  439 + concatFeatures.SetParameterStringList("il",userFeatures)
  440 + concatFeatures.Execute()
  441 +
  442 + concatAllFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  443 + concatAllFeatures.AddImageToParameterInputImageList("il",allFeatures)
  444 + concatAllFeatures.AddImageToParameterInputImageList("il",concatFeatures.GetParameterOutputImage("out"))
  445 + concatAllFeatures.Execute()
  446 +
  447 + allFeatures = concatAllFeatures.GetParameterOutputImage("out")
  448 +
  449 + sampleExtr.SetParameterInputImage("in",allFeatures)
405 450 if annualCropFind:sampleExtr.ExecuteAndWriteOutput()
406 451  
407 452 #Step 9 : Merge
... ... @@ -434,7 +479,9 @@ def generateSamples_classifMix(folderSample,workingDirectory,trainShape,pathWd,f
434 479 previousClassifPath,projOut = Config(file(configPrevClassif)).chain.outputPath,Config(file(configPrevClassif)).GlobChain.proj
435 480 projOut = int(projOut.split(":")[-1])
436 481 stack = "/Final/"+fu.getFeatStackName(pathConf)
437   -
  482 + userFeatPath = Config(file(pathConf)).chain.userFeatPath
  483 + if userFeatPath == "None" : userFeatPath = None
  484 +
438 485 featImg = featuresPath+"/"+currentTile+"/"+stack
439 486 if bindingPy == "True":
440 487 featImg = fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"ST_MASK")[0]
... ... @@ -480,9 +527,11 @@ def generateSamples_classifMix(folderSample,workingDirectory,trainShape,pathWd,f
480 527  
481 528 samples = workingDirectory+"/"+trainShape.split("/")[-1].replace(".shp","_Samples.sqlite")
482 529 if bindingPy == "False":
483   - cmd = "otbcli_SampleExtraction -in "+featImg+" -vec "+sampleSelection+" -field "+dataField+" -out "+samples
484   - print cmd
485   - os.system(cmd)
  530 + folderSample+"/"+trainShape.split("/")[-1].replace(".shp","_Samples.sqlite")
  531 + if not os.path.exists(folderSample+"/"+trainShape.split("/")[-1].replace(".shp","_Samples.sqlite")):
  532 + cmd = "otbcli_SampleExtraction -in "+featImg+" -vec "+sampleSelection+" -field "+dataField+" -out "+samples
  533 + print cmd
  534 + os.system(cmd)
486 535 else:
487 536 AllRefl = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"REFL.tif"))
488 537 AllMask = sorted(fu.FileSearch_AND(featuresPath+"/"+currentTile+"/tmp/",True,"MASK.tif"))
... ... @@ -520,14 +569,40 @@ def generateSamples_classifMix(folderSample,workingDirectory,trainShape,pathWd,f
520 569 sampleExtr.SetParameterString("vec",sampleSelection)
521 570 sampleExtr.SetParameterString("field",dataField)
522 571 sampleExtr.SetParameterString("out",samples)
523   - if len(AllRefl) > 1:
524   - concatSensors.Execute()
525   - sampleExtr.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
526   - else:
527   - sampleExtr.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
528   - sampleExtr.ExecuteAndWriteOutput()
  572 + #if len(AllRefl) > 1:
  573 + # concatSensors.Execute()
  574 + # sampleExtr.SetParameterInputImage("in",concatSensors.GetParameterOutputImage("out"))
  575 + #else:
  576 + # sampleExtr.SetParameterInputImage("in",features[0].GetParameterOutputImage("out"))
  577 + #sampleExtr.ExecuteAndWriteOutput()
  578 +
  579 + if len(AllRefl) > 1:
  580 + concatSensors.Execute()
  581 + allFeatures = concatSensors.GetParameterOutputImage("out")
  582 + else : allFeatures = features[0].GetParameterOutputImage("out")
  583 +
  584 + if userFeatPath :
  585 + print "Add user features"
  586 + userFeat_arbo = Config(file(pathConf)).userFeat.arbo
  587 + userFeat_pattern = (Config(file(pathConf)).userFeat.patterns).split(",")
  588 + concatFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  589 + userFeatures = fu.getUserFeatInTile(userFeatPath,currentTile,userFeat_arbo,userFeat_pattern)
  590 + concatFeatures.SetParameterStringList("il",userFeatures)
  591 + concatFeatures.Execute()
  592 +
  593 + concatAllFeatures = otb.Registry.CreateApplication("ConcatenateImages")
  594 + concatAllFeatures.AddImageToParameterInputImageList("il",allFeatures)
  595 + concatAllFeatures.AddImageToParameterInputImageList("il",concatFeatures.GetParameterOutputImage("out"))
  596 + concatAllFeatures.Execute()
  597 +
  598 + allFeatures = concatAllFeatures.GetParameterOutputImage("out")
  599 +
  600 + sampleExtr.SetParameterInputImage("in",allFeatures)
  601 + sampleExtr.ExecuteAndWriteOutput()
529 602 if pathWd:shutil.copy(samples,folderSample+"/"+trainShape.split("/")[-1].replace(".shp","_Samples.sqlite"))
530   -
  603 + os.remove(SampleSel_NA)
  604 + os.remove(sampleSelection)
  605 + os.remove(stats_NA)
531 606 def generateSamples(trainShape,pathWd,pathConf):
532 607  
533 608 TestPath = Config(file(pathConf)).chain.outputPath
... ... @@ -539,7 +614,7 @@ def generateSamples(trainShape,pathWd,pathConf):
539 614  
540 615 prevFeatures = Config(file(pathConf)).argTrain.prevFeatures
541 616 annualCrop = Config(file(pathConf)).argTrain.annualCrop
542   - AllClass = fu.getFieldElement(trainShape,"ESRI Shapefile",dataField,mode = "unique")
  617 + AllClass = fu.getFieldElement(trainShape,"ESRI Shapefile",dataField,mode = "unique",elemType = "str")
543 618 for CurrentClass in annualCrop:
544 619 try:
545 620 AllClass.remove(str(CurrentClass))
... ...