def __init__(self, zones, zoneIDFld, method, location, **kwargs): zones = common.toFeatureClass(common.checkFile(zones)) if not location: location = common.location(zones) Converter.__init__(self, location, **kwargs) self.zones = zones self.zoneMapper = ODFieldMapper(self.zones) self.zoneMapper.addIDField(zoneIDFld, [common.NEIGH_FROM_FLD, common.NEIGH_TO_FLD], transfer=True) self.method = method self.tmpTable = self.tablePath(self.TABLE_FILE_NAME) self.swmFile = self.folderPath(self.SWM_FILE_NAME) common.overwrite(True)
TMP_CIRCPTS = 'tmp_circ' TMP_ALLPOLY = 'tmp_voroall' with common.runtool(7) as parameters: common.progress('parsing attributes') ## GET AND PREPARE THE ATTRIBUTES # obtained from the tool input points, ptsIDFld, weightFld, normStr, transferFldsStr, tolerStr, outPath = parameters location, outName = os.path.split(outPath) normalization = math.sqrt(common.toFloat(normStr, 'normalization value') / math.pi) tolerance = common.toFloat(tolerStr, 'positional tolerance value') transferFlds = common.parseFields(transferFldsStr) common.progress('creating weighting layer') common.overwrite(True) circLayer = common.createFeatureClass(os.path.join(location, TMP_CIRCPTS), crs=points) inShpFld = arcpy.Describe(points).ShapeFieldName circShapeFld = arcpy.Describe(circLayer).ShapeFieldName arcpy.AddField_management(circLayer, ptsIDFld, common.outTypeOfField(points, ptsIDFld)) inCount = common.count(points) common.progress('opening weighting layer') inCur = arcpy.SearchCursor(points) outCur = arcpy.InsertCursor(circLayer) prog = common.progressor('weighting points', inCount) pi2 = 2 * math.pi for inRow in inCur: # load input geometry pt = inRow.getValue(inShpFld).getPart(0) id = inRow.getValue(ptsIDFld)