how to calculate the area of each landuse type for multiple buffers?

1731
6
Jump to solution
05-14-2014 11:25 AM
JianyongWu
New Contributor
I have a landuse polygon shape file, which include 8 types of landuse. From the polygon file, I find 100 points. I make a buffer for each point with 1 km. Now, I want to calculate the area (percentage) of landuse type for each buffer. how to write a python script to do this? Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AdamCox1
Occasional Contributor II
Use the green check mark underneath the 0 at right.

Cheers!

View solution in original post

0 Kudos
6 Replies
AdamCox1
Occasional Contributor II
Here's the first strategy that comes to mind:

1. Use feature classes in a file geodatabase so every feature has its area automatically calculated
2. Make sure the data is in a projection with a meaningful unit of measure (e.g. meters, not degrees).
3. Clip the land use polygons to the buffer feature class.
4. Iterate through the features in the buffer feature class, selecting each one and using that selection to select the overlapping, clipped landuse polygons in order to get the area values from them and calculate the percentages.  Ok, something like:
buffers_path = "path\to\buffers"
clipped_land_use = "path\to\clipped\land\use"
land_use_fl = arcpy.MakeFeatureLayer(clipped_land_use,"lu")
for row1 in arcpy.SearchCursor(buffers_path):
    oid = str(row1.getValue("OBJECTID"))
    area1 = row1.getValue("SHAPE_area") #presumably, this will be the same for each feature, because you have a standard buffer distance
    name = #get a name value from one of the fields if you want
    print name
    if arcpy.Exists("fl"):
        arcpy.management.Delete("fl")
    fl = arcpy.management.MakeFeatureLayer(buffers_path,"fl",'"OBJECTID" = "+oid)
    arcpy.management.SelectLayerByLocation(land_use_fl,"INTERSECT",fl,"","NEW_SELECTION")
    
    #now iterate through the selected clipped features and print the info
    for row2 in arcpy.SearchCursor(land_use_fl):
        area2 = row2.getValue("SHAPE_area")
        use = #get the land use type from whatever field it's in
        percent = area2*100/area1
        print "  {0}: {1}%".format(use,str(percent))


I haven't tested this code, so there may be a bit of trouble shooting and configuring to do, but it should serve as a decent outline.
I only have 10.0, which is why I'm not using da.SearchCursor(), but this should work fine in 10.1/10.2 as well.
0 Kudos
JianyongWu
New Contributor
That is great. Thank you very much.

Here's the first strategy that comes to mind:

1. Use feature classes in a file geodatabase so every feature has its area automatically calculated
2. Make sure the data is in a projection with a meaningful unit of measure (e.g. meters, not degrees).
3. Clip the land use polygons to the buffer feature class.
4. Iterate through the features in the buffer feature class, selecting each one and using that selection to select the overlapping, clipped landuse polygons in order to get the area values from them and calculate the percentages.  Ok, something like:
buffers_path = "path\to\buffers"
clipped_land_use = "path\to\clipped\land\use"
land_use_fl = arcpy.MakeFeatureLayer(clipped_land_use,"lu")
for row1 in arcpy.SearchCursor(buffers_path):
    oid = str(row1.getValue("OBJECTID"))
    area1 = row1.getValue("SHAPE_area") #presumably, this will be the same for each feature, because you have a standard buffer distance
    name = #get a name value from one of the fields if you want
    print name
    if arcpy.Exists("fl"):
        arcpy.management.Delete("fl")
    fl = arcpy.management.MakeFeatureLayer(buffers_path,"fl",'"OBJECTID" = "+oid)
    arcpy.management.SelectLayerByLocation(land_use_fl,"INTERSECT",fl,"","NEW_SELECTION")
    
    #now iterate through the selected clipped features and print the info
    for row2 in arcpy.SearchCursor(land_use_fl):
        area2 = row2.getValue("SHAPE_area")
        use = #get the land use type from whatever field it's in
        percent = area2*100/area1
        print "  {0}: {1}%".format(use,str(percent))


I haven't tested this code, so there may be a bit of trouble shooting and configuring to do, but it should serve as a decent outline.
I only have 10.0, which is why I'm not using da.SearchCursor(), but this should work fine in 10.1/10.2 as well.
0 Kudos
AdamCox1
Occasional Contributor II
Glad to hear that was helpful!  Be sure to mark the question as answered if you are satisfied.  Good luck!
0 Kudos
JianyongWu
New Contributor
Glad to hear that was helpful!  Be sure to mark the question as answered if you are satisfied.  Good luck!


How to mark it? Thanks.
0 Kudos
AdamCox1
Occasional Contributor II
Use the green check mark underneath the 0 at right.

Cheers!
0 Kudos
TimBarnes
Occasional Contributor III
haha close enough 😛
0 Kudos