<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcMap Draw Camera Range with ArcPy for all column in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174668#M13447</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank you it will solve my problem...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Oct 2011 09:10:50 GMT</pubDate>
    <dc:creator>AragonNette</dc:creator>
    <dc:date>2011-10-27T09:10:50Z</dc:date>
    <item>
      <title>ArcMap Draw Camera Range with ArcPy for all column</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174666#M13445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i am working on some camera data. I have some points which consist of azimuth, angle, distance(1000 mt), and of course coordinate field attributes. In arcmap I want to draw shapes like pie chart ... i write some code inspritaions from some similar code .. but when i choose all necessity column from my shp file and make code run , i am getting error to my except point in code...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

import arcpy, string, operator, math

try:
 #Collect azimuth, angle and x,y parameters
 fc = string.replace(arcpy.GetParameterAsText(0),"\\","/")
 fields = arcpy.ListFields(fc)
 descfc = arcpy.Describe(fc)
 sr = descfc.spatialReference
 azimuth = arcpy.GetParameterAsText(1)
 angle = arcpy.GetParameterAsText(2)
 x = arcpy.GetParameterAsText(3)
 y = arcpy.GetParameterAsText(4)

 #Check for output featureclass 
 outfc&amp;nbsp; = string.replace(fc, ".shp", "_range.shp")
 lstfc = string.split(fc, "/")
 for fd in lstfc:
&amp;nbsp; fn = fd
 #If existance
 if arcpy.Exists(outfc):
&amp;nbsp; arcpy.AddMessage("Deleting " + outfc)
&amp;nbsp; arcpy.Delete_management(outfc)
 #folder name
 folder = string.replace(fc, "/" + fn, "")
 arcpy.RefreshCatalog(folder)
 arcpy.env.workspace = folder
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Create the feature class
 arcpy.AddMessage("Creating a polygon featureclass " + outfc)
 sf = string.replace(outfc,folder + "/", "")
 arcpy.CreateFeatureclass_management(folder, sf, "POLYGON", fc, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr)
 arcpy.RefreshCatalog(folder)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Open search and insert cursors
 n = 0
 insrecs = arcpy.InsertCursor(outfc)
 recs = arcpy.SearchCursor(fc)
 rec = recs.next()
 while rec:
&amp;nbsp; x = rec.getValue(x)
&amp;nbsp; y = rec.getValue(y)
&amp;nbsp; angle = rec.getValue(angle)
&amp;nbsp; azimuth = rec.getValue(azimuth)
&amp;nbsp; 
&amp;nbsp; azimuth = operator.mod(azimuth, 360)
 
&amp;nbsp; if azimuth &amp;lt;= 90:
&amp;nbsp;&amp;nbsp; azimuth = 90 - azimuth
&amp;nbsp; elif azimuth &amp;lt;= 360:
&amp;nbsp;&amp;nbsp; azimuth = 360 - (azimuth -90)
&amp;nbsp; 
&amp;nbsp; arr = arcpy.Array()
&amp;nbsp; 
&amp;nbsp; azimuth1 = azimuth - (angle/2)
&amp;nbsp; azimuth2 = azimuth + (angle/2)
&amp;nbsp; azimuthSo = azimuth1
&amp;nbsp; 
&amp;nbsp; arr.add(x,y)
 
&amp;nbsp; while True:
&amp;nbsp;&amp;nbsp; tx = x + math.cos((math.pi/180) * azimuthSo) * 1000
&amp;nbsp;&amp;nbsp; ty = y + math.sin((math.pi/180) * azimuthSo) * 1000
&amp;nbsp;&amp;nbsp; point = arcpy.Point()
&amp;nbsp;&amp;nbsp; point.x = tx
&amp;nbsp;&amp;nbsp; point.y = ty
&amp;nbsp;&amp;nbsp; arr.add(point)
&amp;nbsp;&amp;nbsp; if azimuthSo &amp;gt;= azimuth2:
&amp;nbsp;&amp;nbsp;&amp;nbsp; break
&amp;nbsp;&amp;nbsp; azimuthSo +=5
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; arr.add(x,y)
&amp;nbsp; 
&amp;nbsp; #arcpy.AddMessage(add)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; #Add feature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insrec = insrecs.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insrec.Shape = arr
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld = fields.reset()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld = fields.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while fld:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fld.name &amp;lt;&amp;gt; "Shape" and fld.name &amp;lt;&amp;gt; "FID":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insrec.setValue ( fld.name, rec.getValue(fld.name))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld = fields.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insrecs.insertRow(insrec)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Next records&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = n + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec = recs.next()&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; 
&amp;nbsp; 
 #arcpy.AddMessageno of features
 arcpy.RefreshCatalog(folder)
 arcpy.AddMessage("\n" + str(n) + " features stored")

 #Completion message
 arcpy.AddMessage("\n** Finished **\n")
 
