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()
def shapeToPoints(a_shape,theType,arcpy): ''' pnts = shapeToPoints(a_shape, shape type, geoprocessor) Purpose: Converts a shape to points, the shape and its type are passed by the calling script Requires: def pntXY(pnt) ''' outList=[] part_num = 0 part_count = a_shape.partCount if theType == "Multipoint": #Multipoints while part_num < part_count: pnt = a_shape.getPart(part_num) XY = pntXY(pnt) if XY not in outList: outList.append(XY) part_num += 1 else: #Poly* features while part_num < part_count: #cycle through the parts a_part = a_shape.getPart(part_num) pnt = a_part.next() while pnt: #cycle through the points XY = pntXY(pnt) if XY not in outList: outList.append(XY) pnt = a_part.next() if not pnt: #null point check (rings/donuts) pnt = a_part.next() if pnt: XY = pntXY(pnt) if XY not in outList: outList.append(XY) part_num += 1 return outList
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.