|
POST
|
Question from a very frustrated individual trying to learn model builder. Can you create a model that will allow you to choose the location of the float files you wish to use, process them to raster then define the projection? Everything I've read seems to show that you have to hard code the file you wish into the model. This seems ridiculously inflexible. Thanks. Right click a data input or output and pick "Set as Parameter". Unless I'm missing something. There is a tutorial in the help that walks you through the process.
... View more
03-19-2013
04:20 PM
|
0
|
0
|
1326
|
|
POST
|
I need to figure the best potential site locations for a store based upon distance from major roads. If a location is within 1000m of a major road its scored 10, if between 1000 and 3000 meters its scored 20 and all other distances are scored 0. None of the syntax formula's I have written seem to work. I am working with 10.1. I have a raster dataset with the euclidian distance to the roads. If you decide that you'd like to do something fancier than what's easy to do with the Weighted Overlay tool, Map Algebra is quite up to the task. Reclassify is handy, but I have to say the Con function is really useful for this kind of thing. I'm assuming you're using Raster Calculator and have a raster layer called "distRas" in your table of contents. This expression, which nests one Con inside another, will do what you want: Con("distRas" < 1000,10,Con("distRas" < 3000,20,0)) UPDATE: fixed syntax above
... View more
03-19-2013
04:08 PM
|
0
|
0
|
1397
|
|
POST
|
Is that the source of the error because i thought it had something to do with the invalid parameter, but i havent changed anything and the script has been working fine for me for a while, i did just update to 10.1 There has been a major change in how database connections are handled. I'd look into that: ArcGIS 10.1 Help: What's new for geodatabases in ArcGIS 10.1
... View more
03-19-2013
12:26 PM
|
0
|
0
|
2118
|
|
POST
|
I keep getting the attached error when i try to run my frequency analysis script, any ideas why /how to fix it? If the output already exists, it may help to delete the output first, change the name of your output file, or add a line of code to your script to allow overwrites of existing datasets: arcpy.env.overwriteOutput = True
... View more
03-19-2013
08:06 AM
|
0
|
0
|
2118
|
|
POST
|
I installed Python 2.7.! But unfortunately I still get error messages. Check out this post about the Desktop.pth file: [thread]23230[/thread] Also - make sure Windows has .py files associated with python 2.7 python.exe.
... View more
03-18-2013
10:55 AM
|
0
|
0
|
1807
|
|
POST
|
it appears that tools will not function if they call third-party modules, or use tools from a list of specific ArcGIS toolboxes. None of my tools do either of these things, but they do import custom modules that I wrote which use only native arcpy and Python mods. Third-party modules should work fine if they are installed in your 64-bit Python. Are trying to access unsupported datatypes?
... View more
03-18-2013
10:50 AM
|
0
|
0
|
854
|
|
POST
|
Thanks for the responses. Can anyone provide an example of just testing whether a parameter exists? When you use GetParameterAsText, when no value was provided, it comes across as an empty string. # test if the third parameter was set if arcpy.GetParameterAsText(2) == "": do this else: do that If you have a checkbox parameter (Boolean) you can do this: # test if the third parameter was checked # Booleans come across as the string "true" or "false" if arcpy.GetParameterAsText(2) == "true": do this else: do that
... View more
03-18-2013
08:37 AM
|
0
|
0
|
2120
|
|
POST
|
There's a great set of ArcGIS Blog posts on this topic that really opened my eyes to some of the more advanced capabilities of ModelBuilder. Parts 1 and 2 directly deal with your question on how to branch models. ArcGIS Blog: If You Are Stuck At "If" (5 parts) Part 1 Part 2 Part 3 Part 4 Part 5
... View more
03-17-2013
10:42 PM
|
0
|
0
|
2120
|
|
POST
|
I have about ten fields but only want to export the City and Zip fields into the new Test.dbf file. I can get it to write all the fields to the new dbf file but am struggling with exporting just two. You could futz with the fieldmappings object (you can look that up in the help), but honestly the easiest way to do what you want is to create the output table with just the two fields you want, and use Append_management with the "NO_TEST" option to copy the two fields over. The fields that do not match (by name) will be ignored in the append. arcpy.CreateTable_management(arcpy.env.workspace,"out.dbf") arcpy.AddField_management("out.dbf","City","Text",field_length=20) arcpy.AddField_management("out.dbf","Zip","text",field_length=9) arcpy.DeleteField_management("out.dbf","ID") # dummy field created by CreateTable arcpy.Append_management("in_table","out.dbf","NO_TEST")
... View more
03-17-2013
10:24 PM
|
0
|
0
|
1321
|
|
POST
|
You're welcome! Can you point me the ESRI web help for the field calculator used in python script. For instance, I never saw this in any help document before: Expression = "'{0}'".format(arcpy.GetParameterAsText(3)) This is a Python thing. Although there are three main ways to do string formatting in Python, the format() function is current way to do it. Python Tutorial: 7.1. Fancier Output Formatting
... View more
03-15-2013
10:49 AM
|
0
|
0
|
1954
|
|
POST
|
Here's a working example - attached - just to show that it can be done. Just to demonstrate how not-scary Python is: you could paste this script at the Python prompt, or recast it as a function and drop it in a Calculate Value tool in ModelBuilder:
import arcpy
arcpy.CheckOutExtension("spatial")
arcpy.env.workspace = pathWhereMyRastersAre
outWks = pathToWriteOutput
for year in range(1976,1979): # 1976 through 1978
for month in range(13): # 1 to 12
# wildcard - "TOMS_1976m01*.HDF" (format month 1 -> "01")
wild = "TOMS_{0}m{1:02d}*.HDF".format(year,month)
rasList = arcpy.ListRasters(wild) # list all rasters for a month
outRas = arcpy.sa.CellStatistics(rasList,"MEAN") # monthly mean
outPath = outWks + "/" + "m{0}m{1:02d}".format(year,month)
outRas.save(outPath)
... View more
03-15-2013
10:12 AM
|
1
|
0
|
2578
|
|
POST
|
Thanks for the reply Curtis. I'm the GIS research specialist helping Amy with her model and suggested she look to the forum for more help. Unfortunately the constraints of academic based GIS research are such that "learning python" isn't really an option for most researchers, especially those with no prior programming background. David, Amy, Writing little Calculate Value scripts are a great way to get started with programming, and honestly to make full use of ModelBuilder you have to. What's awesome about Python is it's a full-featured programming language that is very simple to learn, much easier than even VBScript. This can open doors for scientists without programming background to gain a lot of capability for not a lot of pain. (I was very good with AML but never quite got the hang of .Net and ArcObjects - The more coarse-grained Python GP is much more up my alley. I guess that means i'm not a developer either.) The Esri product teams would be the first to admit that they haven't always made the right call, but they hit a home run IMHO by choosing to build the geoprocessing tool environment around Python. I've used iterators in model builder quite a bit but am not familiar with model variables (other than %name%). In your example ""TOMS_%year%m%month%*", where do the year and month model variables come from? Can we create a list for the years and add that as a variable to the model or do we need to run a search cursor to get all of the names first? What I was thinking was nesting iterators as described in the help here: ArcGIS 10.1 Help: Integrating a model within a model See the section Advanced use of model iterators
... View more
03-15-2013
09:05 AM
|
0
|
0
|
2578
|
|
POST
|
My sample model includes a parameter output. In the one that has a hard-coded name, the output is added to the map. In the one that includes a variable in the output name, the output is not added to the map. I think this is an ESRI bug. Your suggestion gave me a workaround for this issue for the time being. Thanks! You're very welcome. If you haven't filed support incident and gotten a NIM, please do -- this will greatly increase the chances of Esri getting the problem fixed.
... View more
03-15-2013
07:51 AM
|
0
|
0
|
2240
|
|
POST
|
Thank you! It seems like the script is running better now. However, I still come back to my first error. ERROR 00728: Field Update does not exist within table... I am not sure why because the two lines before calculating the field were specifically written to create this field... My guess is the field name "Update" was not legal for that workspace/table type, so the field name got saved as something legal like "UPDATE_". (UPDATE is a reserved word in SQL.) If I try to add a field to a fGDB table with this name interactively, I get a warning: WARNING 000304: Renamed field Update to Update_ Adding Update_ to sampcells_RotateFeatures... See the help for arcpy.ValidateFieldName for more details on how to deal with that.
... View more
03-14-2013
03:31 PM
|
0
|
0
|
1954
|
|
POST
|
I think your Expression variable should actually be: Expression = '"Update" = ' + "'" + arcpy.GetParameter(3) + "'" Or better yet, use Python string formatting - easier to get the syntax right. The expression just has to be the part that you would have typed into the Calculate Field dialog -- "Update = " is handled by putting your field UpdatedField in the second argument. The error is: "cannot concatenate 'str' and 'geoprocessing value object' objects". I also recommend using arcpy.GetParameterAsText unless you have a special reason for needing to use GetParameter (value tables etc). The text representation is usually much easier to work with, as you have discovered. I moved the message first because it makes sense to say what you're about to do before you do it...
# Add Field
arcpy.AddMessage("Adding Updated Field...")
arcpy.AddField_management(Selected_cnddb_point, UpdatedField, "TEXT", "", "", "50","", "NULLABLE")
#Calculate Field
arcpy.AddMessage("Calculating Updated Field...")
Expression = "'{0}'".format(arcpy.GetParameterAsText(3)) # single quoted string literal
arcpy.CalculateField_management(Selected_cnddb_point, UpdatedField, Expression, "PYTHON")
... View more
03-14-2013
01:40 PM
|
0
|
0
|
1954
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-11-2021 01:26 PM | |
| 5 | 12-10-2021 04:58 PM | |
| 1 | 02-27-2017 09:30 AM | |
| 2 | 12-04-2023 01:05 PM | |
| 1 | 04-12-2016 10:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-19-2024
12:10 AM
|