POST
|
Sorry there was a typo in the code. The variable above should be hurricaneLayerName.
hurricaneLayerName = "Hurricanes" #replace with name of hurricane layer
hurricaneLayer = arcpy.mapping.ListLayers(mxd, hurricaneLayerName, df)[0]
You were on the right track though. You can just pass in the name, but it needs to be the name of the layer in the map, not the shapefile name (They could be different). You would also need to surrond it in quotes, because it is a string.
hurricaneLayer = arcpy.mapping.ListLayers(mxd, "hurr_data", df)[0]
... View more
10-17-2013
08:17 AM
|
0
|
0
|
385
|
POST
|
To accomplish this you are going to need to use python, which you could then create a script tool from and use in model builder. Below is a code sample. Basically we are opening the MXD, gettting some references to the data frame and layers and then stepping through time. At each step we perform our analysis and then move to the next time step.
#Get a reference to the map document and first data frame
mxd = arcpy.mapping.MapDocument('Current') #If code is run in the app with the MXD open, otherwise pass the path to the MXD
df = arcpy.mapping.ListDataFrames(mxd)[0] #Assuming here there is only one data frame in the MXD
rasterLayerName = "SST" #replace with name of netCDF raster layer
rasterLayer = arcpy.mapping.ListLayers(mxd, rasterLayerName, df)[0]
hurricaneLayer = "Hurricanes" #replace with name of hurricane layer
hurricaneLayer = arcpy.mapping.ListLayers(mxd, hurricaneLayerName, df)[0]
#Loop through each time step within the full time extent
df.time.currentTime = df.time.startTime
while df.time.currentTime <= df.time.endTime:
#Add your logic here, I assume you are using extract values to point
#So we don't overwrite the output each time, we need a unique name, this will append the Year and Month value currently being processed.
uniqueName = "Hurricanes_" + dt.time.currentTime.strftime("%Y_%m")
outPointFeatures = r"C:\OutputDate\" + uniqueName
ExtractValuesToPoints(hurricaneLayer, rasterLayer, outPointFeatures,
"NONE", "VALUE_ONLY")
#Set the current time of the data frame to the next time step
df.time.currentTime += df.time.timeStepInterval
... View more
10-16-2013
04:32 PM
|
0
|
0
|
385
|
POST
|
With a geocoding service it would be possible to send a request to the service using the address and return the result without ever creating a table or feature class. Otherwise I think the simplest thing to do would be to just create and in_memory table and write the address to a field and then write the output to an in_memory feature class. The in_memory input and output would just be temporary in the script.
... View more
04-16-2013
09:28 AM
|
0
|
0
|
337
|
POST
|
ListFields takes a wildcard for the field name, passing in the field name should only return the single field. import arcpy
arcpy.env.workspace = "C:\GeoSpatialTraining\GISProgramming101\Exercises\Data"
infc= "Streets.shp"
fieln="FULL_STREE"
field = arcpy.ListFields(infc,fieldn)[0]
print field.type
... View more
04-12-2013
01:29 PM
|
0
|
0
|
1445
|
POST
|
Yes, one option would be to author a model or script tool that has 2 data-time parameters and based on use input executes some logic. Then from a button in your add-in you could launch that tool. GP Tools have 100's of parameter types that allow you to build a UI for accepting user input and built-in and customize-able validation that can be run before the tool is actually executed. Another option would be to build a .Net add-in. The .Net framework offers a rich environment for building windows forms that can accept user input and execute code. If you would prefer to author your form in .Net you could still have you business logic in a python script tool and call the tool from .Net passing in any required parameters.
... View more
04-12-2013
01:23 PM
|
0
|
0
|
230
|
POST
|
That occurs when the path has a space in it for a multivalue parameter. You can safely remove the single quote using the strip function on the string. If the string doesn't begin or end with a single-quote then the code below will have no impact on the original string. shpPath = shp.strip("'")
... View more
04-08-2013
02:52 PM
|
0
|
0
|
241
|
POST
|
Hi Chris -- thanks for the reply. So, simply running the makeaddin.py from say PythonWin will not work? It seems to create a new .esriaddin file each time! 1. I am unsure if your suggestion will work for me as we are in a Citrix environment. There is no Program Files\Common Files\ArcGIS\bin\ESRIRegAddIn.exe available to us! Can that ESRIRegAddIn.exe tool be copied and run from our Citrix environment? I may have to use one of our server environments that has a full install of ArcGIS 10.1 on it in order to get this add-in built. Unless you have a solution for us Citirx environment people? I am kind of confused, I understood that you had a problem when double-clicking the esriaddin file. The makeaddin.py is just a python script that will zip up all the contents of the addin into a single compressed file with a .esriaddin extension. So yes, it is intended behavior that a new .esriaddin file is created each time. As far as running the makeaddin.py file, you could run it from any Python IDE or if it is already associated with an install of python you should be able to just double-click it. You don't need an install of ArcGIS 10.1 to build the python add-in, all you need is a version of python installed, i am not sure if there is a specific version, but 2.7 would be the best bet. This is because you only need to be able to run the makeaddin.py to build the add-in. To install the add-in, ie double-click the .esriaddin file and pop up the installation utility, you do need ArcGIS 10.1 installed. This is because that utility is ESRIRegAddIn.exe which is installed with ArcGIS Desktop. In regards to a Citrix environment, if ArcGIS Desktop 10.1 was installed on the citrix machine the ESRIRegAddIn.exe should have already been associated with the .esriaddin file extension type for all users on the machine. This is really not specific to Citrix. If you are connecting to Citrix machine that has ArcGIS Desktop installed and attempting to double-click an .esriaddin file and no installation utility is launched it sounds like something broke the default file associations with these files. If that is the case you would want to work with the administrator of the machine to reestablish those file associations for all user.
... View more
04-05-2013
12:44 PM
|
0
|
0
|
735
|
POST
|
With regards to double-clicking the esriaddin file and it asking you which program to open with it sounds like there is a file association problem. Go ahead and right-click any esriaddin file and select Open With > Choose Default program and select ESRIRegAddIn.exe from C:\Program Files\Common Files\ArcGIS\bin. With regards to the tool. It probably won't make a difference to the problem but go ahead and remove all the other functions in the tool you don't plan to implement, ie onMouseDown, onMouseUp, etc. The behavior that controls whether you can click and drag and what shape is drawn is controlled by the shape property of the tool class. I see you have it set to Rectangle, so that seems correct. Try adding the same logic to onMouseDown and see if that even causes a messagebox to be shown. Could you post the code with the intentional error you added?
... View more
04-05-2013
11:28 AM
|
0
|
0
|
735
|
POST
|
This is assuming based on your code that you only need to find MXDs whose first 5 characters of the name is "Copy_":
#This is where I am encountering problems with how to only apply changes to mxd's file names that contain 'Copy'
#term = "Copy"
#if term in basename:
if basename[0:5] == "Copy_":
Strings are indexable so what I am doing is returning the first 5 characters of the name of the MXD and testing if it is equal to Copy_
... View more
03-21-2013
12:58 PM
|
0
|
0
|
243
|
POST
|
I am having the same problem. I get a big red X on my Toolbox, which means I am unable to open it and even view the potential errors within them. However, when I click "Check Syntax" I get "No Syntax Errors". What does this mean? If there are no syntax errors, what is the problem? If there is an error, why doesn't it tell me where it is? As a test, I added an error, and it was returned when I reclicked "Check Syntax". This seems in all respects to be a bug. Could you post the toolbox? It does sound like a bug.
... View more
03-13-2013
03:43 PM
|
0
|
0
|
961
|
POST
|
Thomas, I posted the add-in to arcgis.com if you want to download and compare: http://www.arcgis.com/home/item.html?id=56df83424be54b5aa96aa564b88c10ed The code looks alright after a quick look. To debug this what is being printed to the python window? There are a lot of print statements in the code, are any of them being reached? Also win32com is not available by default with a base install of python. You need to actually go out and install it to use it. The pythonaddins module should only be used within ArcGIS Desktop in an add-in.
... View more
03-13-2013
03:33 PM
|
0
|
0
|
795
|
POST
|
Excellent Chris, this works perfectly. Thanks very much. DK P.S. Any idea why elseif is one work but end if is two? I am not sure, but this is consistent with all VB languages. http://msdn.microsoft.com/en-us/library/752y8abs(v=vs.80).aspx
... View more
03-13-2013
08:12 AM
|
0
|
0
|
1177
|
POST
|
A couple things, VBScript does not allow you to explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x. If you want to execute only one statement when a condition is true, you can write the code on one line, otherwise each statement needs to be on a new line ie If....Then statement elseif....Then statement else statement end if Dim temp If [OBJECTID] =1 Then temp = "Very Destructive" elseif [OBJECTID] = 2 Then temp = "Destructive" elseif [OBJECTID] =3 Then temp = "Damaging" else temp ="Nothing" end if
... View more
03-12-2013
04:21 PM
|
0
|
0
|
1177
|
POST
|
To add to Luke's response you might want to specifically check out Live Mode on the Time Slider
... View more
03-11-2013
02:54 PM
|
0
|
0
|
182
|
POST
|
Check my latest posts on the following ArcGIS Idea for information on a 64 bit version of ArcGIS Desktop: 64 Bit ArcGIS Desktop In addition, at 10.1 you should start to consider if making an OLE DB connection is necessary. We now allow you to make a database connection to any of the following databases even if they don't contain an enterprise geodatabase: �?� IBM DB2 �?� Informix �?� Microsoft SQL Server �?� Windows Azure SQL Database �?� Netezza �?� Oracle �?� PostgreSQL So for the majority of users they will only ever need to use the Add Database Connection command. The only time you would need to use an OLE DB Connection is if you need to connect to a database not in the list above. The original poster was working with SQL Server, so if you use a Database Connection instead you will be able to use this connection in 32 bit or 64 bit background.
... View more
03-08-2013
10:15 AM
|
0
|
0
|
189
|
Title | Kudos | Posted |
---|---|---|
1 | 06-02-2011 03:59 PM | |
1 | 06-10-2011 08:37 AM | |
1 | 06-08-2011 04:27 PM | |
1 | 06-07-2011 03:11 PM | |
1 | 01-31-2013 02:36 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:22 AM
|