# to make a keyfile # 26 April 2010 kimo # much better than MakeQueryTable and it works across geodatabases # still uses an SQL query but python generates the set for the expression # will work for tens of thousands of keys (amazing) # if you want to save the featureclass or table as a layer or view definition # to use in ArcMap (without making a copy) you MUST have an index on the key field # or it will be extremely slow to draw. # see the Keyfile tool in ArcScripts for an alternative method using selection sets in ArcMap import arcgisscripting,sys,os,datetime,fileinput gp = arcgisscripting.create(9.3) def titlekey(title) : gp.Workspace = ws # Make a title set to use as a keyfile lstTitle = [] cur = gp.SearchCursor(title) row = cur.next() while row : lstTitle.append(row.ttl_title_no) row = cur.next() del row,cur return set(lstTitle) def title_tab(src) : " use setTitle to export records to a table" start = datetime.datetime.now() gp.Workspace = ws setTitle = titlekey(title) expTitle = ",".join(["'"+t+"'" for t in setTitle]) sqlQuery = "ttl_title_no in ("+expTitle+")" gp.MakeTableView_management(src,src+"_view",sqlQuery,wsout) gp.OverwriteOutput = True gp.CopyRows_management(src+"_view",wsout+"/"+src+"_sub") print gp.GetCount(wsout+"/"+src+"_sub").Getoutput(0),"records in "+src+"_sub" print datetime.datetime.now() - start # ------------------------- main ------------------------- title = "e:/arrears.mdb/title" ws = "e:/memo.gdb" wsout = "e:/arrears.mdb" # create subsets based on title keys if not gp.Exists(wsout+"/tta_sub") : title_tab("tta")
myList = ["apple","pear","orange"] for item in myList: # Select item in list based on field COUNTRY. qry = "\"COUNTRY\" = '"+item+"'" gp.Select_analysis(inFile, outDir, qry)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.