|
POST
|
Hope you know some Python. There are a few ways of determning adjacency in ArcGIS that I use: 1. Use a SelectByLocation to select polygons that touch/intersecct/share line segment with/etc. 2. Use the PolygonToLine tool. The output lines will have fields indicating the OBJECTID of the polygon to the right and left of the arc... I mean line (just like a good ole' coverage .aat)!
... View more
05-24-2011
08:35 AM
|
0
|
0
|
2891
|
|
POST
|
How about using .centroid? Here is a v93 example. fc = r"D:\csny490\temp\road_pnts.shp"
pntDict = {}
dsc = gp.describe(fc)
shapeFieldName = dsc.shapefieldname
oidFieldName = dsc.oidfieldname
searchRows = gp.searchcursor(fc)
searchRow = searchRows.next()
while searchRow:
shapeFieldValue = searchRow.getvalue(shapeFieldName)
oidFieldValue = searchRow.getvalue(oidFieldName)
centroidValue = shapeFieldValue.centroid
xValue = centroidValue.x
yValue = centroidValue.y
if (xValue,yValue) in pntDict:
pntDict[(xValue,yValue)].append(oidFieldValue]
else:
pntDict[(xValue,yValue)] = [oidFieldValue]
searchRow = searchRows.next()
... View more
05-24-2011
08:23 AM
|
0
|
0
|
2482
|
|
POST
|
How about using .centroid? Here is a v93 example. fc = r"D:\csny490\temp\road_pnts.shp" pntDict = {} dsc = gp.describe(fc) shapeFieldName = dsc.shapefieldname oidFieldName = dsc.oidfieldname searchRows = gp.searchcursor(fc) searchRow = searchRows.next() while searchRow: shapeFieldValue = searchRow.getvalue(shapeFieldName) oidFieldValue = searchRow.getvalue(oidFieldName) centroidValue = shapeFieldValue.centroid xValue = centroidValue.x yValue = centroidValue.y if (xValue,yValue) in pntDict: pntDict[(xValue,yValue)].append(oidFieldValue] else: pntDict[(xValue,yValue)] = [oidFieldValue] searchRow = searchRows.next()
... View more
05-24-2011
08:22 AM
|
0
|
0
|
2482
|
|
POST
|
You need to provide an index to tell the .getpart() method what part you want to get. Get part is the way to deal with possible multipart shapes. If you are SURE your features are singlepart, then .getpart(0) will do the trick. Otherwise you need to loop through the parts as Dan's code is doing.
... View more
05-24-2011
06:28 AM
|
0
|
0
|
2482
|
|
POST
|
On the flip side... I see more and more computer resources being devoted to the "overhead" bells and whistles of some recent geeprocessing enhancements. Things like results/history, large tiling algorithms, and progress bars don't make the tools run faster (if anything the latter). Some of us actually would like a more bare-bones geoprocessing engine that is optimized for speed and performance rather than a "rich user experience". For example, I have a Python script that calculates vector polygons based on a series of cost-distance raster overlay thingamajiggers... It takes only a few seconds to write a shapefile out... However, I have 50,000 rasters to run through! So even a 1/4 second speed improvement (maybe getting rid of the results feature?) would be very welcome!!! Used to be in Workstation that when you converted a grid to a shapefile there was only three files (.shp, .dbf, .shx) - now in v10 a shape files has like seven or eight associated files (no thanks I don't want the .cpg file!). I wish there was a way to turn off all the bells and whistles!!!
... View more
05-23-2011
02:38 PM
|
0
|
0
|
2296
|
|
POST
|
Does arcgisscripting even work with v10.0? It does if you use the default version of Python that is auto-installed with v10 (and you don't try to monkey with or upgrade it). Although I think(?) in this case all you have to do is change "gp" to "arcpy": selectionCount = len(arcpy.describe(lyr).fidset.split(";"))
#or
selectionCount = int(arcpy.GetCount_management(gp.describe(lyr).catalogpath).getoutput(0)) - int(arcpy.GetCount_management(lyr).getoutput(0))
... View more
05-18-2011
03:42 PM
|
0
|
0
|
2218
|
|
POST
|
Two methods I use (v9.3 code BTW, but easy to convert to arcpy): For actual selections (must be a selection made by SelectByAttributes or SelectByLoactions and not a definition query): selectionCount = len(gp.describe(lyr).fidset.split(";")) But for layers that might have a differenet feature count than the actual feature class they are based off (via a definition query or some SQL used by the MakeFeatuerLayer tool): selectionCount = int(gp.GetCount_management(gp.describe(lyr).catalogpath).getoutput(0)) - int(gp.GetCount_management(lyr).getoutput(0))
... View more
05-18-2011
08:39 AM
|
0
|
0
|
2218
|
|
POST
|
How about this:
arcpy.env.overwriteOutput = True
arcpy.MakeFeatureLayer_management(copy_ft, "in_lyr")
boundary_file_list = arcpy.ListFeatureClasses()
for boundary_file in boundary_file_list:
arcpy.SelectLayerByLocation_management ("in_lyr", "INTERSECT", boundary_file)
arcpy.CopyFeatures_management("in_lyr", output_ft)
... View more
05-05-2011
09:13 AM
|
0
|
0
|
1723
|
|
POST
|
You could probably also do this (merge two features into one) using an update cursor.
... View more
05-04-2011
08:28 AM
|
0
|
0
|
3954
|
|
POST
|
hope that it'll be a bug that is fixed quickly :rolleyes:
... View more
04-28-2011
03:39 PM
|
0
|
0
|
1948
|
|
POST
|
It would seem logical (but perhaps incorrect) to assume that the row(s) you are inserting will always have ordered and consecutive OID values relative to any existing OID values in the table. So, if inserting rows into an empty table, logically your fist inserted row would be OID = 1 (OID = 0 if a shapefile/dbf). Similarly, if inserting rows into a table with existing records (last existing one ending in OID = 222), then your first inserted row would be OID = 223. Note that the insertcursor method does not have a sort order parameter, so no chance for that messing with an otherwise orderly universe. So maybe a faster/better work around would be prior to running an insert cursor, run a searchcursor to grab the largest existing OID value, and in your insertcursor, start counting at that number.
... View more
04-28-2011
03:28 PM
|
0
|
0
|
1948
|
|
POST
|
BTW: this is not a new issue: http://forums.esri.com/Thread.asp?c=93&f=1729&t=293522
... View more
04-28-2011
03:11 PM
|
0
|
0
|
1948
|
|
POST
|
Nope, as far as my attempts have gone, you can't do it (retrieve an insert cursor value like you can with an update cursor). So a v9.3 example: insertRows = gp.insertcursor(myTable)
insertRow = insertRows.newrow()
insertRow.MYFIELD = "my value"
print insertRow.MYFIELD #THIS BOMBS! It's a bug.
... View more
04-28-2011
02:46 PM
|
0
|
0
|
1948
|
|
POST
|
Question: Do you want the points like this
#aligned like a square (not equadistant)
+ + + +
+ + + +
+ + + +
+ + + +
or like this: #aligned like a tringle/diamond (equadistant)
+ + + +
+ + + +
+ + + +
+ + + + If it's the former, just use the fishnet tool (and convert the polygon centroids to points using the FeatureToPoint tool), or as Darren suggests, use a raster/vector hybrid approach If it's the latter (which is what we use BTW to lay out our inventory plots), I think I have some code that I can borrow from someone. Let me know, and I'll try to post it (if they let me).
... View more
04-26-2011
03:13 PM
|
0
|
0
|
2466
|
|
POST
|
The * just means it's indexed - no cause fro alarm...
... View more
04-22-2011
08:08 AM
|
0
|
0
|
353
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|