|
POST
|
I still get the error. I think the problem is with the fac + 1 at the beginning of line 3. I have tried using str(i) there too, and that does not help.
>>> while i < 111101:
... i = 1111
... fac + i = ExtractByAttributes("Fac", "Value =" + str(i))
... i = i + 1111
...
Runtime error SyntaxError: can't assign to operator (<string>, line 3) post more of the code as it is hard to tell what fac is.
... View more
05-02-2013
12:36 PM
|
0
|
0
|
2342
|
|
POST
|
I am running a while loop and would like to name each output file using the iterator (i) as part of the file name. I have tried "fac" + i, "fac" + str(i), fac + str(i), and fac + i. None of these work. Does anyone know how this can be done? >>> while i < 111101:
... i = 1111
... fac + i = ExtractByAttributes("Fac", "Value =" + i)
... i = i + 1111
...
Runtime error SyntaxError: can't assign to operator (<string>, line 3) edit: I see my solution wouldn't work.... I don't quite understand why you are doing this:
fac + i
Just convert the i value to a string:
## updated
fac + str(i) = ExtractByAttributes("Fac", "Value =" + str(i))
... View more
05-02-2013
12:31 PM
|
0
|
0
|
2342
|
|
POST
|
Hi, We need to share some Python toolboxes across the whole company. We have 2 sides in the production: core users has ArcMap installed on their laptops and others will use it through Citrix. What I would like to do is set the "My Toolboxes" or "System Toolboxes" to point to some shared folder where we can have the tools centralized manner. Is there some easy way to do this at machine level like setting some registry value to HKEY_LOCAL_MACHINE branch? with regards, caje I'd like to know as well (we are a Citrix shop too). For now, we have just placed any new Toolbox with their source scripts on the network share (everyone has access to) and those source code .py files are located close to the Toolbox. This works because we also have some Add-Ins that reference the these Toolboxes too (the tools/buttons on the add-in actually launch the toolbox and the various tools within them). It really is just a matter of providing documentation to users on how to make a new folder connection to this share location. But I'd like to know of other options too. j
... View more
05-02-2013
04:13 AM
|
0
|
0
|
626
|
|
POST
|
How about something like: storeIdSet = set([r[0] for r in arcpy.da.SearchCursor(myFC, ["STORE_ID"])])
for storeId in storeIdSet:
outFC = r"C:\temp\test.gdb\store_" + str(storeId)
arcpy.Select_analysis(myFC, outFC, "STORE_ID = " + str(storeId)) Nice! What a very pythonic way to write. and I am stealing this 🙂 ...so tough to remove the ArcObjects from my thinking!
... View more
05-01-2013
11:53 AM
|
0
|
0
|
3504
|
|
POST
|
Help docs have a reference: http://resources.arcgis.com/en/help/main/10.1/index.html#//0017000000mn000000
... View more
04-30-2013
03:27 AM
|
0
|
0
|
2205
|
|
POST
|
Just as an example of how you might use the timedelta object, so you will have to decide how to implement it. Below d1 is a string object representation of the date (I wasn't sure what field type was in your attribute table), so it shows this conversion but you may not necessarily need that.
import arcpy
import datetime
import timedelta
d1 = '3/4/2013 10:23'
d1frmt = datetime.datetime.strptime(d1, "%m/%d/%Y %H:%M")
addhours = 36
dt = datetime.timedelta(hours = addhours)
later = d1frmt + dt
arcpy.AddMessage(str(later))
output date "later" is printed as: 2013-03-05 22:23:00
... View more
04-29-2013
05:01 AM
|
0
|
0
|
3387
|
|
POST
|
** Changes applied and resolved ** Thanks again for your suggestions. I wasn't completely sold on the idea of using the MakeFeatureLayer_management function to load the SDE Feature Class and I revisted my initial approach. So, this actually did work at first ("sort of"):
arcpy.mapping.AddLayer(df, theFC, "BOTTOM")
The problem is that when it loaded into the TOC, it was named only with the first couple of characters of the full FC datasource. After thinking about it, I figured that maybe I could just simply rename it to the full name after it loads. And that seems to work for my needs -- just reseting the .name property is fine:
arcpy.env.workspace = "C:\\Users\\me\\AppData\\Roaming\ESRI\\Desktop10.1\\ArcCatalog\\mysdeserver.sde"
sdelist = arcpy.ListFeatureClasses()
for sdeFC in sdelist:
## locate the desired fc and add it to the TOC
if sdeFC == 'GIS.THE_FEATURE_CLASS_NAME':
sdeLyr = arcpy.mapping.Layer(sdeFC)
arcpy.mapping.AddLayer(df, sdeLyr, "BOTTOM")
arcpy.mapping.AddLayer
## reset the fc's name after it is added to the TOC
arcpy.mapping.ListLayers(mxd)[0].name = "GIS.THE_FEATURE_CLASS_NAME"
arcpy.RefreshTOC()
... View more
04-19-2013
04:53 AM
|
0
|
0
|
2522
|
|
POST
|
This may be a silly question, but did you set the env.workspace? Does the workspace actually have "wellresult" and "westbays" in it and are they tables in the FGDB? Sorry if this throws you off in the wrong direction, but that's the first thing I'd double-check. j I am trying to use the Make Query Table to join two tables in a one to many situation. I don't want to link the entire script because it is huge. Here is the piece of code within the larger script: sqltable = "sqltable_" + InfoRequestNum
inList = ["wellresult","westbays"]
wellsList = ["wellresult.STAID1_T","wellresult.STAID2_T","westbays.STAID4"]
arcpy.MakeQueryTable_management(inList, sqltable, "USE_KEY_FIELDS", wellsList, "", "") Some info about the script: Everything is taking place in a file geodatabase. wellresult is a point featureclass westbays is a table Each point has a STAID1_T but there are multiple STAID4 that relate to one STAID1_T The output should be sqltable. The error: ERROR 000152: Invalid input data
... View more
04-19-2013
03:46 AM
|
0
|
0
|
4802
|
|
POST
|
That all seems fine, what is the error message you get? Didn't notice this until now, but arcgisscripting???? What? That is very odd. arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000733: Output Layer: Same as input C:\\Users\\me\\AppData\\Roaming\ESRI\\Desktop10.1\\ArcCatalog\\mysdeserver.sde\GIS.THE_FEATURE_CLASS_NAME Failed to execute (MakeFeatureLayer) From ArcGIS 10.1 Help: "000733 : <value>: Same as input <value>. Description The input and output have been given the same name. Solution To prevent overwriting your input during the operation, change the output name to be unique from the input."
... View more
04-18-2013
11:41 AM
|
0
|
0
|
2522
|
|
POST
|
I'm not sure why you would have an issue with using the qualified name. I don't get any error when using the same layer name as the feature class name. How are you creating your mxd and df objects?
def onRectangle(self, rectangle_geometry):
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
... View more
04-18-2013
07:31 AM
|
0
|
0
|
2522
|
|
POST
|
I think you want to use MakeFeatureLayer and add that as a layer object to your map. http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000006p000000 Ah. Okay that works (sort of). I get an error if I attempt to set the same fully qualified Feature Class name as it is in SDE. This fails:
if sdeFC == 'GIS.THE_FEATURE_CLASS_NAME':
sdeLyr = arcpy.mapping.Layer(sdeFC)
arcpy.MakeFeatureLayer_management(sdeFC, "GIS.THE_FEATURE_CLASS_NAME")
why would I want to add something to the map display that is NOT named what it is stored as? Also: Why is it "MakeFeatureLayer"? This is not very descriptive of "Adding a Feature Class to the TOC"! Lol...
... View more
04-18-2013
04:18 AM
|
0
|
0
|
2522
|
|
POST
|
When adding an ArcSDE Feature Class to an .mxd, it only shows the first 3 letters of the name in the TOC. arcpy.env.workspace = "C:\\Users\\me\\AppData\\Roaming\ESRI\\Desktop10.1\\ArcCatalog\\mysdeserver.sde" sdelist = arcpy.ListFeatureClasses() for sdeFC in sdelist: ## locate the desired fc and add it to the TOC if sdeFC == 'GIS.THE_FEATURE_CLASS_NAME': sdeLyr = arcpy.mapping.Layer(sdeFC) arcpy.mapping.AddLayer(df, sdeLyr, "BOTTOM") arcpy.mapping.AddLayer arcpy.RefreshTOC() The above code adds the feature class but it adds it with the name "GIS". Am I completely using the wrong method (I don't see any other way). Solution? Comments? Thanks!
... View more
04-17-2013
11:31 AM
|
0
|
7
|
3510
|
|
POST
|
Due to time constraints, I've had to get a working solution. Like today. 🙂 So, I just went with what was available: Attachments. ew. But it works, and I guess I have to admit that the html popup is pretty sweet (plus you can publish it as a map service to ArcGIS Online and just enable that popup with the attachments and it just works. A bit clunky, certainly not user-interfac'ie/dynamic, but it works). http://resources.arcgis.com/en/help/main/10.1/index.html#/An_overview_of_the_Attachments_toolset/00170000015m000000/ Rather than post all of this messy code, just know that I pretty much copied-and-pasted the AddAttachment_management sample into my def() and it just works.
... View more
04-16-2013
11:22 AM
|
0
|
0
|
741
|
|
POST
|
I see in the docs for the da.updateCursor that it says: "Raster fields are not supported." Check. Anyone know how to update a Raster Field? Thanks for any comments or suggestions!
... View more
04-16-2013
09:39 AM
|
0
|
0
|
741
|
|
POST
|
I couldn't find any immediate information on loading a raster field of a FGDB Feature Class. Didn't attempt to just issue it on an updateCursor yet as I wasn't sure if there are other methods. But this is pretty straight forward -- just need to Load a .png into a Raster field of a FC. Thanks!
... View more
04-16-2013
09:15 AM
|
0
|
2
|
963
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|