|
POST
|
I keep getting the syntax error on Line 2. def getTIME(TF):
time == str(%Time Frame%)
if time == "5 Minutes":
You can't put model variables inside the Calculate Value codeblock. Here's how you do that: Expression: getTime("%Time Frame%") Code block: def getTIME(TF):)
if TF == "5 Minutes":
(...)
You can read up on lists and dictonaries quickly in the Python tutorial. (I still go back to it at times to brush up.) Dan is right -- they are definitely the way to go with lookups like this:
dictTimes = {"Years":"yr","Days":"dy"}
lstPair = TF.split() # makes list: ["5","Years"]
shortName = lstPair[0] + dictTimes[lstPair[1]] # "5yr"
... View more
06-20-2011
02:44 PM
|
0
|
0
|
4153
|
|
POST
|
The field map object is the easy way - the string representation can get pretty complicated so it's easier to work the the object. An "easy" method I've used with append is to create an empty output feature class with just the fields I want and run Append to that dataset with "NO_TEST" - any fields that don't match with the output dataset's fields (schema) are simply ignored. I have found this less painful than dinking with the field map object to change field order or drop fields.
... View more
06-20-2011
02:28 PM
|
0
|
0
|
3829
|
|
POST
|
Danger, the code above uses normal strings with backslashes. These are escape characters in Python and will not work. Easily fixed by making them "raw" strings as follows: fcpath = r"X:\working\metadata\BlankGDB.gdb\FullMetaFC"
Also you may want to read up on the Arc 10 metadata story, as both FGDC and ArcGIS 10 metadata may be in the metadata file and you will want to decide how you can handle that. A New Approach To Metadata at ArcGIS 10 (Part 1) http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2011/01/03/A-new-approach-for-Metadata-with-ArcGIS-10.aspx
... View more
06-20-2011
02:16 PM
|
1
|
2
|
4828
|
|
POST
|
It may help figure out what went wrong if we saw the original example. Did the example come from the online help? In your code, I'm pretty sure that "dir" is a list of folders, not a list of rasters. The usual approach would be to use ListFiles or glob.glob() to get a list of .flt files for each folder and loop on that. What format do you want for the integer output?
... View more
06-20-2011
02:12 PM
|
0
|
0
|
602
|
|
POST
|
I am running ArcGIS 10 and I am running it as tool. Any suggestions/ideas? If you are running is a tool, you may want to make the input a multi-value integer. Then as the user enters them one a time in a dialog, they are all checked to be integers (within a domain that you can specify, for example, the tool won't accept negative numbers). This is really nice because you can do error checking before your tool even sees it, saving you script coding! If you do it this way, the list comes across as a ';'-delimited string, so you need to split it this way: strList = gp.GetParameterAsText(2)
lstNums = strList.split(';') If the parameter is strings that may have quotes or ';' within the data values, you may need to get a little fancier with the "list comprehensions" mentioned in this thread.
... View more
06-10-2011
04:27 PM
|
0
|
0
|
1738
|
|
POST
|
this problem is not unique to person geodatabase format. I see the calculation slow down in shapefiles, file geodatabases and in enterprise level geodatabases when comparing 10 vs 9.3.1. 9.3.1 wins! Something to check that I didn't see mentioned in this thread yet: if you have a join active, you should disable it - or use the VBScript option in Field Calculator. Bug" rel="nofollow" target="_blank">http://support.esri.com/en/bugs/nimbus/TklNMDYwNjc1]Bug NIM060675 Field Calculate performs very slowly on a layer with a join when using Python as the parser. [post]45792[/post]
... View more
06-10-2011
03:55 PM
|
0
|
0
|
2627
|
|
POST
|
is it possible to calculate multiple individual viewsheds with a feature class that contains a hundred or so points in model builder. If you're using 10.0, I highly recommend trying an iterator in your model. You could iterate features and produce a bunch of outputs, maybe doing some post-processing on each one as it goes. Of course it might take a while!
... View more
06-10-2011
01:00 PM
|
0
|
0
|
409
|
|
POST
|
Persist the Join (i.e. CopyFeatures to new FC), can the field be used? Does IDW work? I second the suggestion. (Hi Steve!) My guess is the tool is balking at the $ in the field name.
... View more
06-10-2011
12:35 PM
|
0
|
0
|
812
|
|
POST
|
I found a possible workaround in the old forums. I realize this involves re-mapping field names but it may be the only way. http://forums.esri.com/thread.asp?c=93&f=1728&t=224243 Subject Re: "Export" a table in Modelbuilder Author Karl Brotzman Date Jun 19, 2007 Message Take a look at DataManagementTools -> General -> Merge. I've used it to clean up a file after three joins. If you double click the tool after you've added it to a model in the model builder, you'll see the "Field Map" at the bottom of the dialog. You can delete and rename fields there. Worked great for me. The tool accepts a single feature class as well as multiple. That's how I use it. The only setback I've had is with the persistence of the "Field Map". It was working great, but somehow the model reverted to the default or original Field Map which is all the fully qualified and mangled names. So, I had to retype the map. I tried without success to reproduce that problem. Those of us at the UC should make a point to ask about this at the geoprocessing island. (I've found this is a very effective way to get things on their radar. I try to sweeten the pie by giving them well-deserved thanks for successes while I'm there -- for example, I absolutely love the new iterator functionality - it's very useful and has worked very well for me.) Joins in model builder have been a hassle from the beginning. We need it to work better than this!
... View more
06-10-2011
09:29 AM
|
0
|
0
|
2977
|
|
POST
|
I got back from ESRI: NIM069071 The environment setting to 'Maintain fully qualified field names' is not honored when performing an Add Join in Modelbuilder Thank you for getting that logged and sharing that NIM# here. Everyone please use all avenues at your disposal (ideas.esri.com, support tickets, ESRI doctor's office) to push this getting fixed and soon. If you have Premium Support please ask for a hotfix so we can get a patch online! I sure hope they marked it Critical!
... View more
06-09-2011
07:02 AM
|
0
|
0
|
2977
|
|
POST
|
I want to list all features, by feature dataset, to deliver to the staff at my office. Since you're not well-versed with Python, you may want to look into ModelBuilder 10. I never used to suggest this, but have been very impressed with the new iterator functionality. To generate a list of anything (even recursively in a folder tree) in model builder right-click, choose Iterators and what you want to list. Then double click it and enter the particulars (ie where you want to look), and then pipe the pathname output into the Collect Values tool and run it. This easily generates a list of with no coding; you could use Calculate Value to convert it to a string to paste into a text file or whatever.
... View more
06-09-2011
06:49 AM
|
1
|
0
|
6200
|
|
POST
|
Are both in the same coordinate system? To check, add each one to a new dataframe and mouse around on the screen to check the coordinates in the bottom right (ie don't rely on the meta data) Just a clarification: what Dan is getting at is that if they are in different coordinate systems, and the gp environment is set to use the default coordinate system, the EMVTP tool will do the analysis using the coordinate system of the first raster in the list. This means the second one may be try to extract a value way off your raster. My favorite way to double check whether the two datasets are in the same coordinate system is to clear the data frame's coordinate system (this turns off any projection on the fly) and zoom to the two layers to see if they are plotting in the same part of the world. My experience is that for most things in the spatial analyst toolbox, having everything in the same coordinate system is the best policy (especially rasters, features do sometimes project on the fly fine).
... View more
05-31-2011
11:09 AM
|
0
|
0
|
775
|
|
POST
|
I will. is there a way to link this post to the ideas.esri.com? Well, you could paste the URL into your submission. do they take our needs into consideration? how much time It's a slow process, but going to tech support and getting an enhancement request is required if you want the developers to be aware of your need. for the time being, how can i sort the values. it doesn't make sense to arrange them alphabetically the thing that the ArcGIS does!!! Use reclass to create a grid with "Value" reflecting the order you want; 1=lousy to 4=great for example -- and use the label field to label them. I honestly thing you should try to do analysis with integer data -- since the operators like reclass work with integers in truth -- the support of text fields is a behind-the-scenes lookup which may get you into trouble down the road.
... View more
05-31-2011
11:00 AM
|
0
|
0
|
1134
|
|
POST
|
why the "Combine" tool doesn't keep the original values of the combined rasters? is there any other tool that combines the rasters but keeps the values of the fields of as they are??? The issue with Combine is that it is an integer value operation. Floating point (or text) raster table values wouldn't lend themselves to the desired combinatorial operation. So -- you would like all the fields in the output table? In command-line ArcInfo GRID there is a command MERGEVAT (it exists in 9.x MOMA, but that's a secret) that does this. It basically did a Join Field between two raster tables, dropping VALUE and COUNT from the second input. That would be a nice little tool. I just may write a Python script tool to do that.... Send it to ESRI as an enhancement request!
... View more
05-30-2011
08:16 AM
|
0
|
0
|
846
|
|
POST
|
The sample you code you posted uses something called "DOCELL" notation (sometimes called neighborhood notation) to refer to neighboring cells using relative coordinates (for example, 1,-1). Unfortunately, ESRI still has not ported that functionality in ArcGIS. Just to set the record straight, the "[,]" neighborhood notation is supported (and is much more efficient) outside of DOCELL blocks in ArcInfo GRID. There are no plans I've heard to support neighborhood notation in ArcGIS; members of the raster team have also pointed me to raster to numpy array to accomplish this task. (Are ya listening, your rasteroid guys and gals in Redlands? IMHO going to numpy is a bit kludgy to access what I feel is basic raster modeling functionality. Sure would be nice if you supported neighborhood notation as a method on the raster object, say: "myRaster.nbr(1,1)" or something like that.) I just thought of another approach outside of shifting grids around - which is to calculate focal sums using custom kernel neighborhoods to access those neighborhood cells. This has the potential of performing better than using the shift tool, which most certainly would involve copying the whole grid to access neighborhood cell. If you have access to ArcInfo GRID I'd look for an old person to help you do it there. 🙂
... View more
05-30-2011
07:29 AM
|
0
|
0
|
1672
|
| 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
|