插个广告,制作ArcGIS的Tool工具学习下面的教程就对了:
零基础学习Python制作ArcGIS自定义工具观看链接
《零基础学习Python制作ArcGIS自定义工具》课程简介
 import arcpy
import numpy
from arcpy import da def GetFieldUniqueValue(inTable,inField):
value_list=[]
rows=arcpy.da.SearchCursor(inTable,inField)
for row in rows:
if row[0] not in value_list:
value_list.append( str(row[0]).decode('utf-8') )
del row
del rows
return value_list def GetDuplicateValue(inTable,inField):
dic={}
rows=arcpy.da.SearchCursor(inTable,inField)
for row in rows:
if row[0] in dic.keys():
dic[row[0]]=dic[row[0]]+1
else:
dic[row[0]]=1
del row
del rows
for key,value in dic.items():
if value==1:
del dic[key]
return dic def GetFieldMode(inTable,inField):
dic=GetDuplicateValue(inTable,inField)
lst=[value for key,value in dic.items()]
num=max(lst)
modeList=[]
for key,value in dic.items():
if value==num:
modeList.append(key)
return modeList def GetFieldValueList(inTable,inField):
value_list=[]
rows=arcpy.da.SearchCursor(inTable,inField)
for row in rows:
value_list.append(row[0])
del row
del rows
return value_list def main():
in_fc=arcpy.GetParameterAsText(0)
in_fld=arcpy.GetParameterAsText(1)
c=arcpy.GetParameterAsText(2)
if c== "Unique value":
uniqueValue=GetFieldUniqueValue(in_fc,in_fld)
arcpy.AddMessage("Unique Value:")
for i in uniqueValue:
arcpy.AddMessage(str(i))
if c=="Duplicate value":
duplicateValue= GetDuplicateValue(in_fc,in_fld)
arcpy.AddMessage("Duplicate Value,Count:")
for key,value in duplicateValue.items():
arcpy.AddMessage("{0},{1}".format(key,value))
if c=="Max/Min/Sum/Average etc.":
valueList=GetFieldValueList(in_fc,in_fld)
arcpy.AddMessage("Field Name:{}".format(in_fld))
arcpy.AddMessage("Max:{}".format(max(valueList)))
arcpy.AddMessage("Min:{}".format(min(valueList)))
arcpy.AddMessage("Sum:{}".format(sum(valueList)))
arcpy.AddMessage("Average:{}".format(numpy.mean(valueList)))
arcpy.AddMessage("Median:{}".format(numpy.median(valueList)))
arcpy.AddMessage("Mode:{}".format(GetFieldMode(in_fc,in_fld)))
arcpy.AddMessage("Variance:{}".format(numpy.var(valueList)))
arcpy.AddMessage("Standard Deviation:{}".format(numpy.std(valueList)))

arcpy-字段唯一值、重复值、最值、平均值、方差、标准差、中数、众数的更多相关文章

  1. 获取字段唯一值工具- -ArcPy和Python案例学习笔记

    获取字段唯一值工具- -ArcPy和Python案例学习笔记   目的:获取某一字段的唯一值,可以作为工具使用,也可以作为函数调用 联系方式:谢老师,135-4855-4328,xiexiaokui# ...

  2. arcgis python获得字段唯一值

    arcgis python获得字段唯一值 # Import native arcgisscripting moduleimport arcgisscripting, sys# Create the g ...

  3. Mysql查询某字段值重复的数据

    查询user表中,user_name字段值重复的数据及重复次数 select user_name,count(*) as count from user group by user_name havi ...

  4. MySQL 查询表中某字段值重复的数据

    MySQL中,查询表(dat_bill_2018_11)中字段(product_id)值重复的记录: ; 说明:先用GROUP BY 对 product_id 进行分组,同时使用COUNT(*)进行统 ...

  5. mysql 允许在唯一索引的字段中出现多个null值

    线上问题:org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [update fl_table ...

  6. SQL0803问题 键值重复

    工作中遇到SQL0803问题  使用DB2AS400数据库 报数据库键值重复错误 经同事分析为索引的起始值与当前已有记录的最大索引值不匹配造成的,验证过程如下: 1.SELECT max(被索引字段) ...

  7. SQL语句增删改字段、表、修改默认值

    收集转载: 1.修改字段,默认值 .修改字段默认值 alter table 表名 drop constraint 约束名字 ------说明:删除表的字段的原有约束 alter table 表名 ad ...

  8. Oracle-一张表中增加计算某列值重复的次数列,并且把表中其他列也显示出来,或者在显示过程中做一些过滤

    总结: 1.计算某列值(数值or字符串)重复的次数 select 列1,count( 列1 or *) count1  from table1 group by 列1 输出的表为:第一列是保留唯一值的 ...

  9. select初始化添加option,通过标签给出回显值,由于回显值和初始化值option中有一个值重复,去重等问题!

    第一张图片: 第二张图片 /** *该方法是为了去重,所谓去重就是 因为回显给select附上了值并设置为selected选中状态,而在我们初始化所有的select添加option元素中于回显的值重复 ...

  10. 表A中有两个表示时间的字段A,B;如果B的值大于A的值,则把B的值更新为A的值

    sql语句:表A中有两个表示时间的字段A,B:如果B的值大于A的值,则把B的值更新为A的值 update 表名 set B=A where B>A

随机推荐

  1. springCloud的使用04-----熔断器hystrix的使用

    1. restTemplate+ribbon使用hystrix 1.1 引入依赖 <!-- 配置hystrix断路器 --> <dependency> <groupId& ...

  2. POJ:3371 Connect the Cities(最小生成树)

    http://acm.hdu.edu.cn/showproblem.php?pid=3371 AC代码: /** /*@author Victor /* C++ */ #include <bit ...

  3. getopts举例

  4. services - Internet 网络服务列表

    DESCRIPTION(描述) services 是一个普通的 ASCII 码文件, 它在 internet 服务的友好原文名以及这些服务预先分配的端口和协议类型之间提供了映射. 每个联网程序必须查找 ...

  5. tomcat-性能优化参考

    转摘 http://blog.csdn.net/lifetragedy/article/details/7708724. ###jdk1.6.未验证.仅供参考### linux环境下Tomcat调优 ...

  6. 如何快速使用YOLO3进行目标检测

    本文目的:介绍一篇YOLO3的Keras实现项目,便于快速了解如何使用预训练的YOLOv3,来对新图像进行目标检测. 本文使用的是Github上一位大神训练的YOLO3开源的项目.这个项目提供了很多使 ...

  7. css 多行省略号兼容移动端

    浏览器兼容css样式 -webkit-line-clamp: ; display: -webkit-box; overflow: hidden; text-overflow: ellipsis; te ...

  8. 【leetcode】662. Maximum Width of Binary Tree

    题目如下: Given a binary tree, write a function to get the maximum width of the given tree. The width of ...

  9. Linux的软件包管理

    此博客的环境任意. 主题Linux的软件包管理 一软件管理工具 1编译安装      2rpm包管理          3yum管理 二软件运行和编译 1ABI 应用程序的二进制接口 ABI:Appl ...

  10. 大碗宽面Beta迭代阶段第十二周会议记录

    本周一晚上我们在熟悉的宿舍楼一楼大厅进行了本周的小组会议. 对于上周的任务,前端的同学修改统一了导航栏和footer,在课程评价界面中添加了“添加评论”功能,其中含有,是否修改过该课程的单选框,评论, ...