|
POST
|
Here is an example on how you can do this: Codeblock: def update(field):
if field[0] in str(range(0, 9)) or field[0] == '#':
pass
else:
return field Field= update(!TAG!) Be sure 'Python' is checked on at the top of the field calculator. Here is a screen shot. [ATTACH=CONFIG]16236[/ATTACH]
... View more
07-19-2012
03:12 AM
|
0
|
0
|
6064
|
|
POST
|
Are the text and integer values separated by a space? You can most likely use the .split command to do this. However, this will be a little more difficult if any of the river names contain spaces. Are all the integer values the same length (i.e. 100, 220, 354, etc)? It may be best to provide a screen shot of how the field looks in your attribute table.
... View more
07-19-2012
02:41 AM
|
0
|
0
|
6064
|
|
POST
|
Hi Cameron, Yes, that is a fair assessment. The 10.1 help also provides examples on how you can create a python script to update your database statistics. Updating database statistics can be an I/O-intensive operation, so you might want to do this while most users are logged out of the database. Having Windows Task Scheduler execute a script is the perfect solution for this.
... View more
07-19-2012
02:35 AM
|
0
|
0
|
1211
|
|
POST
|
The Tool Validator will successfully convert the field names to strings. Try the following: 1. Set the data type for the Dimensions-Felder parameter to 'String' 2. Update the Tool Validator with the following code: def updateParameters(self): if self.params[0].value: list = [] lstFields = arcpy.ListFields(str(self.params[0].value)) for field in lstFields: list.append(field.name) list.remove(str(self.params[1].value)) self.params[2].filter.list = list return
... View more
07-18-2012
02:55 AM
|
0
|
0
|
3220
|
|
POST
|
Can you attach a screen shot of your Tool Validator tab, and a screen shot of your Parameters tab? Also, are you working with Tables or Feature Classes?
... View more
07-18-2012
02:22 AM
|
0
|
0
|
3220
|
|
POST
|
Hi Karsten, Here is an example on how you can do this by updating the updateParameters function: def updateParameters(self):
if self.params[0].value:
list = []
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
for layer in arcpy.mapping.ListLayers(mxd, "", df):
list.append(layer.name)
list.remove(str(self.params[0].value))
stringFilter = self.params[1].filter
stringFilter.list = list
return For the multivalue parameter, you will want to set the Data Type to 'String' within the Parameters tab.
... View more
07-17-2012
08:19 AM
|
0
|
0
|
3220
|
|
POST
|
Is the NULL value within the feature class's numeric field, or the database table's numeric field? You can have NULL values within a feature class's numeric field as long as 'ALLOW NULL VALUES' is set to YES.
... View more
07-17-2012
04:33 AM
|
0
|
0
|
2792
|
|
POST
|
Hi Jamie, Take a look at the following tutorial on Publishing Geoprocessing Services.
... View more
07-16-2012
10:23 AM
|
0
|
0
|
622
|
|
POST
|
I was able to pass the error when I used 'arcpy.Delete_management' to delete the File Geodatabase and a lock was present. See if this will work for you. Here is an example: import os, logging, arcpy OldFileGDBPath = r"C:\temp\python\Old.gdb" FileGDBPath = r"C:\temp\python\New.gdb" try: # Delete Old File Geodatabase arcpy.Delete_management(OldFileGDBPath) print "Deleting Old File Geodatabase..." logging.info("Deleted %s" %(OldFileGDBPath)) # Rename New File Geodatabase arcpy.Rename_management(FileGDBPath, OldFileGDBPath) print "Renaming New File Geodatabase..." logging.info("Renamed %s %s" %(FileGDBPath, OldFileGDBPath)) except Exception as e: print e print "passing error" pass
... View more
07-16-2012
09:05 AM
|
0
|
0
|
1599
|
|
POST
|
Are any ArcGIS Server services accessing data within the File Geodatabase you are trying to delete? This will cause a lock and prevent you from deleting the geodatabase. Could replication replace the copying of feature classes to a new File Geodatabase? You could then perform a synchronization rather than a copy/paste of feature classes.
... View more
07-16-2012
07:56 AM
|
0
|
0
|
1599
|
|
POST
|
Hi Mike, Are you running ArcGIS 10.1, yet? ArcGIS 10.1 added a new data access module (arcpy.da). The previously existing cursors (that are still listed under arcpy) are still functional and valid; however, the new arcpy.da cursors include significantly faster performance. I tested the new arcpy.da.UpdateCursor vs the older updateCursor and CalculateField_management. The new arcpy.da.UpdateCursor provided faster performance than the other two. For the error you are receiving, I would recommend incorporating print statements within your script and print each feature class you are updating. That way you can pinpoint the problematic feature class when the error occurs. The OBJECTID reported in the pop-up will tell you the specific feature within the feature class.
... View more
07-16-2012
03:37 AM
|
0
|
0
|
2792
|
|
POST
|
Try adding arcpy.RefreshTOC() and arcpy.RefreshActiveView to your script. Ex:
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.mapping.MoveLayer(df, "Contours 10m - MARANOA REGIONAL", "SPOT 2009 Image Date", "BEFORE")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
mxd.save()
del mxd Also, are you executing the python script within ArcMap?
... View more
07-16-2012
02:51 AM
|
0
|
0
|
2538
|
|
POST
|
Here is an example on how to create an XY event layer from your SQL table and then reproject the coordinates from decimal degrees to feet: import arcpy
from arcpy import env
env.workspace = r"Database Connections\PUBS.sde"
table = "pubs.dbo.XY"
arcpy.MakeXYEventLayer_management(table, "X", "Y", "XY_layer", r"C:\data\test.gdb\Airports_WGS84")
rows = arcpy.SearchCursor("XY_layer", "", r"C:\data\test.gdb\Airports_NAD83_feet")
for row in rows:
print row.shape.centroid.X, row.shape.centroid.Y
del row, rows The XY event layer is created with the same coordinate system as the Airports_WGS84 feature class. In this case it is geographic. Then, the XY coordinates are returned based off of a NAD83_feet coordinate system using the SearchCursor function and printed out. If you are looking to update the SQL table with these values, SDE will need to be installed and the table will need to be registered with the geodatabse. You can then use the 'UpdateCursor' to update new fields.
... View more
07-09-2012
10:12 AM
|
0
|
0
|
1888
|
|
POST
|
Is your SQL database spatially enabled (SDE installed)? Or was the table created within SQL Server, and the database is not spatially enabled?
... View more
07-09-2012
06:33 AM
|
0
|
0
|
1888
|
|
POST
|
The problem before was that the dictionary was not sorted correctly. You can do this one of two ways. 1. Using an a data dictionary with an updateCursor: table = "Basins.dbf" fc = "Watersheds.shp" fcDict = {} rows = arcpy.SearchCursor(fc, "", "", "", "ID A") for row in rows: fcDict[row.ID] = row.Value del rows, row x = 0 rows = arcpy.UpdateCursor(table, "", "", "", "ID A") for row in rows: if row.ID == sorted(fcDict) : row.Value = fcDict[row.ID] rows.updateRow(row) print "Successfully updated row" x += 1 del rows, row 2. Create a Join and then calculate values using the Field Calculator: table = "Basins.dbf" fc = "Watersheds.shp" arcpy.MakeTableView_management(table, "Basins_view") arcpy.AddJoin_management("Basins_view", "ID", fc, "ID") arcpy.CalculateField_management("Basins_view", "basins.Value", "[watersheds.Value]")
... View more
07-03-2012
11:44 AM
|
0
|
0
|
2622
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 4 | 05-07-2020 05:14 PM | |
| 1 | 03-25-2026 04:16 AM | |
| 1 | 03-16-2026 01:00 PM | |
| 1 | 12-22-2025 10:39 AM |
| Online Status |
Online
|
| Date Last Visited |
an hour ago
|