POST
|
When calling list fields you essentially return a copy of the field in the form of the field object, so when modifying the field alias you are modifying the field object not the actually field in the database or layer. There has been a bug logged to update the documentation stating this: NIM068561: Update the documentation for the fieldalias property and any other related properties that are listed as read and write. It should clarify that changing the property updates the field object only, it does not make an edit on the geodatabase. One workaround, though probably not ideal, I found was using the 'Field Mapping' option in the Feature Class to Feature Class tool. You can use this to update the field alias, then copy the new feature class replacing the old one. Ex: env.overwriteOutput = True
fc = "townships"
arcpy.FeatureClassToFeatureClass_conversion(fc, r"c:\temp\python\test.gdb", "Townships2", "",
"NAME \"Township Name\" true true false 100 Text 0 0,First,#,C:\\temp\\python\\Test.gdb\\townships,NAME,-1,-1")
arcpy.Copy_management("townships2", "townships")
arcpy.Delete_management("townships2")
... View more
06-06-2011
11:15 AM
|
0
|
0
|
644
|
POST
|
The previous code will only work for polyline feature classes. I will have to see if there is a way to do this for polygon feature classes.
... View more
06-03-2011
09:52 AM
|
0
|
0
|
672
|
POST
|
If an arc exists, it's centroid and true centroid will be different values. Therefore you can search each feature class to see if any centroids do not match the true centroids. Ex: lstFCs = arcpy.ListFeatureClasses("*", "Polyline")
for fc in lstFCs:
rows = arcpy.SearchCursor(fc)
print fc
for row in rows:
type = row.Shape
geom = str(type.centroid.X)
truegeom = str(type.trueCentroid.X)
if geom != truegeom:
print row.ObjectID
del row, rows This will print the feature class and the OBJECTID of any arcs within that feature class.
... View more
06-03-2011
08:50 AM
|
0
|
0
|
672
|
POST
|
I would try using the commands outside of the Raster Calculator. Ex: import arcpy
from arcpy import sa
from arcpy.sa import *
arcpy.CheckOutExtension("spatial")
forest = r"c:\test.gdb\forest"
forest_slope = arcpy.sa.Slope(forest, "DEGREE", "1")
sin = arcpy.sa.Sin(forest_slope)
divide = arcpy.sa.Divide(sin, 57.2958)
multiply = arcpy.sa.Times(divide, 200)
multiply.save(r"c:\test.gdb\forest_slope_cost")
... View more
06-01-2011
08:55 AM
|
0
|
0
|
1713
|
POST
|
I am using Flex 2.2 and I'm having an issue where a feature service in the web application will not update after a delete or attribute change has occurred. If a feature is added, the feature service will update correctly in the web application. For example, I open a flex app with a feature service. I have the same feature service being consumed on my mobile device using ArcGIS Mobile. I'll collect a feature using ArcGIS Mobile and then post the edit back to database. Next I pan/zoom around the flex app and the feature service updates dynamically and I can see the feature. However, if I delete a feature or update attributes of an existing feature using ArcGIS Mobile, post changes back to database, and then pan/zoom around the changes are not reflected. I have to refresh the entire flex app. After doing so the changes are reflected. The same happens no matter which client I'm using to update the service. For example if I make a delete/update to the feature class in ArcMap I have to refresh the flex app. I tried setting 'mode' equal to 'onDemand' in the config file, but this did not make a difference. Has anyone experienced this? Thanks!
... View more
05-20-2011
12:10 PM
|
0
|
2
|
634
|
POST
|
What user are you connecting to the database as? Is this user an administrator on the SQL Server machine? I was able to reproduce this behavior. I logged onto my machine as "Joe", created a connection SDE and created a feature called "Vector.Joe.Parcels". I then logged off of my machine and logged back on as an administrator. When I connect to SDE I can see the feature class, "Vector.Joe.Parcels" because I am an administrator. When I attempt to run my script I receive the error that the feature class does not exist. The reason being is that it is now using my current windows user, the administrator, and is therefore looking for "Vector.DBO.Parcels". Unless you are connected to the database as the feature class owner, you will need to specify the full feature class name.
... View more
05-13-2011
11:09 AM
|
0
|
0
|
438
|
POST
|
You can specify a query with the arcpy.UpdateCursor. The update will only update records that are returned from this query. Ex:
fc = "parcels"
rows = arcpy.UpdateCursor(fc, "Area1 = 10")
for row in rows:
row.Area2 = 200
rows.updateRow(row)
... View more
05-13-2011
03:37 AM
|
0
|
0
|
446
|
POST
|
1. Did you re-synch all the database authenticated logins after restoring the database onto the new machine: http://resources.arcgis.com/content/kbase?fa=articleShow&d=29672 2. Did you restore to a different version of SQL Server (ie 2005 to 2008)? If so, check to make sure the compatibility level updated: http://resources.arcgis.com/content/kbase?fa=articleShow&d=32979
... View more
05-12-2011
12:22 PM
|
0
|
0
|
438
|
POST
|
The 'mxd' variable will place a lock on the MXD. Without deleting this variable, the lock will remain. For example, you run a python script that makes some change to an MXD and you don't delete the 'mxd' variable. Then you open this MXD in ArcMap, make another change and then try saving. You will receive an error that it is in use.
... View more
05-12-2011
12:16 PM
|
2
|
0
|
1259
|
POST
|
What RDBMS are you using (i.e. Oracle, SQL Server, PostgreSQL....)?
... View more
05-12-2011
05:58 AM
|
0
|
0
|
243
|
POST
|
I have added to the code to capture the extent ID (it can fill in filename as 'mxd' and not sure how to capture scale) but it is giving errors in identifying the x'th entry in to the list -it prints just the x'th character. Also it's not clear where to put a print statment to give feedback that the program is working on the 2,3,4th etc mxd file. You will need to append the extent ID to a list. Ex: for el in arcpy.mapping.ListLayoutElements(mxd2, "DATAFRAME_ELEMENT"):
ExtentIDStore = str(el.name)
list2.append(ExtentIDStore) Then you can use print statement for the list: print list2[0] I also notice that it loops first through the mxd's creating extent 1, then loops through creating extent 2 etc. I was initially thinking that it opened the first mxd, cycled through and created all the extent polygons and then opened the next mxd and created the extents. You can code it to do it this way, but the end result will be the same. Also it's not clear where to put a print statement to give feedback that the program is working on the 2,3,4th etc mxd file. You can execute a print statement at the beginning of the first 'for' loop:
for mxd in mxdList:
mxd2 = mapping.MapDocument(mxd)
print mxd However, the same MXD name will be printed multiple times since the code loops through each MXD multiple times.
... View more
05-12-2011
04:45 AM
|
0
|
0
|
907
|
POST
|
It appears that the feature datasets were not empty. Deleting table entries within SQL Server Management Studio is a last resort. When it comes to feature classes, there are a slew of other table entries/tables that need to be deleted as well. Attempting to delete other table entries can seriously corrupt your database. I would recommend restoring your database backup and contacting tech support. They will be able to determine why the feature datasets are still existing even though the database has been deleted. Also, I would recommend using a single geodatabase model in the future. I find they are much easier to maintain.
... View more
05-11-2011
10:47 AM
|
0
|
0
|
308
|
POST
|
You can do this using the UpdateCursor. Ex: table = "XY"
rows = arcpy.UpdateCursor(table)
for row in rows:
if row.field1 > row.field2:
row.Num = row.field1
elif row.field1 < row.field2:
row.Num = row.field2
rows.updateRow(row) del row, rows
... View more
05-11-2011
08:29 AM
|
0
|
0
|
394
|
POST
|
You can delete the empty feature datasets within SQL Server Management Studio. Before doing so be sure to make a database backup of your SDE geodatabase. After the backup is created you can run the following query: use SDE delete from sde.GDB_ITEMS where Name = 'TroutCreek.DBO.Model'
... View more
05-11-2011
08:03 AM
|
0
|
0
|
308
|
Title | Kudos | Posted |
---|---|---|
1 | Tuesday | |
1 | Monday | |
1 | Monday | |
3 | 12-15-2020 04:55 PM | |
6 | 04-26-2024 10:15 AM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|