I'm confused. If you know the file name, why not just substitute the file name for "_stanislaus.img"?import arcpy import sys, os, string from arcpy.sa import * from arcpy import env arcpy.env.workspace = "D:\Project\Stanislaus\Timeseries\NDVI" LstRst = arcpy.ListRasters("*", "img") for Rst in LstRst: Img1 = string.find(Rst, "aug08_2010_stanislaus.img") if Img1 > -1: print Rst Or, are you looking for how to substitute a variable into the file name?import arcpy import sys, os, string from arcpy.sa import * from arcpy import env arcpy.env.workspace = "D:\Project\Stanislaus\Timeseries\NDVI" LstRst = arcpy.ListRasters("*", "img") fileprefix = "aug08_2010" for Rst in LstRst: Img1 = string.find(Rst, fileprefix + "_stanislaus.img") if Img1 > -1: print Rst
import arcpy import sys, os, string from arcpy.sa import * from arcpy import env arcpy.env.workspace = "D:\Project\Stanislaus\Timeseries\NDVI" LstRst = arcpy.ListRasters("*", "img") for Rst in LstRst: Img1 = string.find(Rst, "aug08_2010_stanislaus.img") if Img1 > -1: print Rst
import arcpy import sys, os, string from arcpy.sa import * from arcpy import env arcpy.env.workspace = "D:\Project\Stanislaus\Timeseries\NDVI" LstRst = arcpy.ListRasters("*", "img") fileprefix = "aug08_2010" for Rst in LstRst: Img1 = string.find(Rst, fileprefix + "_stanislaus.img") if Img1 > -1: print Rst
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.