无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

arcpy開發(fā)實例之POI格網(wǎng)剖分聚類

2022-11-11 10:08 作者:夕林泉石  | 我要投稿

# _*_ encoding: utf-8 _*_

import arcpy

arcpy.env.workspace = "d:/temp/poi_yuelu";


# 1. 生成格網(wǎng)(魚網(wǎng))

arcpy.management.CreateFishnet("d:/temp/poi_yuelu/grid.shp",'12560907 3264305','12560907 3286103',500,500,45,30,labels=False,geometry_type='POLYGON');

# 刪除行政邊界外的格網(wǎng),以減少計算量


# 2. 空間關(guān)聯(lián)計算每個單元格里的poi數(shù)量

arcpy.analysis.SpatialJoin("grid","poi_yuelu","d:/temp/poi_yuelu/grid_pcount.shp","JOIN_ONE_TO_ONE",match_option="COMPLETELY_CONTAINS");

#刪除所有poi點數(shù)量為0的單元格,以減少計算量

with arcpy.da.UpdateCursor("grid_pcount","*","join_count=0") as cursor:

? ? for row in cursor:

? ? ? ? cursor.deleteRow();


# 3. 使用自然分類法,將單元格的poi數(shù)量劃分為10個組

ys = [];

with arcpy.da.SearchCursor("grid_pcount","join_count") as cursor:

? ? for row in cursor:

? ? ? ? ys.append(row[0]);? ? ??


import jenkspy

breaks = jenkspy.jenks_breaks(ys, nb_class=10)

print breaks

#[1.0, 10.0, 25.0, 45.0, 69.0, 99.0, 138.0, 182.0, 240.0, 305.0, 401.0]


# 4. 根據(jù)breaks,為每個單元格設(shè)置分組號

with arcpy.da.UpdateCursor("grid_pcount",["join_count","pcount"]) as cursor:

? ? for row in cursor:

? ? ? ? if row[0]<breaks[1]:

? ? ? ? ? ? row[1]=1;

? ? ? ? elif row[0]>=breaks[1] and row[0]<breaks[2]:

? ? ? ? ? ? row[1] = 2;

? ? ? ? elif row[0]>=breaks[2] and row[0]<breaks[3]:

? ? ? ? ? ? row[1] = 3;

? ? ? ? elif row[0]>=breaks[3] and row[0]<breaks[4]:

? ? ? ? ? ? row[1] = 4;

? ? ? ? elif row[0]>=breaks[4] and row[0]<breaks[5]:

? ? ? ? ? ? row[1] = 5;

? ? ? ? elif row[0]>=breaks[5] and row[0]<breaks[6]:

? ? ? ? ? ? row[1] = 6;

? ? ? ? elif row[0]>=breaks[6] and row[0]<breaks[7]:

? ? ? ? ? ? row[1] = 7;

? ? ? ? elif row[0]>=breaks[7] and row[0]<breaks[8]:

? ? ? ? ? ? row[1] = 8;

? ? ? ? elif row[0]>=breaks[8] and row[0]<breaks[9]:

? ? ? ? ? ? row[1] = 9;

? ? ? ? elif row[0]>=breaks[9]:

? ? ? ? ? ? row[1] = 10;? ??

? ? ? ? cursor.updateRow(row);


# 6. 使用arcgis自帶的hotarean分析工具

arcpy.stats.OptimizedHotSpotAnalysis("poi_yuelu","d:/temp/poi_hotarea.shp",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Incident_Data_Aggregation_Method="COUNT_INCIDENTS_WITHIN_FISHNET_POLYGONS",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Cell_Size="20 Meters");

# 六邊形魚網(wǎng)

arcpy.stats.OptimizedHotSpotAnalysis("poi_yuelu","d:/temp/poi_hotarea.shp",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Incident_Data_Aggregation_Method="COUNT_INCIDENTS_WITHIN_HEXAGON_POLYGONS",

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Cell_Size="20 Meters");


arcpy開發(fā)實例之POI格網(wǎng)剖分聚類的評論 (共 條)

分享到微博請遵守國家法律
分宜县| 昌平区| 灯塔市| 贵州省| 广平县| 东台市| 灵山县| 商水县| 陇西县| 光山县| 天门市| 临夏市| 西乌| 都江堰市| 万山特区| 邢台县| 遂昌县| 安泽县| 吉木萨尔县| 孟连| 平果县| 永仁县| 海淀区| 曲靖市| 青田县| 濮阳市| 宜君县| 崇左市| 新兴县| 昭苏县| 丰镇市| 威远县| 吉隆县| 乌苏市| 四会市| 佛学| 临夏县| 镇坪县| 饶平县| 洞头县| 施秉县|