# 一、渔网图

• 渔网的空间范围
• 渔网的行数与列数以及各单位的高度与宽度
• 渔网的旋转角度
• 定义输出要素类名称和类型（面或线）的参数以及包含各像元质心的可选点数据集

# 二、生成蜂窝点

## 2.2蜂窝点算法

``````#!/usr/bin/env python
"""

ArcGIS 版本:  10.2
"""

import math
import os
import arcpy

def create_thiessen_points(study_area, side_length, output_fc):

# 输入图层
count = int(str(arcpy.GetCount_management(study_area)))
if count == 0:
return
side_length = float(side_length)
if side_length <= 0:
return

# 计算点范围
dx = 3.0 * side_length
dy = side_length / 2.0 * math.sqrt(3.0)
indent = dx / 2

desc = arcpy.Describe(study_area)
if desc.dataType == "FeatureLayer":
desc = arcpy.Describe(desc.featureClass.catalogPath)
ext = desc.extent

# 计算行列
xmin = ext.XMin - dx
ymin = ext.YMin - dy * 3.0
xmax = ext.XMax + dx
ymax = ext.YMax + dy * 3.0
num_rows = int((ymax - ymin) / dy) + 1
num_cols = int((xmax - xmin) / dx) + 2

# 创建输出图层
spatial_ref = desc.spatialReference
workspace = os.path.dirname(output_fc)
fc_name = os.path.basename(output_fc)
fc = arcpy.CreateFeatureclass_management(
workspace, fc_name, "POINT", "", "", "", spatial_ref)

arcpy.AddMessage('Creating ' + str(num_rows * num_cols) + ' points...')
cursor = arcpy.InsertCursor(output_fc)
feature = None

try:
y = ymin
for r in range(num_rows):
x = xmin - indent / 2
if r % 2 != 0:
x += indent

for c in range(num_cols):
feature = cursor.newRow()
p = arcpy.Point()
p.X = x
p.Y = y
feature.shape = p
cursor.insertRow(feature)
x += dx

y += dy

finally:
if feature:
del feature
if cursor:
del cursor

if __name__ == '__main__':
is_test = False

if is_test:
raise Exception(' Testing not yet implemented')
else:
study_area = arcpy.GetParameterAsText(0)
side_length = arcpy.GetParameterAsText(1)
output_fc = arcpy.GetParameterAsText(2)

create_thiessen_points(study_area, side_length, output_fc)``````