|
POST
|
Thanks so much, here's my final script. Please if you wouldn't mind let me know where I should change the structure, layout or add notes to my script to learn to write my scripts correctly. I can't thank you enough for all the assistance that you have provided me today. I now feel that I really can learn how to write custom scripts with a lot more work of course, but I've now at least made a start. import arcpy, os
from arcpy import env
folder = r"S:\Projects\H107039\GIS\ModelBuilder\Geodatabases"
for (path, dirs, files) in os.walk(folder):
if ".gdb" not in path.lower():
env.workspace = path
databases = arcpy.ListWorkspaces("*", "FileGDB")
# Set parameters
DomainTable = arcpy.GetParameterAsText(0)
Code = 'Code'
Description = 'Description'
DomainName = arcpy.GetParameterAsText(1)
DomainDesc = arcpy.GetParameterAsText(2)
Replace = 'Replace'
# Run Tool
for database in databases:
arcpy.TableToDomain_management(DomainTable, Code, Description, database,
DomainName, DomainDesc, Replace) Regards
... View more
10-27-2011
08:20 AM
|
0
|
0
|
2202
|
|
POST
|
I'm trying to add the python script to an ArcToolBox and have adjusted the model to preset certain paramaters as they won't change. My current script is structured as follows: import arcpy, os from arcpy import env folder = r"S:\Projects\H107039\GIS\ModelBuilder\Geodatabases" for (path, dirs, files) in os.walk(folder): if ".gdb" not in path.lower(): env.workspace = path databases = arcpy.ListWorkspaces("*", "FileGDB") Code = 'Code' Description = 'Description' Replace = 'REPLACE' for database in databases: arcpy.TableToDomain_management(r"S:\Projects\H107039\GIS\Domains.gdb\Landuse_Description", Code, Description, database, "Landuse Description", "Aurecon Landuse Description", Replace) The only parameters that need to be defined by the end user are: 1) table containing domain 2) The name to be given to the domain 3) The description of the domain I've set the parameters as follows when adding a script to the toolbox: 1) Table View (Input) 2) String (Input) 3) String (Input) If I run the script within python it adds the additional domain to each file geodatabase. If I try to run the script from within Arctoolbox, its runs, completes, but nun of the file geodatabases are updated with the new domain. Regards
... View more
10-27-2011
07:20 AM
|
0
|
0
|
2202
|
|
POST
|
Thank You so much, I will definitetly look into taking the course and purchasing a python reference book. You have just saved me hours in work time on my current project. Regards
... View more
10-27-2011
05:38 AM
|
0
|
0
|
2202
|
|
POST
|
Thank you so much for you assistance with the following. Would you mind explaining the reason that it never worked in order for me to learn from the current script so that I could use it for looping through other tools within ArcGIS? Thanks once again for your assistance. Regards
... View more
10-27-2011
05:05 AM
|
0
|
0
|
2202
|
|
POST
|
Hi Peter, It may be easiest to do this using a python script rather than model builder. Here is an example on how to do this. The below script will iterate through each sub directory in your 'H:\Projects\H107039_PeterW\workpackages' workspace: import arcpy, os
from arcpy import env
folder = r"H:\Projects\H107039_PeterW\workpackages"
for (path, dirs, files) in os.walk(folder):
if ".gdb" not in path.lower():
env.workspace = path
databases = arcpy.ListWorkspaces("*", "FileGDB")
for database in databases:
arcpy.TableToDomain_management(r"C:\TEMP\Python\domain.dbf", "Code", "Desc", database, "City") You will just need to update the line "arcpy.TableToDomain_management(r"C:\TEMP\Python\domain.dbf", "Code", "Desc", database[0], "City")". The first variable is the path to the table containing the domain. The second variable is the field containing the domain code. Third variable is the field containing the domain description, and the 5th variable is what you would like to name the domain. I ran the script and received the following error: Traceback (most recent call last): File "S:\Projects\H107039\GIS\ModelBuilder\TableToDomain2.py", line 10, in <module> arcpy.TableToDomain_management(r"S:\Projects\H107039\GIS\Domains.gdb\Landuse_Description", "Code", "Description", database[0], "Landuse Description", "Aurecon Landuse Description", "REPLACE") IndexError: list index out of range Here's the current structure of my script: import arcpy, os from arcpy import env folder = r"S:\Projects\H107039\GIS\ModelBuilder\Geodatabases" for (path, dirs, files) in os.walk(folder): if ".gdb" not in path.lower(): env.workspace = path database = arcpy.ListWorkspaces("*", "FileGDB") arcpy.TableToDomain_management(r"S:\Projects\H107039\GIS\Domains.gdb\Landuse_Description", "Code", "Description", database[0], "Landuse Description", "Aurecon Landuse Description", "REPLACE") Regards
... View more
10-27-2011
04:56 AM
|
0
|
0
|
2202
|
|
POST
|
I need to add an attribute domain to multiple file geodatabases, using the geprocessing tool "table to domain" for each file geodatabase wihtin a directory within subfolders. I've attached a print screen of the folder structure. Any assistance in being able to achieve this will be appreciated. Please note that I have very little experience in python. Regards
... View more
10-26-2011
11:17 AM
|
0
|
9
|
5235
|
|
POST
|
I'm looking for assistance in adding an attribute domain to multiple file geodatabases by iterating through a folder and adding an attribute domain using "table to domain" for each file geodatabase found within the directory. If anyone can assist me with generating a model within modelbuilder to accomplish this, it will truly be appreciated. Regards
... View more
10-26-2011
11:11 AM
|
0
|
1
|
595
|
|
POST
|
I'm looking for a way to iterate through all the file geodatabases under a directory which has folder for each filegeodatabase and add a domain to each file geodatabase using the geoprocessing tool "table to domain". I'm wanting to replace the geodatabase for each iteration based on a list of file geodatabases found under the directory within subdolders. I tried to use the new iterator option within modelbulder 10, but have been unsuccessful. I've attached a print screen of the current model as well as the folder structure that I'm trying to iterate through. Any advice in how to achieve this will be appreciated. Regards
... View more
10-26-2011
10:14 AM
|
0
|
2
|
2440
|
|
POST
|
Hi Peter, Thanks for the reply. Yes, you're right about the location not being correct on the screen shot I posted. I think at that time I was checking to see if the Layers folder was causing my problems, so I changed the path temporarily. However, the main problem seems to be with the vector data path and the geodatabase. I am able to create one dataset in the geodatabase, and then if I try to add any more, or even try to use that one dataset for any further AH analysis, the tool I am trying to use crashes (doesn't matter which AH tool). For example: I run Sink Evaluation, which creates SinkPoly and SinkDA feature classes in the geodatabase. Then, the next tool I try to run that either uses those feature classes, or tries to create new feature classes (say, Catchment Grid Delineation, or Flow Direction with Sinks) causes the "Set Target Locations" box to pop up, blocking me from running the tool no matter where I set the locations to. I am also unable to change the path to the database in the Set Target Locations menu. It always reverts to the default (which would be fine, except the default keeps crashing my tools!). I have reinstalled AH with the most recent version, and I have reinstalled ArcGIS. Neither has helped, so I think I will reformat my computer when I have some time. Unless you have any other ideas?:D Thanks, Brendan Hi Brendan I have one more possible solution. This will require you to uninstall ArcHydro, restart your computer, then find your temp folder under delete everything under your user profile and reinstall ArcHydro. ArcHydro create a temp ArcHydro tartget locations file under the temp folder. Yours could have become corrupted and was not removed when you reinstalled and therefore reinstalling without removing this never solved your problem. I sure this or your windows is causing the problem as I use ArcHydro on a daily basis. Regards
... View more
10-24-2011
12:22 PM
|
0
|
0
|
2014
|
|
POST
|
Hi Brendan 🙂 I'm currently running Windows 7 64bit with ArcGIS 10 SP3 and the latest ArcHydro 2.0 (26 Sept 11). The first thing that I notest is that your layers path for set locations is not refering to the defualt layers folder where ArcHydro generally saves all the rasters that are generated. C:\Work\Kamloops\. It should be C:\Work\Kamloops\Layers\. The word layers is the folder thats originally generated when you initially save your mxd that you are using to run ArcHydro. If all else fails unintstall Archydro and download the latest from the ESRI ftp server. I dont have the address currently on me, but if you search ESRI FTP ArcHydro within the forums you will find it within one of the forums posted. best of luck. Regards
... View more
10-17-2011
07:27 PM
|
0
|
0
|
2014
|
|
POST
|
Dear Community I'm looking at developing a model using ArcGIS Model Builder and Python in developing a process of estimating the potential loss of life due to dam failures caused by flooding based on Graham (1999) method. I'm looking at getting advice on current approaches that have been applied using GIS in order to eliminate time wasted in the development of my model. Any advice or assistance will be appreicated. Regards
... View more
10-13-2011
12:59 AM
|
0
|
0
|
2712
|
|
POST
|
Peter - please email me (contact info in in my sig below) Hi Curtis My contact details are : Peter.Wilson@aurecongroup.com, Thanks Regards
... View more
08-11-2011
07:55 PM
|
0
|
0
|
2650
|
|
POST
|
I am interested as well. Thanks, James Hi James I've spoken to Dean Djokic from the ESRI Arc Hydro Team and Terrain Datasets won't be supported as they vector based and Arc Hydro uses grids. Mosaic Datasets on the other hand will be support at a later stage. Regards
... View more
08-11-2011
07:54 PM
|
0
|
0
|
505
|
|
POST
|
Hi Curtis I would really be interested in looking at the toolbox that you have developed. It would be greatly appreciated if you would be willing to email me a copy for ArcGIS 10. Thanks fo offering your assistance. Regards
... View more
08-10-2011
08:44 PM
|
0
|
0
|
2650
|
|
POST
|
Hi Jamie Thanks so much, your python script has solved my problem. I've made some minor adjustments to your code to tie in with ArcHydro. Thanks again, its greatly appreciated. Regards
... View more
08-10-2011
08:38 PM
|
0
|
0
|
2650
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 01-16-2012 02:34 AM | |
| 1 | 05-07-2016 03:04 AM | |
| 1 | 04-10-2016 01:09 AM | |
| 1 | 03-13-2017 12:27 PM | |
| 1 | 02-17-2016 02:34 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-04-2021
12:50 PM
|