|
POST
|
To expand on what James Crandall posted and accomplish your second task of getting the total area for all features in the shapefile, you could use a SearchCursor like Darren Wiens mentioned, or the Summary Statistics that you mentioned yourself. If you go with the Summary Statistics, you could use in-memory workspace for the output table, but you'd still have to use a SearchCursor to get the values out of it, so you might as well just do your own adding. import arcpy
fc = r'PathToLayer\LayerNamel'
field_names = [f.name for f in arcpy.ListFields(fc)]
if 'Area' not in field_names:
arcpy.AddField_management(fc, "Area", "FLOAT", 6, 3)
arcpy.CalculateField_management(
fc,
"Area",
"!SHAPE.area!",
"PYTHON_9.3",
)
fcAreas = [row[0] for row in arcpy.da.SearchCursor(fc, ["Area"])]
print sum(fcAreas) EDIT: After thinking about this, it might actually be better if you used Summary Statistics instead of calculating the field because if the geometry of the features change, the Area field will not get updated unless you run this code again. The values in the Area field could be misleading.
... View more
04-08-2015
02:12 PM
|
2
|
7
|
4230
|
|
POST
|
It looks like you spent a lot of time formatting your Python code to highlight syntax like the IDE. There's a handy way to let the GeoNet forums do that for you! Posting Code blocks in the new GeoNet
... View more
04-08-2015
01:41 PM
|
0
|
1
|
4230
|
|
POST
|
I have two questions for you, Richard: Does using OID@ for the field name let the cursor dynamically find the ObjectID field even if it isn't called ObjectID? Could you explain the first colon in the list comprehension on line 8? (row[0:])
... View more
04-08-2015
01:28 PM
|
0
|
3
|
4535
|
|
POST
|
I think you can mark your own reply as correct if it includes the full solution from various sources and the correct attribution is given to the original authors. Anyone else who stumbles upon this thread with a similar issue would want quick access to the final solution, not just which one helped the most in getting there. Ideally the reply marked as correct would have all of these things.
... View more
04-07-2015
03:49 PM
|
1
|
2
|
2063
|
|
POST
|
After working with Esri support (thanks Jing!) I have some more information to share. To add a new entry to ST_SPATIAL_REFERENCE Table, you can create or import a feature class with the spatial reference you wanted to the geodatabase. Make sure you use ST_Geometry as the Configuration Keyword. By default, if you choose Default as the Configuration Keyword, it will create a ST_Geometry type feature class. If you know a feature class that is using the desired SRID, you can import this feature class to your 10.0 geodatabase, there will be a new record account for this SRID in the ST_SPATIAL_REFERENCE Table. If you want to create a feature class to generate the desired SRID, you can following the following steps For example the SRID you wanted is 4152, you can run "select * from ST_COORDINATE_SYSTEMS where id=4152;" in Oracle. The returned Type field is Geographic, so when we select the coordinate system for our new feature class, you will go to Geographic Coordinate Systems. The Description Colum will give us a clue on where to find this coordinate system. In ArcCatalog, right click on the database connection > New > Feature class > Provide Name, then click Next > Expand Geographic Coordinate Sytems, Then North America, select NAD 1983 HARN, then click Next > Next > Select Default as the Configuration Keyword, click Next > Finish Check ST_SPATIAL_REFERENCE Table, you will see a new record show up in there. Feel free to delete the feature class. Delete the feature class will not delete the record in the ST_SPATIAL_REFERENCE Table This worked in ArcSDE 10.0 but I haven't tested anything else. I'm assuming from looking at the documentation that it works the same. The big thing to keep in mind here is that SRID is just an arbitrary number for that row in the ST_Spatial_References table. It means nothing outside of that table. The SRID doesn't have to be the same as the CS_ID. So when we upgrade to 10.2.2, we will have to remember to check the SRIDs in the table to see if they changed and alter our SQL views accordingly. I followed the steps to create a new feature class in SDE with the coordinate system I wanted (GCS_North_American_1983_HARN - 4152). Our final SQL for 10.0 uses 57 for SRID, which only applies to our particular SDE database. SELECT EID,
ST_X(sde.st_transform(SHAPE, 57)) as LONGITUDE,
ST_Y(sde.st_transform(SHAPE, 57)) as LATITUDE
FROM LIS.ADDRESS_PNT;
... View more
04-07-2015
03:35 PM
|
1
|
0
|
1487
|
|
DOC
|
This is the first thing I've seen about multithreaded processing with Python. Thanks for the post!
... View more
04-03-2015
01:19 PM
|
1
|
0
|
14753
|
|
POST
|
ArcGIS REST API - Remove User ArcGIS for Server (Windows) - Scripting with the ArcGIS REST API Sorry, I haven't done this before so getting the info is as much as I know. Anything more and I'm learning right with you. Here's some other useful information I've found... ArcGIS Server Administration Toolkit - 10.1+ arcpy/AdministeringArcGISServerwithPython_DS2014 · GitHub
... View more
04-03-2015
09:49 AM
|
3
|
4
|
2478
|
|
POST
|
I think your workspace has to be a geodatabase, not an MXD. Also, the point variable is the name your input feature class (not a the layer name from an MXD). EDIT You may also need to change the strings in the if statement from "True" to "TRUE" and "False" to "FALSE" so it matches your data.
... View more
04-03-2015
09:36 AM
|
2
|
0
|
1724
|
|
POST
|
for row in cursor:
if row[1] == 'True':
x = row[0]
elif row[1] == 'False':
list.append(x) Wouldn't that only get the last row that is TRUE? x gets replaced each time it's true and only gets appended to list when it finds a FALSE. Seems like you'd have to do something like for row in cursor:
if row[1] == 'True':
list.append(row[0])
elif row[1] == 'False':
break
... View more
04-03-2015
08:45 AM
|
2
|
13
|
3474
|
|
POST
|
That's not reliable because you cannot guarantee the order in which the rows are returned. Could you describe in more detail why you only want to copy rows until it finds a FALSE?
... View more
04-03-2015
08:32 AM
|
1
|
1
|
3474
|
|
POST
|
There is a lot of little things wrong with your code. Before I try creating new code, I have a question. It looks like you have a second condition you are using to filter your table, could you please describe that? Right now I see the only thing you check is that the Condition field is equal to "TRUE". What criteria did you use to eliminate FID 4 and 5?
... View more
04-03-2015
08:21 AM
|
2
|
3
|
3474
|
|
POST
|
I didn't realize this is was something that Esri designed. Thanks for the clarification.
... View more
04-03-2015
07:51 AM
|
0
|
0
|
1462
|
|
POST
|
I don't know if I follow exactly what you're getting at here, but I think you need to actually return something from your method; probably parameters. Right now your changing the .enabled and .value attributes of parameters[1], but those changes are only in the local variables for the method, they don't go anywhere. Try this at the end. return parameters Then I'm assuming you use parameters as input for some other process or method, in which case it should have the new properties you set in updateParameters(). Thank you, Adam Cox, for the clarification.
... View more
04-02-2015
04:41 PM
|
0
|
2
|
1462
|
|
POST
|
I try to use the r string prefix with path names so it escapes the backslashes. mypath = r"C:\temp\myfile.mxd" Or you can construct file paths with os.path mydrive = "c:"
myfolder = "temp"
myfile = "mapdoc.mxd"
mypath = os.path.join(mydrive, myfolder, myfile)
... View more
04-02-2015
11:47 AM
|
3
|
1
|
2578
|
|
POST
|
Glad you got it working. Is there a database trigger set up on any of the tables? That could slow down the processing with lots of activity. You could also try scripting your process with Python (like you originally mentioned) using Calculate Field. Python might be able to power through because there is no UI (ArcMap) involved. Still might have to wait for everyone to stop editing the version though. May also be worth investigating using different versions for everyone; that's what they're there for.
... View more
04-02-2015
11:39 AM
|
1
|
0
|
1602
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-23-2025 03:53 PM | |
| 1 | 3 weeks ago | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM | |
| 1 | 12-01-2025 06:19 AM |