<s> '''<STR_LIT>''' <EOL> import os <EOL> import sys <EOL> import traceback <EOL> import arcpy <EOL> acceptableDistanceUnits = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> srDefault = arcpy . SpatialReference ( <NUM_LIT> ) <EOL> def rangeRingsFromList ( centerFC , rangeList , distanceUnits , numRadials , outputRingFeatures , outputRadialFeatures , sr ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> if sr == "<STR_LIT:#>" or sr == "<STR_LIT>" or sr == None : <EOL> sr = srDefault <EOL> rm = RingMaker ( centerFC , rangeList , distanceUnits , sr ) <EOL> numCenterPoints = arcpy . GetCount_management ( centerFC ) . getOutput ( <NUM_LIT:0> ) <EOL> numRingsPerCenter = len ( rangeList ) <EOL> totalNumRings = int ( numCenterPoints ) * int ( numRingsPerCenter ) <EOL> totalNumRadials = int ( numCenterPoints ) * int ( numRadials ) <EOL> arcpy . AddMessage ( "<STR_LIT>" + str ( totalNumRings ) + "<STR_LIT>" + str ( numRingsPerCenter ) + "<STR_LIT>" + str ( numCenterPoints ) + "<STR_LIT>" ) <EOL> rm . makeRingsFromDistances ( ) <EOL> outRings = rm . saveRingsAsFeatures ( outputRingFeatures ) <EOL> arcpy . AddMessage ( "<STR_LIT>" + str ( totalNumRadials ) + "<STR_LIT>" + str ( numRadials ) + "<STR_LIT>" + str ( numCenterPoints ) + "<STR_LIT>" ) <EOL> rm . makeRadials ( numRadials ) <EOL> outRadials = rm . saveRadialsAsFeatures ( outputRadialFeatures ) <EOL> return [ outRings , outRadials ] <EOL> except arcpy . ExecuteError : <EOL> msgs = arcpy . GetMessages ( ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( msgs ) <EOL> except : <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> tbinfo = traceback . format_tb ( tb ) [ <NUM_LIT:0> ] <EOL> pymsg = "<STR_LIT>" + tbinfo + "<STR_LIT>" + str ( sys . exc_info ( ) [ <NUM_LIT:1> ] ) <EOL> msgs = "<STR_LIT>" + arcpy . GetMessages ( ) + "<STR_LIT:\n>" <EOL> arcpy . AddError ( pymsg ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( pymsg + "<STR_LIT:\n>" ) <EOL> print ( msgs ) <EOL> def rangeRingsFromMinMax ( centerFC , rangeMin , rangeMax , distanceUnits , numRadials , outputRingFeatures , outputRadialFeatures , sr ) : <EOL> '''<STR_LIT>''' <EOL> rangeList = [ min ( rangeMin , rangeMax ) , max ( rangeMin , rangeMax ) ] <EOL> return rangeRingsFromList ( centerFC , rangeList , distanceUnits , numRadials , outputRingFeatures , outputRadialFeatures , sr ) <EOL> def rangeRingsFromInterval ( centerFC , numRings , distBetween , distanceUnits , numRadials , outputRingFeatures , outputRadialFeatures , sr ) : <EOL> '''<STR_LIT>''' <EOL> rangeList = [ x * distBetween for x in range ( <NUM_LIT:1> , numRings + <NUM_LIT:1> ) ] <EOL> return rangeRingsFromList ( centerFC , rangeList , distanceUnits , numRadials , outputRingFeatures , outputRadialFeatures , sr ) <EOL> class RingMaker : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , center , inputRangeList , distanceUnits , sr ) : <EOL> '''<STR_LIT>''' <EOL> self . deleteme = [ ] <EOL> originalGeom = arcpy . CopyFeatures_management ( center , arcpy . Geometry ( ) ) <EOL> newGeom = [ ] <EOL> for g in originalGeom : <EOL> newGeom . append ( g . projectAs ( sr ) ) <EOL> self . center = newGeom <EOL> self . rangeList = self . _sortList ( inputRangeList ) <EOL> if distanceUnits == None or distanceUnits == "<STR_LIT:#>" or distanceUnits == "<STR_LIT>" : <EOL> self . distanceUnits = sr . linearUnitName <EOL> else : <EOL> self . distanceUnits = distanceUnits <EOL> if not sr == None or not sr == "<STR_LIT:#>" or not sr == "<STR_LIT>" : <EOL> self . sr = sr <EOL> else : <EOL> self . sr = srDefault <EOL> self . ringFeatures = None <EOL> self . radialFeatures = None <EOL> self . ringCount = len ( self . rangeList ) <EOL> self . ringMin = min ( self . rangeList ) <EOL> self . ringMax = max ( self . rangeList ) <EOL> def __del__ ( self ) : <EOL> '''<STR_LIT>''' <EOL> for i in self . deleteme : <EOL> if arcpy . Exists ( i ) : <EOL> arcpy . Delete_management ( i ) <EOL> def _sortList ( self , listToSort ) : <EOL> '''<STR_LIT>''' <EOL> if len ( listToSort ) == <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> return None <EOL> return sorted ( listToSort ) <EOL> def _addFieldsToTable ( self , tab , fields ) : <EOL> '''<STR_LIT>''' <EOL> for f in list ( fields . keys ( ) ) : <EOL> arcpy . AddField_management ( tab , f , fields [ f ] ) <EOL> return tab <EOL> def _makeTempTable ( self , name , fields ) : <EOL> '''<STR_LIT>''' <EOL> tab = os . path . join ( "<STR_LIT>" , name ) <EOL> arcpy . CreateTable_management ( os . path . dirname ( tab ) , <EOL> os . path . basename ( tab ) ) <EOL> self . deleteme . append ( tab ) <EOL> if fields : <EOL> newtab = self . _addFieldsToTable ( tab , fields ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> newtab = tab <EOL> return newtab <EOL> def makeRingsFromDistances ( self ) : <EOL> '''<STR_LIT>''' <EOL> fields = { '<STR_LIT:x>' : '<STR_LIT>' , '<STR_LIT:y>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> inTable = self . _makeTempTable ( "<STR_LIT>" , fields ) <EOL> cursor = arcpy . da . InsertCursor ( inTable , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT>' ] ) <EOL> for i in self . center : <EOL> pt = i . firstPoint <EOL> for r in self . rangeList : <EOL> cursor . insertRow ( [ pt . X , pt . Y , r * <NUM_LIT:2> ] ) <EOL> del cursor <EOL> self . deleteme . append ( inTable ) <EOL> outFeatures = os . path . join ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> arcpy . TableToEllipse_management ( inTable , outFeatures , <EOL> '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> self . distanceUnits , <EOL> '<STR_LIT:#>' , '<STR_LIT:#>' , '<STR_LIT:#>' , self . sr ) <EOL> exp = r"<STR_LIT>" <EOL> arcpy . CalculateField_management ( inTable , '<STR_LIT>' , exp , '<STR_LIT>' ) <EOL> self . deleteme . append ( outFeatures ) <EOL> self . ringFeatures = outFeatures <EOL> return outFeatures <EOL> def makeRadials ( self , numRadials ) : <EOL> '''<STR_LIT>''' <EOL> segmentAngle = <NUM_LIT> / float ( numRadials ) <EOL> segmentAngleList = [ ] <EOL> a = <NUM_LIT:0.0> <EOL> while a < <NUM_LIT> : <EOL> segmentAngleList . append ( a ) <EOL> a += segmentAngle <EOL> fields = { '<STR_LIT:x>' : '<STR_LIT>' , '<STR_LIT:y>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> tab = self . _makeTempTable ( "<STR_LIT>" , fields ) <EOL> cursor = arcpy . da . InsertCursor ( tab , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> for i in self . center : <EOL> pt = i . firstPoint <EOL> for r in segmentAngleList : <EOL> cursor . insertRow ( [ pt . X , pt . Y , r , self . ringMax ] ) <EOL> del cursor <EOL> self . deleteme . append ( tab ) <EOL> outRadialFeatures = os . path . join ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> arcpy . BearingDistanceToLine_management ( tab , outRadialFeatures , '<STR_LIT:x>' , '<STR_LIT:y>' , <EOL> '<STR_LIT>' , self . distanceUnits , '<STR_LIT>' , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT:#>" , self . sr ) <EOL> self . deleteme . append ( outRadialFeatures ) <EOL> self . radialFeatures = outRadialFeatures <EOL> return outRadialFeatures <EOL> def saveRingsAsFeatures ( self , outputFeatureClass ) : <EOL> '''<STR_LIT>''' <EOL> arcpy . CopyFeatures_management ( self . ringFeatures , outputFeatureClass ) <EOL> return outputFeatureClass <EOL> def saveRadialsAsFeatures ( self , outputFeatureClass ) : <EOL> '''<STR_LIT>''' <EOL> arcpy . CopyFeatures_management ( self . radialFeatures , outputFeatureClass ) <EOL> return outputFeatureClass </s>
