AnsweredAssumed Answered

square buffer

Question asked by Mahmoud_Medoukh on Jan 24, 2015
Latest reply on Feb 23, 2015 by xander_bakker

for people who know about using python scripting in ArcMap, I'm a GIS student and I have a small project about python. I'm beginner in python language I need some help in my python script. it's about square buffer around a points feature in GIS ArcMap 10.1? and I have tried all my best to do this but it's not working .. Hope you'll help me If you don't know "Just tag this post to anyone who know about this" Thanks in advance.

This is my script:

 

    import arcpy
    import math
    import os
    from arcpy import env
    env
.overwriteOutput=False

    #Point Feature Class that the square buffers will be created around
    Input_Points= arcpy.GetParameterAsText(0)
    #Path and name for Output Polygon Feature Class
    out_Feature_Class
=arcpy.GetParameterAsText(1)
    Out_Path=os.path.dirname(out_Feature_Class)
    out_Name
=os.path.basename(out_Feature_Class)
    #Height
    h
= arcpy.GetParameterAsText(2)
    h
=float(h)
    #Width
    w
= arcpy.GetParameterAsText(3)
    w
=float(w)
    cursor
=arcpy.da.SearchCursor(Input_Points,"Shape")
    fields
=cursor.fields
    for field in fields:
      m
=cursor.next()
      x
=m[0][0]
      y
=m[0][1]
      x1
=x-(w/2)
      x2
=x+(w/2)
      x3
=x+(w/2)
      x4
=x-(w/2)
      y1
=y-(h/2)
      y2
=y-(h/2)
      y3
=y-(h/2)
      y4
=y-(h/2)
      pnt1
=arcpy.Point(x1,y1)
      pnt2
=arcpy.Point(x2,y2)
      pnt3
=arcpy.Point(x3,y3)
      pnt4
=arcpy.Point(x4,y4)
      arr
=arcpy.Array([pnt1,pnt2,pnt3,pnt4,pnt1])
      square_buffer
=arcpy.Polygon(arr)

    arcpy
.CopyFeatures_management(square_buffer,"square_buffer")

    arcpy
.CreateFeatureclass_management(Out_Path,out_Name,"POINT")
    arcpy
.AddField_management(out_Feature_Class,"x","FLOAT")
    arcpy
.AddField_management(out_Feature_Class,"y","FLOAT")
    arcpy
.AddField_management(out_Feature_Class,"POI","TEXT")
    arcpy
.AddField_management(out_Feature_Class,"Height","DOUBLE")
    arcpy
.AddField_management(out_Feature_Class,"Width","DOUBLE")

    with arcpy.da.InsertCursor(out_Feature_Class,("SHAPE@xy","x","y","POI","Height","Width"))as cursor:
     
for line in cursor:
      attributes
=line.split(",")
      x
=attributes[0]
      x
=float(x)
      y
=attributes[1]
      y
=float(y)
      POI
=attributes[3]
     
Height=attributes[4]
     
Width=attributes[4]
      row
=((x,y),x,y,POI,Height,Width)
     
#arcpy.Add massege(row)
      cursor
.insertRow(row)

Outcomes