0

I create a polygon layer including 80 buffer areas (they are not overlapping) and want to get the area of each value of a raster file for each buffer area. I can use the tabulate area to realize this but the output only includes 79 buffer areas. I find many explanations for this, such as raster resolution but I still cannot solve this problem.

The following part is my scripts.

import pandas as pd
import arcpy

from arcpy import env
from arcpy.sa import *

arcpy.env.workspace = "D:/STAR/WQ_Summer.gdb"
arcpy.env.overwriteOutput = True #overwrite the exsiting files

pointlayer = "network_node_all" 

scenairoCon = "ConPro"  
scenairo1 = "b00w50r00s760Pro"
scenairo2 = "b00w50r00s070Pro"
scenairo3 = "b00w50r90s760Pro"
scenairo4 = "b00w50r90s070Pro"
scenairo5 = "b00w90r00s760Pro"
scenairo6 = "b00w90r00s070Pro"
scenairo7 = "b00w90r90s760Pro"
scenairo8 = "b00w90r90s070Pro"
scenairo9 = "b90w50r00s760Pro"
scenairo10 = "b90w50r00s070Pro"
scenairo11 = "b90w50r90s760Pro"
scenairo12 = "b90w50r90s070Pro"
scenairo13 = "b90w90r00s760Pro"
scenairo14 = "b90w90r00s070Pro"
scenairo15 = "b90w90r90s760Pro"
scenairo16 = "b90w90r90s070Pro"
scenairo17 = "b00w50r00s400Pro"
scenairo18 = "b00w50r65s070Pro"
scenairo19 = "b00w50r65s400Pro"
scenairo20 = "b00w50r65s760Pro"
scenairo21 = "b00w50r90s400Pro"
scenairo22 = "b00w90r00s400Pro"
scenairo23 = "b00w90r65s070Pro"
scenairo24 = "b00w90r65s400Pro"
scenairo25 = "b00w90r65s760Pro"
scenairo26 = "b00w90r90s400Pro"
scenairo27 = "b90w50r00s400Pro"
scenairo28 = "b90w50r65s070Pro"
scenairo29 = "b90w50r65s400Pro"
scenairo30 = "b90w50r65s760Pro"
scenairo31 = "b90w50r90s400Pro"
scenairo32 = "b90w90r00s400Pro"
scenairo33 = "b90w90r65s070Pro"
scenairo34 = "b90w90r65s400Pro"
scenairo35 = "b90w90r65s760Pro"
scenairo36 = "b90w90r90s400Pro"

scenairos = [scenairo2,scenairo3,scenairo4,scenairo5,
             scenairo6,scenairo7,scenairo8,scenairo9,scenairo10,scenairo11,
             scenairo12,scenairo13,scenairo14,scenairo15,scenairo16,scenairo17,
             scenairo18,scenairo19,scenairo20,scenairo21,scenairo22,scenairo23,
             scenairo24,scenairo25,scenairo26,scenairo27,scenairo28,scenairo29,
             scenairo30,scenairo31,scenairo32,scenairo33,scenairo34,scenairo35,
             scenairo36]

number = [9,22]
distance = 25

for i in number:

    #load necessary point documents
    randomfile = "RandomSelection_" + str(i)

    loc = ("D:\\STAR\\RandomPoints\\" + randomfile + ".csv")

    print randomfile

    df = pd.read_csv(loc) #read the csv file
    random = df[df.columns[3]]

    point_out = "point_layer" + str(i)

    random = random.values.tolist()

    random = list(map(int,random))

    arcpy.MakeFeatureLayer_management(pointlayer,pointlayer)

    arcpy.SelectLayerByAttribute_management(pointlayer,"ADD_TO_SELECTION","ARC_ in (" + str(random)[1:-1] + ")")

    arcpy.CopyFeatures_management(pointlayer, point_out) 

    print point_out

    buffername = point_out + "buffer" + str(distance)

    buffer_range = str(distance) + " miles"

    arcpy.Buffer_analysis(point_out,buffername,buffer_range)

    print buffername

    scenairopair = [scenairo1,scenairos[i-2]]

    for scenairo in scenairopair:

        print scenairo

        outTable = point_out + "_" + scenairo + "_table"

        inZoneData = buffername
        inClassData = scenairo
        zoneField = "ARC_"
        classField = "VALUE"
        processingCellSize = scenairo

        arcpy.CheckOutExtension("Spatial")
        TabulateArea(inZoneData, zoneField, inClassData, classField, outTable, processingCellSize)

        folder_name = "scenairo" + str(i)
        outpath = "D:\\STAR\\Results\\" + str(distance) + "miles\\" + folder_name
        outresult = outpath + "\\" + scenairo + "_v2" + ".xls"
        arcpy.TableToExcel_conversion(outTable,outresult)

        print outresult

    print "#################################"

In the script, I firstly select 80 points based on the uploaded document and then create a buffer layer using these 80 points. The only thing matters are the result only includes 79 buffers rather than 80.

New contributor
Dennis is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • If you try to create 2 buffers do you get 2? When you try to create 3 do you get 3? When does the number you get depart from the number that you expect? – PolyGeo Aug 14 at 19:31

Your Answer

Dennis is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.