Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- import string
- from math import *
- from arcpy import *
- from arcpy.sa import *
- import os
- from os import listdir
- from os.path import join
- arcpy.CheckOutExtension("spatial")
- BP = "H:\NorthSea\Images4AllDates\BPnoEo\"
- Eo = "C:\Users\robyn\Desktop\NCEPre2\Watts2Eo\"
- output = "C:\Users\robyn\Desktop\FinalPPresults\"
- arcpy.env.cellSize = "MINOF"
- netSW = os.listdir(Eo)
- chlKd = os.listdir(BP)
- for files in netSW and chlKd:
- SW = os.path.join(Eo, files)
- filenameSW = SW[40:48]
- CC = os.path.join(BP, files)
- filenameCC = CC[35:43]
- if files.endswith(".img"):
- if (files in SW[40:48]) == (files in CC[35:43]):
- #or if filenameSW == filenameCC:
- Output = output + files
- BPI = Raster(SW) * Raster(CC)
- BPI.save(Output)
- print Output + " done"
- for files in (netSW and chlKd):
- import arcpy
- import string
- from math import *
- from arcpy import *
- from arcpy.sa import *
- import os
- from os import listdir
- from os.path import join
- import re
- arcpy.CheckOutExtension("spatial")
- arcpy.env.cellSize = "MINOF"
- BP = "H:\NorthSea\Images4AllDates\BPnoEo\"
- Eo = "C:\Users\robyn\Desktop\NCEPre2\Watts2Eo\"
- output = "C:\Users\robyn\Desktop\FinalPPresults\"
- netSW = os.listdir(Eo)
- chlKd = os.listdir(BP)
- netSW_regex = re.compile("([0-9]{8}).img") # matches 20020101_105433.img
- chlKd_regex = re.compile("([0-9]{8})_([0-9]{6}).img") # matches 20020102.img
- for fileSW in netSW:
- for fileCC in chlKd:
- SW = os.path.join(Eo, fileSW)
- CC = os.path.join(BP, fileCC)
- netSW_matcher = netSW_regex.match(fileSW)
- chlKd_matcher = chlKd_regex.match(fileCC)
- if netSW_matcher and chlKd_matcher and netSW_matcher.group(1) == chlKd_matcher.group(1):
- print "Multiplying {} and {}".format(fileSW, fileCC)
- target_path = os.path.join(result, fileSW)
- BPI = Raster(SW) * Raster(CC)
- BPI.save(target_path)
- print "Done {}".format(target_path)
Add Comment
Please, Sign In to add comment