Пример #1
0
def Optimized_HotSpot_Analysis(facilityName):
    '''
    To conduct Optimized Hot Spot Analysis
    :param facilityName: feature class name of the facility
    :return:
    '''
    try:
        #Get the raster dataset of facility density surface
        arcpy.env.mask = "basemap_dissolved"
        arcpy.MinimumBoundingGeometry_management(facilityName,facilityName+"_MBG","CONVEX_HULL","ALL","#","NO_MBG_FIELDS")
        ohsa = arcpy.OptimizedHotSpotAnalysis_stats(facilityName,facilityName+"_ohsaSnap","","SNAP_NEARBY_INCIDENTS_TO_CREATE_WEIGHTED_POINTS",
                                                   facilityName+"_MBG","",facilityName+"_ohsaRaster" )
        ohsa2 = arcpy.OptimizedHotSpotAnalysis_stats(facilityName, facilityName+"_ohsaFishnet","","COUNT_INCIDENTS_WITHIN_FISHNET_POLYGONS",
                                                     "basemap_dissolved")
        if arcpy.Exists(facilityName+"_MBG"):
            arcpy.Delete_management(facilityName+"_MBG")
        print "Complete hot spot analysis"
    except:
        print (arcpy.GetMessages())
Пример #2
0
    def Analysis(self, gridName):
        print("Analysis Start:")
        all_field = "count_all"
        self.CountAll(gridName, all_field)
        arcpy.OptimizedHotSpotAnalysis_stats(gridName, "HSAnalysis_All",
                                             all_field)
        print("All hex grids analyzed, output layer HSAnalysis_All")
        if self.districts:
            arcpy.MakeFeatureLayer_management(self.districts,
                                              "districts_layer")
            arcpy.MakeFeatureLayer_management(gridName, "hex_layer")
            arcpy.SelectLayerByLocation_management("hex_layer", "intersect",
                                                   "districts_layer")
            arcpy.OptimizedHotSpotAnalysis_stats("hex_layer",
                                                 "HSAnalysis_XIAN", all_field)
            print(
                "Hex grids within Xi'an analyzed, output layer HSAnalysis_XIAN"
            )
            with arcpy.da.SearchCursor("districts_layer",
                                       ['FID', 'Name']) as cursor:
                for row in cursor:
                    arcpy.SelectLayerByAttribute_management(
                        "districts_layer", "NEW_SELECTION",
                        "FID = " + str(row[0]))
                    arcpy.SelectLayerByLocation_management(
                        "hex_layer", "intersect", "districts_layer")

                    num = int(arcpy.GetCount_management("hex_layer")[0])
                    print("In total {0} grids".format(num))
                    if num > 30:
                        arcpy.OptimizedHotSpotAnalysis_stats(
                            "hex_layer", "HSAnalysis_{0}".format(row[1]),
                            all_field)
                        print(
                            "Hex grids within {0} analyzed, output layer HSAnalysis_{0}"
                            .format(row[1]))
                    else:
                        print("Not enough grids to analyze")
Пример #3
0
#Hotspot Analysis of Parking Violations in DC in 2016

# Import arcpy module
import arcpy

# Local variables:
PV_2016_csv = "G:\\DC Policy Center\\Parking Violations\\Data\\Tab\\PV_2016.csv"
PV_2016_Layer = "PV_2016_Layer"
Parking_2016 = "G:\\DC Policy Center\\Parking Violations\\Data\\Spatial Data\\ParkingViolations.gdb\\Parking_2016"
DC_Boundary = "Block_Group"
Optimal_Hot_Spot = "G:\\DC Policy Center\\Parking Violations\\Data\\Spatial Data\\ParkingViolations.gdb\\Optimal_Hot_Spot"
Desnity_Surface = "G:\\DC Policy Center\\Parking Violations\\Data\\Spatial Data\\ParkingViolations.gdb\\Desnity_Surface"

# Process: Make XY Event Layer, display csv in ArcMap
arcpy.MakeXYEventLayer_management(
    PV_2016_csv, "x", "y", PV_2016_Layer,
    "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision",
    "")

# Process: Convert event layer to shapefile
arcpy.FeatureToPoint_management(PV_2016_Layer, Parking_2016, "CENTROID")

# Process: Optimized Hot Spot Analysis
arcpy.OptimizedHotSpotAnalysis_stats(
    Parking_2016, Optimal_Hot_Spot, "OBJECTID_1",
    "COUNT_INCIDENTS_WITHIN_FISHNET_POLYGONS", DC_Boundary, "",
    Desnity_Surface)
Пример #4
0
def compute_hotspots(city_id):
    print 'Computing hotspots for', city_id
    shpfile = os.path.join(LATLNGS_SHP_DIR, str(city_id) + '.shp')
    output = os.path.join(HOTSPOTS_DIR, str(city_id) + '_hotspots.shp')
    arcpy.OptimizedHotSpotAnalysis_stats(shpfile, output, 'price')
    print 'FINISHED %s!' % city_id
Пример #5
0
def hotspot(year):
    arcpy.OptimizedHotSpotAnalysis_stats(
        'AccidentLocations_' + year + '.shp', 'HotSpot_' + year + '.shp', '#',
        'COUNT_INCIDENTS_WITHIN_AGGREGATION_POLYGONS', '#',
        'SA2_2016_AUST.shp', '#')