# Land cover nearby
# Created on: 2018-02-22 10:12:09.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Set the necessary product code
# import arcinfo

#import system modules
import arcpy
from arcpy import env
import os
import time
import sys

outputroot="E:\\nearbylandcover08\\"
temp="E:\\nearbylandcover08\\temp\\"

# Local variables:
LC_p_shp = "D:\\Work\\CIRCA\\Circa\\GISdata\\prop_oneunitcoastGgl.shp"
Landcover=["2008"]
# "2002","2008","2009","2010","2011","2012","2013","2014","2015"
# Make a layer from the feature class
arcpy.Delete_management("lyr", "")
arcpy.MakeFeatureLayer_management(LC_p_shp, "lyr") 
StartTime0=time.clock()
for LC in Landcover:
 lc_tif="D:\\Work\\CIRCA\\Circa\\GISdata\\land_use_land_cover_NASS_CDL_ct_3545667_02\land_use_land_cover\NASS_ct\\cdl_30m_r_ct_"+LC+"_utm18.tif"
 lcpoly=temp+"lcpoly_"+LC+".shp"   
 lcclip_tif=temp+"lcclip_"+LC+".tif"
 #arcpy.Clip_management(lc_tif, "748990.313657903 556164.743413563 1246647.64549954 694448.639494738", lcclip_tif, LC_p_shp, "-3.402823e+038", "", "NO_MAINTAIN_EXTENT")
 # Process: Raster to Polygon
 #arcpy.RasterToPolygon_conversion(lcclip_tif, lcpoly, "NO_SIMPLIFY", "Value")
 for n in range(203917,231650):
   StartTime = time.clock()
   prop_buffer=temp+"propbuff_"+str(n)+".shp"
   
   proplc_n = outputroot+"Plandc_"+str(n)+LC+".shp"
   arcpy.Delete_management(prop_buffer, "")
   arcpy.Delete_management(proplc_n, "")
   
   arcpy.SelectLayerByAttribute_management("lyr", "New_SELECTION", '"fid" = '+str(n))
   # half mile buffer
   arcpy.Buffer_analysis("lyr", prop_buffer, ".5 Miles", "FULL", "ROUND", "NONE", "", "GEODESIC")

   # Process: Intersect
   arcpy.Intersect_analysis(prop_buffer+" #;"+lcpoly+" #", proplc_n, "ALL", "", "INPUT")
   
   arcpy.AddGeometryAttributes_management(proplc_n, "AREA_GEODESIC", "FEET_US", "SQUARE_FEET_US", "GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
   # Process: Delete
   arcpy.Delete_management(prop_buffer, "")
   StopTime1 = time.clock()
   elapsedTime=(StopTime1-StartTime)
   print 'Time for operating feature '+str(n)+' in Year '+LC+' is: '+ str(round(elapsedTime, 1))+ ' seconds'


StopTime2 = time.clock()
elapsedTime1=(StopTime2-StartTime0)/60
print 'Time for all the analysis is: '+ str(round(elapsedTime1, 1))+ ' minites'

6379d1abc026afcdd0d5d8167bf03e98e7d8dd6b
# Land cover nearby
# Created on: 2018-02-22 10:12:09.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Set the necessary product code
# import arcinfo

#import system modules
import arcpy
from arcpy import env
import os
import time
import sys

outputroot="E:\\nearbylandcover08\\"
temp="E:\\nearbylandcover08\\temp\\"

# Local variables:
LC_p_shp = "D:\\Work\\CIRCA\\Circa\\GISdata\\prop_oneunitcoastGgl.shp"
Landcover=["2008"]
# "2002","2008","2009","2010","2011","2012","2013","2014","2015"
# Make a layer from the feature class
arcpy.Delete_management("lyr", "")
arcpy.MakeFeatureLayer_management(LC_p_shp, "lyr") 
StartTime0=time.clock()
for LC in Landcover:
 lc_tif="D:\\Work\\CIRCA\\Circa\\GISdata\\land_use_land_cover_NASS_CDL_ct_3545667_02\land_use_land_cover\NASS_ct\\cdl_30m_r_ct_"+LC+"_utm18.tif"
 lcpoly=temp+"lcpoly_"+LC+".shp"   
 lcclip_tif=temp+"lcclip_"+LC+".tif"
 #arcpy.Clip_management(lc_tif, "748990.313657903 556164.743413563 1246647.64549954 694448.639494738", lcclip_tif, LC_p_shp, "-3.402823e+038", "", "NO_MAINTAIN_EXTENT")
 # Process: Raster to Polygon
 #arcpy.RasterToPolygon_conversion(lcclip_tif, lcpoly, "NO_SIMPLIFY", "Value")
 for n in range(203917,231650):
   StartTime = time.clock()
   prop_buffer=temp+"propbuff_"+str(n)+".shp"
   
   proplc_n = outputroot+"Plandc_"+str(n)+LC+".shp"
   arcpy.Delete_management(prop_buffer, "")
   arcpy.Delete_management(proplc_n, "")
   
   arcpy.SelectLayerByAttribute_management("lyr", "New_SELECTION", '"fid" = '+str(n))
   # half mile buffer
   arcpy.Buffer_analysis("lyr", prop_buffer, ".5 Miles", "FULL", "ROUND", "NONE", "", "GEODESIC")

   # Process: Intersect
   arcpy.Intersect_analysis(prop_buffer+" #;"+lcpoly+" #", proplc_n, "ALL", "", "INPUT")
   
   arcpy.AddGeometryAttributes_management(proplc_n, "AREA_GEODESIC", "FEET_US", "SQUARE_FEET_US", "GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
   # Process: Delete
   arcpy.Delete_management(prop_buffer, "")
   StopTime1 = time.clock()
   elapsedTime=(StopTime1-StartTime)
   print 'Time for operating feature '+str(n)+' in Year '+LC+' is: '+ str(round(elapsedTime, 1))+ ' seconds'


StopTime2 = time.clock()
elapsedTime1=(StopTime2-StartTime0)/60
print 'Time for all the analysis is: '+ str(round(elapsedTime1, 1))+ ' minites'