except:

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Error
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("\n** Error **\n")


finally:

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Cleanup
&amp;nbsp;&amp;nbsp;&amp;nbsp; del arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.AddMessage("\n** Finished **\n")
 &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 11:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174666#M13445</guid>
      <dc:creator>AragonNette</dc:creator>
      <dc:date>2011-10-14T11:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap Draw Camera Range with ArcPy for all column</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174667#M13446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a sample to draw an Arc and by using the center point of the circle, you can create a pie wedge.&amp;nbsp; You are most likely going to have modify this code to fit your needs.&amp;nbsp; You can create the wedge and then use an insert cursor to put the geometry into your feature class.&amp;nbsp; I just save it to disk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import math
import arcpy
def toCoord(centerX,centerY, radius, angle):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Calculates the position on the arc
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; radians = float((angle/180) * math.pi)
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = float(centerX + math.cos(radians) * radius)
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = float(centerY + math.sin(radians) * radius)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return [x, y]

def arc(centerX,centerY,radius,startAngle,endAngle,segments):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; centerX and centerY - X,Y center points of arc segment
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radius - distance from center to edge of circle in map units
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startAngle - starting position as degrees 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endAngle&amp;nbsp; ending position as degrees
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; segments - number of points to add in the Arc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returns: Array of Coordinates [[X1,X1],...,[Xn,Yn]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle = startAngle
&amp;nbsp;&amp;nbsp;&amp;nbsp; path = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; coords = toCoord(centerX,centerY,radius, angle)
&amp;nbsp;&amp;nbsp;&amp;nbsp; path.append(coords)
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (angle &amp;lt;= endAngle):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coords = toCoord(centerX,centerY,radius, angle)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path.append(coords)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle +=float(((endAngle-startAngle)/segments))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return path

centerPt = arcpy.Point(1.0,1.0)
arcPts = arc(centerPt.X,centerPt.Y,5.0,10.0,50.0,10)
array = arcpy.Array()
array.add(centerPt)
for pt in arcPts:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcPt = arcpy.Point(pt[0],pt[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(arcPt)
array.add(centerPt)
geom = arcpy.Polygon(array)
arcpy.CopyFeatures_management(geom,r"c:\temp\testArc.shp")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition to that, you might want to improve your error handling:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Change this
arcpy.AddMessage("\n** Error **\n")
# To at least this:
arcpy.AddError(arcpy.GetMessages(2))
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You might want to also consider adding a trace function to your except that will point out exactly what line is failing.&amp;nbsp; See: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000q000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000q000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174667#M13446</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-11T09:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap Draw Camera Range with ArcPy for all column</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174668#M13447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank you it will solve my problem...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 09:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174668#M13447</guid>
      <dc:creator>AragonNette</dc:creator>
      <dc:date>2011-10-27T09:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap Draw Camera Range with ArcPy for all column</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174669#M13448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the code its work perfect,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I adopted but because I have multiple points, each point present CCTV camera.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I make the script loop for each point, but when try to create the polygon I get one polygon for all cctv cameras. I don't know how to create multiple polygons on the same layer,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;could you please help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Jul 2013 04:03:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174669#M13448</guid>
      <dc:creator>AhmedAlani</dc:creator>
      <dc:date>2013-07-07T04:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap Draw Camera Range with ArcPy for all column</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174670#M13449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Andrew - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the beautiful code example. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran into a few issues with the radian conversion and I replaced line 7 with python's built in angle to radians function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;radians = math.radians(angle)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, this worked like a charm!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 21:55:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-draw-camera-range-with-arcpy-for-all-column/m-p/174670#M13449</guid>
      <dc:creator>RaphaelSiebenmann</dc:creator>
      <dc:date>2015-01-29T21:55:51Z</dc:date>
    </item>
  </channel>
</rss>

