def createCSVFromGEOJSON(rasterList, geoJsonList, outputCSVFileName): chipSummaryList = [] #AOI_2_RIO_3Band_img997.tif #AOI_2_RIO_img635.geojson if len(rasterList) != len(geoJsonList): print 'the count the raster is not equal to geojson' return False # find RasterPrecursor # rasterList = glob.glob(os.path.join(rasterDirectory, '*.tif')) # rasterPrefix = os.path.basename(rasterList[0]) # rasterPrefix = rasterPrefix.split("_")[0] # geoJsonList = glob.glob(os.path.join(geoJsonDirectory, '*.geojson')) for i in range(0, len(rasterList)): image_path = rasterList[i] geojson_path = geoJsonList[i] rasterName = os.path.basename(image_path) imageId = os.path.splitext(rasterName)[0] # for stripItem in stripList: # rasterName = rasterName.replace(stripItem, '') # if args.DontstripFirstUnderScore: # rasterName = rasterPrefix+"_"+rasterName.split('_',1)[1] # else: # rasterName = rasterPrefix+"_"+rasterName print(imageId) # print(os.path.join(rasterDirectory,rasterName)) # chipSummary = {'chipName': os.path.join(rasterDirectory, rasterName), # 'geoVectorName': os.path.join(geoJsonDirectory, imageId), # 'imageId': os.path.splitext(imageId)[0]} chipSummary = { 'chipName': image_path, 'geoVectorName': geojson_path, 'imageId': imageId } chipSummaryList.append(chipSummary) print("starting") lT.createCSVSummaryFile( chipSummaryList, outputCSVFileName, replaceImageID="", createProposalsFile=True, # True will output the confidence pixPrecision=2) print("finished") return True
rasterPrefix = os.path.basename(rasterList[0]) rasterPrefix = rasterPrefix.split("_")[0] geoJsonList = glob.glob(os.path.join(geoJsonDirectory, '*.geojson')) for imageId in geoJsonList: imageId = os.path.basename(imageId) rasterName = imageId.replace('.geojson', '.tif') for stripItem in stripList: rasterName = rasterName.replace(stripItem, '') if args.DontstripFirstUnderScore: rasterName = rasterPrefix + "_" + rasterName.split('_', 1)[1] else: rasterName = rasterPrefix + "_" + rasterName print(imageId) print(os.path.join(rasterDirectory, rasterName)) chipSummary = {'chipName': os.path.join(rasterDirectory, rasterName), 'geoVectorName': os.path.join(geoJsonDirectory, imageId), 'imageId': os.path.splitext(imageId)[0]} chipSummaryList.append(chipSummary) print("starting") lT.createCSVSummaryFile(chipSummaryList, outputCSVFileName, replaceImageID=rasterPrefix + "_", createProposalsFile=createProposalFile, pixPrecision=args.pixelPrecision) print("finished")
for chipSummary in splitInformation[1]: for chip in chipSummary['chipName']: shutil.copy( chip[1], os.path.join(outputDir, splitInformation[0], chip[0])) shutil.copy( chipSummary['geoVectorName'], os.path.join(outputDir, splitInformation[0], 'geojson', 'buildings')) rasterPrefix = 'PAN' chipSummaryListTmp = [] for chipSummary in splitInformation[1]: chipSummaryTmp = chipSummary chipSummaryTmp['chipName'] = chipSummary['chipName'][0][1] chipSummaryListTmp.append(chipSummaryTmp) print("starting") outputCSVFileName = os.path.join( outputDir, args.outputCSV + splitInformation[0] + ".csv") lT.createCSVSummaryFile(chipSummaryListTmp, outputCSVFileName, replaceImageID=rasterPrefix + "_", pixPrecision=args.pixelPrecision) print("finished")
mkdir_p(os.path.join(outputDir, splitInformation[0], rastDir[1])) mkdir_p(os.path.join(outputDir, splitInformation[0], 'geojson', 'buildings')) for chipSummary in splitInformation[1]: for chip in chipSummary['chipName']: shutil.copy(chip[1], os.path.join(outputDir, splitInformation[0], chip[0])) shutil.copy(chipSummary['geoVectorName'], os.path.join(outputDir, splitInformation[0], 'geojson', 'buildings')) rasterPrefix = 'PAN' chipSummaryListTmp = [] for chipSummary in splitInformation[1]: chipSummaryTmp = chipSummary chipSummaryTmp['chipName'] = chipSummary['chipName'][0][1] chipSummaryListTmp.append(chipSummaryTmp) print("starting") outputCSVFileName = os.path.join(outputDir, args.outputCSV + splitInformation[0] + ".csv") lT.createCSVSummaryFile(chipSummaryListTmp, outputCSVFileName, replaceImageID=rasterPrefix+"_", pixPrecision=args.pixelPrecision) print("finished")
rasterPrefix = rasterPrefix.split("_")[0] geoJsonList = glob.glob(os.path.join(geoJsonDirectory, '*.geojson')) for imageId in geoJsonList: imageId = os.path.basename(imageId) rasterName = imageId.replace('.geojson','.tif') for stripItem in stripList: rasterName = rasterName.replace(stripItem, '') if args.DontstripFirstUnderScore: rasterName = rasterPrefix+"_"+rasterName.split('_',1)[1] else: rasterName = rasterPrefix+"_"+rasterName print(imageId) print(os.path.join(rasterDirectory,rasterName)) chipSummary = {'chipName': os.path.join(rasterDirectory, rasterName), 'geoVectorName': os.path.join(geoJsonDirectory, imageId), 'imageId': os.path.splitext(imageId)[0]} chipSummaryList.append(chipSummary) print("starting") lT.createCSVSummaryFile(chipSummaryList, outputCSVFileName, replaceImageID=rasterPrefix+"_", createProposalsFile=createProposalFile, pixPrecision=args.pixelPrecision) print("finished")