|
POST
|
I came up with something like the following. It will take any parameter input and append the associated field name and the value as a tuple to a list. Then iterate through that list appending the values to the expression for however many values there are. Then at the end it removes the 'AND' tag that is defaulted at the end of each loop. The AddMessage is a good line to add when trouble shooting to ensure your variables are being put together as expected. list1 = []
Expression = ''
Meridian = arcpy.GetParameterAsText(0)
if Meridian:
list1.append(('MER', Meridian))
Range = arcpy.GetParameterAsText(1)
if Range:
list1.append(('RGE', Range))
Township = arcpy.GetParameterAsText(2)
if Township:
list1.append(('TWP', Township))
Section = arcpy.GetParameterAsText(3)
if Section:
list1.append(('SEC', Section))
Quarter = arcpy.GetParameterAsText(4)
if Quarter:
list1.append(('QTR', "'{0}'".format(Quarter)))
for field, val in list1:
Expression += '{0} = {1} AND '.format(field, val)
Expression = Expression.strip()[:-4]
arcpy.AddMessage(Expression)
... View more
04-16-2013
08:20 AM
|
0
|
0
|
1582
|
|
POST
|
To do things like zooming etc you will need to work with the 'current' mxd. mxd = arcpy.mapping.MapDocument("current") * is not a valid query value for arc (unless you are dealing with strings). It is hard to tell, are the values in your table you are querying in string format or numeric?
... View more
04-16-2013
05:44 AM
|
0
|
0
|
1582
|
|
POST
|
But is there anyway to achieve the same in arcpy? Yes... Christopher's answer.
... View more
04-11-2013
12:35 PM
|
0
|
0
|
5832
|
|
POST
|
there is a button that clears everything. That is available through ArcObjects, not arcpy. http://forums.esri.com/Thread.asp?c=93&f=992&t=274217
... View more
04-11-2013
11:45 AM
|
0
|
0
|
5832
|
|
POST
|
For your first problem it is fairly simple to design a script tool to take optional parameters. Then based on which parameters are input create a query to input into a layer selection or layer definition query to then get the selected extent and set that to your data frame extent. Here's a simple example. arcpy.SelectLayerByAttribute_management(
lyr, "NEW_SELECTION", "{0} = '{1}'".format(field, value))
df.extent = lyr.getSelectedExtent(False) The second problem is a little harder, it will be highly dependant on your particular environment and requirements in regards to specific features and how they are organized.
... View more
04-10-2013
07:05 AM
|
0
|
0
|
1582
|
|
POST
|
They have quotes because you have spaces in your paths. You should generally try to avoid spaces or starting a directory with a numeral as both of those cases can cause issues when dealing with rasters.
... View more
04-08-2013
02:44 PM
|
0
|
0
|
1217
|
|
POST
|
You seem to be missing some code. I don't see where you assign a value to your variable citiesL and I don't see where you have set your workspace.
... View more
04-08-2013
06:37 AM
|
0
|
0
|
1272
|
|
POST
|
I believe this is the correct syntax.
CSTRANS = '"NAD_1927_To_NAD_1983_NADCON + NAD_1983_To_HARN_WA_OR"'
... View more
04-08-2013
06:27 AM
|
0
|
0
|
2074
|
|
POST
|
You are trying to call your list as a function. And as your error says a list is not callable. You should just need to modify these lines for item in Features:
arcpy.Clip_analysis(item, FloodLevel, "Features_clip")
... View more
04-03-2013
09:51 AM
|
0
|
0
|
8923
|
|
POST
|
Is there a place to track updates on bugs if we know the number? I'm very interested to see what's going to happen with NIM089529 Apologies if this is stupid questions. I did try googling it for a while, but no luck yet. Thanks You can search for bugs that have been published here. http://support.esri.com/en/ This one still isn't showing up though. I assume Esri has internal bug tracking that they don't publish immediately, or ever, as I have seen numerous NIM references from Esri support that don't ever show up there under the referenced number.
... View more
04-03-2013
08:29 AM
|
0
|
0
|
752
|
|
POST
|
The with statement is bugged currently. I'd avoid it for now. http://forums.arcgis.com/threads/79647-Clarifying-when-cursor-locks-are-released?p=280350&viewfull=1#post280350
... View more
04-02-2013
11:14 AM
|
0
|
0
|
5090
|
|
POST
|
You are having issues because you are specifying a dataframe to export. You cannot export a dataframe by layout view. arcpy.mapping.ExportToJPEG(mxd, os.path.join(r"C:\Project\Output", fileName), df) You can read the help on the tool here to get the proper parameter. http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000038000000
... View more
03-27-2013
09:59 AM
|
0
|
0
|
1374
|
|
POST
|
dbf appears to be a function in the dbfpy module. To use your syntax you would have this in your imports. from dbfpy import dbf Or call it explicitly in your line db = dbfpy.dbf.Dbf(complete_name) I've never used the package dbfpy though, so I could be off.
... View more
03-27-2013
07:19 AM
|
0
|
0
|
1324
|
|
POST
|
Are you sure it is actually running slower or just not updating the print outs as fast? I've noticed in pyscripter if you are rapidly sending print statements it starts bogging down the GUI much more than IDLE or command/power shell. It always ran at the same actual times for me though.
... View more
03-27-2013
05:51 AM
|
0
|
0
|
4229
|
|
POST
|
It's my lazy way, but it still works. Though yours is more pythonic I would wager. Potato, tomato.
... View more
03-26-2013
07:44 PM
|
0
|
0
|
2961
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|