|
POST
|
I used to do a method that used a spatial join but after upgrading to 10 it started to fail repeatedly without returning any errors. It was as if while loading the data into the parcels a sys.exit() signal was sent. The whole shell restarted instead of a normal crash regardless of what error catching I tried to include. I think it may save time to loop once through the parcels for each 'i' instead of the other way around. Im testing that now. I may consider the dictionaries as an option if this doesnt work. The reason I am using networked data is that it is on an SDE and I would rather not have to have the code reconcile the FGDB with the SDE at the start of each run though.
... View more
12-01-2010
09:25 AM
|
0
|
0
|
1482
|
|
POST
|
Well you can try reading the geometry of the line to get the coords of the vertexs and use those to find the angle of the line. Then a point object can be created along that line wherever you would like and use that as an input for arcpy.SplitLineAtPoint_management().
... View more
11-30-2010
09:21 AM
|
0
|
0
|
1208
|
|
POST
|
Well the biggest problem I was having was that I assumed it was more complicated than it is. To get the geometry object for a row you only have to set a variable equal to the value of the shape field. Then you can use any of the geometry functions available to that geometry type. This is a simple example that iterates over my parcels and looks for a polygon in the FLU layer that its centroid is inside of.
parcel_desc=arcpy.Describe("parcels") #describe the parcels and get the shape field name
parcel_shapefield=parcel_desc.ShapeFieldName
flu_desc=arcpy.Describe("flu")#describe the flu and get the shape field name
flu_shapefield=flu_desc.ShapeFieldName
parcel_cursor=arcpy.UpdateCursor("parcels")
for row in parcel_cursor: #iterate over the parcels
parcel_row_shape=row.getValue(parcel_shapefield) #get the geometry object
centroid=parcel_row_shape.centroid #get the centroid from the geometry object
flu_cursor=arcpy.SearchCursor("flu")
for flu_row in flu_cursor: #iterate over the flu
flu_row_shape=flu_row.getValue(flu_shapefield) #get the geometry object
if centroid.within(flu_row_shape)==True: #compare the two geometries
print "RENUM: %s FLU: %s" % (parcel_row.A1RENUM, flu_row.FLU_CODE) #do some junk with the two rows
del flu_cursor
del parcel_cursor
... View more
11-30-2010
04:41 AM
|
0
|
0
|
1482
|
|
POST
|
I have figured it out! Will post code later today once I get it nailed down.
... View more
11-29-2010
09:04 AM
|
0
|
0
|
1482
|
|
POST
|
Well you can iterate over the feature classes, use a cursor to get a set of the values in the subtype field iterate over the values in the set select by the value featureclasstofeatureclass the selection.
... View more
11-29-2010
04:13 AM
|
0
|
0
|
962
|
|
POST
|
This sounds like a job for geometry objects. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Geometry/000v00000095000000/ I cant help much beyond that as I am just learning how to use these as well.
... View more
11-29-2010
04:10 AM
|
0
|
0
|
435
|
|
POST
|
This sounds like a job for geometry objects. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Geometry/000v00000095000000/ I cant help much beyond that as I am just learning how to use these as well.
... View more
11-29-2010
04:09 AM
|
0
|
0
|
1208
|
|
POST
|
I dont like pythonwin. I find the GUI a bit irriatating for some reason. I use Komodo now. You can have multiple scripts open in tabs. Handy if you are working on a few things at the same time.
... View more
11-24-2010
11:31 AM
|
0
|
0
|
2007
|
|
POST
|
After some playing around I know how to make a point-geometry object. All you do is get the centroid from shape field. parceldesc=arcpy.Describe('parcels')
parcelShapeField=parceldesc.ShapeFieldName
parcel_cursor=arcpy.UpdateCursor('parcels')
for parcel_row in parcel_cursor:
parcel_row_shape=parcel_row.getValue(parcelShapeField) #
centroid=parcel_row_shape.centroid and to compare that to another geometry I just need to do centroid.crosses(other geometry object) I dotn know how to get a polygon geometry from a row in a way taht is useful though. I can get a convex hull and an extent envelope but neither are helpful.
... View more
11-24-2010
10:10 AM
|
0
|
0
|
1482
|
|
POST
|
I have Leaning Python by O'Reilly. The 4th Edition covers Python 2.6 and 3.0. ArcGIS v10 uses 2.6. Also, #Python on irc.freenode.net is a great resource as well. Dont be daunted by the stuff they talk about. I ask noobish things all the time and they always take time to answer me. I agree that a class is good though. I got a class on a dvd from Keck and Wood for like 100 bucks thats a good intro to python for ArcGIS. EDIT: Also, all good python skill starts with a viewing of Monty Python's Quest for the Holy Grail. It puts you in the proper mind set.
... View more
11-24-2010
04:55 AM
|
0
|
0
|
2007
|
|
POST
|
Thanks Chris. I think this is what I want to do. Granted this is extremely metaish code lol.
For update_row in update_cursor:
geo_update_row=create a geometry object for this row's label point
for search_row in search_cursor:
geo_search_row=create a geometry object for this row
if geo_update_row.crosses(geo_search_row) == True:
update_row.something = search_row.something
update_cursor.updaterow(update_row)
del geo_search_row
del geo_update_row
Thats the general idea. Now I just have to learn geometry objects.
... View more
11-24-2010
04:38 AM
|
0
|
0
|
1482
|
|
POST
|
I know I can get the centroid for a row from the geometry object and I know in theory that I can use that to intersect with another FC and grab some of its values. I just dont know how :p.
... View more
11-23-2010
07:08 AM
|
0
|
19
|
4891
|
|
POST
|
arcpy.AddJoin() This requires you to make a feature layer of your base table. the joined table doesnt need to be a feature layer or table view arcpy.CopyFeatures() This will copy your feature layer that you just joined to to a shp.
... View more
11-23-2010
07:01 AM
|
0
|
0
|
671
|
|
POST
|
Im not sure about using the csv library to read, but if you open a file straight up with open(file,'r') and split on the ',' like Chris said you should get a list of strings regardless of whats in the strings. As for copying the file to a backup folder, you can use shutil.copyfile(source, destination) and then os.remove(source) which will copy your file and then delete the old one. I would not go into opening excel and mucking with win32com if you can avoid it.
... View more
11-22-2010
01:06 PM
|
0
|
0
|
2452
|
|
POST
|
WOO we win! Now lets not screw this up or we may not get the next thing we want. 😄
... View more
11-22-2010
05:20 AM
|
0
|
0
|
825
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-03-2015 11:33 AM | |
| 1 | 09-23-2015 10:50 AM | |
| 1 | 12-14-2015 10:42 AM | |
| 1 | 12-14-2015 01:10 PM | |
| 1 | 12-04-2015 08:19 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|