Hello everybody ,for people who know about using python scripting - TopicsExpress



          

Hello everybody ,for people who know about using python scripting in ArcMap, Im a GIS student and I have a small project about python. Im beginner in python language I need some help in my python script. its about square buffer around a points feature in GIS ArcMap 10.1? and I have tried all my best to do this but its not working .. Hope youll help me If you dont 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)
Posted on: Sat, 24 Jan 2015 21:56:41 +0000

Trending Topics



Recently Viewed Topics




© 2015