一、工具截图






二、导出文件

三、脚本

# coding=utf-8
import json
import sys
import arcpy
import osdef set_encoding():"""set system encoding."""a, b, c = sys.stdin, sys.stdout, sys.stderrreload(sys)sys.setdefaultencoding("utf-8")sys.stdin, sys.stdout, sys.stderr = a, b, cdef ring_point_count(feature):"""count point number.:type feature: dict:param feature::return:"""count = 0for ring in feature["geometry"]["rings"]:count += len(ring)return countdef reset_num(coordinate):"""reset last one serial number.:type coordinate: list:param coordinate:"""coordinate[-1][0] = "J1"def load_json(path):"""load json file from disk.:type path: str:param path::return:"""with open(path.decode("utf-8"), "r") as f:return json.load(f)def feature_maps(features, configure):"""get a new feature json of list.:param features::type features: dict:param configure::type configure: dict:return: feature json of list"""maps = []feature_map = []point_max = int(configure["attr-desc"]["point-max-num"])count = 0index = 1for feature in features:rp_count = ring_point_count(feature)if (count + rp_count) > point_max:maps.append(feature_map)feature_map = []count = 0index = 1index_feature = {"index": str(index),"rp_count": str(rp_count),"attributes": feature["attributes"],"rings": feature["geometry"]["rings"]}feature_map.append(index_feature)count += rp_countindex += 1maps.append(feature_map)return mapsdef analyse_overview(feature, configure):"""get a overview info.:type configure: dict:type feature: dict:param feature::param configure::return:"""attributes = feature["attributes"]# 坐标点个数,地块面积,地块号,地块名称,图形属性,图幅号,地块用途,备注,@return "{coordinate_count},{area},{plot_num},{plot_name},{attribute},{sheet_designation},{land_use},{remark},@".format(coordinate_count=feature["rp_count"],area=attributes[configure["layer-meta"]["serial-num-field"]],plot_num=attributes[configure["layer-meta"]["area-field"]],plot_name=configure["attr-desc"]["prefix"] + feature["index"],attribute="",sheet_designation="",land_use="",remark=configure["attr-desc"]["layer-remark"])def analyse_coordinates(feature):"""get coordinates from feature.:type feature: dict:param feature::return:"""rings = feature["rings"]coordinates = [[["J" + str(index + 1), str(ring_index + 1), ",".join(list(map(str, coordinate[:])))] for index, coordinate inenumerate(ring)] for ring_index, ring in enumerate(rings)]return coordinatesdef create_dir(path):""":type path: str:param path:"""if not os.path.exists(path.decode("utf-8")):os.makedirs(path.decode("utf-8"))else:arcpy.AddError(path.decode("utf-8") + "目录已存在")def write_header(f, configure):attr_desc = configure["attr-desc"]f.write("[属性描述]\n")f.write("格式版本号=" + attr_desc["version"] + "\n")f.write("数据生产单位=" + attr_desc["producer"] + "\n")f.write("数据生产日期=" + attr_desc["date"] + "\n")f.write("坐标系=" + attr_desc["coordinate"] + "\n")f.write("几度分带=" + attr_desc["degree"] + "\n")f.write("投影类型=" + attr_desc["projection"] + "\n")f.write("计量单位=" + attr_desc["unit"] + "\n")f.write("带号=" + attr_desc["degree-num"] + "\n")f.write("精度=" + attr_desc["precision"] + "\n")f.write("转换参数=" + attr_desc["conversion-parameter"] + "\n")f.write("[地块坐标]\n")def convert(export_info, configure):"""create a new file of coordinates.:type export_info: dict:param export_info:"""geojson = load_json(export_info["jsonfile"])features = geojson["features"]create_dir(export_info["export_dir"])for index, feature_map in enumerate(feature_maps(features, configure)):out_filename = "{0}\\{1}-{2}.txt".format(export_info["export_dir"], export_info["filename"], str(index))with open(out_filename.decode("utf-8"), "w") as f:write_header(f, configure)for feature in feature_map:overview = analyse_overview(feature, configure)f.write(overview)f.write("\n")for coordinate in analyse_coordinates(feature):reset_num(coordinate)for item in coordinate:f.write(",".join(item) + "\n")def analyse_path(workspace, temp_workspace, layer):"""get export information.:type layer: str:type temp_workspace: str:type workspace: str:param workspace::param temp_workspace::param layer::return:"""filename = os.path.basename(layer).split(".")[0]export_info = {"layer": layer,"filename": filename,"jsonfile": "{root}\\{filename}.json".format(root=temp_workspace, filename=filename),"export_dir": "{root}\\{layer_dir}".format(root=workspace, layer_dir=filename)}return export_infodef check_path(workspace, temp_workspace, layers, skip_repeat):"""check whether the path exists.:param workspace::param temp_workspace::param layers::return:"""export_infos = []for layer in layers:export_info = analyse_path(workspace, temp_workspace, layer)if skip_repeat == "true":if os.path.exists(export_info["jsonfile"].decode("utf-8")):continueelif os.path.exists(export_info["export_dir"].decode("utf-8")):continueelse:export_infos.append(export_info)else:if os.path.exists(export_info["jsonfile"].decode("utf-8")):arcpy.AddError(export_info["jsonfile"] + "目录已存在")elif os.path.exists(export_info["export_dir"].decode("utf-8")):arcpy.AddError(export_info["export_dir"] + "目录已存在")else:export_infos.append(export_info)return export_infosdef export_json(export_infos):"""export all json file:param export_infos:"""for export_info in export_infos:arcpy.FeaturesToJSON_conversion(export_info["layer"], export_info["jsonfile"])def export_all_file(export_infos, configure):"""export file:param export_infos::param configure:"""for export_info in export_infos:convert(export_info, configure)def export_file(workspace, temp_workspace, layers, configure, skip_repeat):"""export file.:type configure: dict:type layers: list:type temp_workspace: str:type workspace: str:param workspace::param temp_workspace::param layers::param configure:"""arcpy.AddMessage("检查路径是否重复......")export_infos = check_path(workspace, temp_workspace, layers, skip_repeat)arcpy.AddMessage("导出JSON格式......")export_json(export_infos)arcpy.AddMessage("导出标准格式......")export_all_file(export_infos, configure)arcpy.AddMessage("导出完毕")if __name__ == "__main__":set_encoding()workspace = arcpy.GetParameterAsText(0)temp_workspace = arcpy.GetParameterAsText(1)layers = arcpy.GetParameterAsText(2).split(";")skip_repeat = arcpy.GetParameterAsText(3)configure = {"layer-meta": {"serial-num-field": arcpy.GetParameterAsText(4),"area-field": arcpy.GetParameterAsText(5),},"attr-desc": {"version": arcpy.GetParameterAsText(6),"producer": arcpy.GetParameterAsText(7),"date": arcpy.GetParameterAsText(8),"coordinate": arcpy.GetParameterAsText(9),"degree": arcpy.GetParameterAsText(10),"projection": arcpy.GetParameterAsText(11),"unit": arcpy.GetParameterAsText(12),"degree-num": arcpy.GetParameterAsText(13),"precision": arcpy.GetParameterAsText(14),"conversion-parameter": arcpy.GetParameterAsText(15),"prefix": arcpy.GetParameterAsText(16),"point-max-num": arcpy.GetParameterAsText(17),"layer-remark": arcpy.GetParameterAsText(18)},"encode": arcpy.GetParameterAsText(19)}export_file(workspace, temp_workspace, layers, configure, skip_repeat)

arcpy 土地整治报备坐标文件导出(解决内环问题)相关推荐

  1. 土地报备坐标文件(TXT)生成

    勘测定界.土地报件.增减挂钩.开发整理等项目涉及土地报备坐标文件生成工作,利用python结合ArcGIS提供arcpy站点包开发一个工具批量生成土地报备坐标文件. 1.土地报备文件模板 2.土地报备 ...

  2. lisp自动生成界址点表_基于AutoCAD VBA增减挂钩报备坐标文件自动生成.doc

    基于AutoCAD VBA增减挂钩报备坐标文件自动生成 基于AutoCAD VBA增减挂钩报备坐标文件自动生成 摘要:生成增减挂钩报备坐标文件是一项非常繁琐的工作,会占用大量工作时间.如果利用VBA对 ...

  3. 土地报备坐标txt文件转shp遇到的坑以及该功能的 Python(Arcpy) 实现

    文章目录 土地报备坐标txt文件转shp遇到的坑以及该功能的 Python(Arcpy) 实现 一. 使用 Python(ArcPy) 绘制shp 什么是ArcPy 如何构造shp(面) 主要涉及方法 ...

  4. arcgis 经纬度转大地坐标_土地报备坐标txt(坐标交换数据)转shp遇到的坑及其Python(ArcPy/ArcGIS)实现...

    目录 土地报备坐标txt文件(坐标交换数据)转shp遇到的坑以及该功能的Python(ArcPy/ArcGIS)实现 一. 使用 Python(ArcPy) 绘制shp 什么是ArcPy 如何构造sh ...

  5. ARCGIS之土地耕地占补平衡系统报备坐标txt格式批量导出工具(定制开发版)

    一.软件简介 本软件是基于arcgis二次开发的工具(插件),需要授权后才能使用: 本软件支持arcgis格式(shp/Mdb/Gdb/DWG )转换为设施农用地报备坐标TXT文件工具,目前,软件已经 ...

  6. ARCGIS之土地报备坐标(报盘数据)txt批量导出工具

    在勘测定界.土地报件.增减挂钩.开发整理等项目中经常用到! 一.主要依据标准<勘测定界界址点坐标交换格式> 二.软件功能:工具实现了arcgis常用格式SHP,Mdb.Gdb面图层批量导出 ...

  7. ARCGIS之设施农用地用地报备坐标txt格式批量导出工具(定制开发版)

    一.软件简介 本软件是基于arcgis二次开发的工具(插件),需要授权后才能使用: 本软件支持arcgis格式(shp/Mdb/Gdb/DWG )转换为设施农用地报备坐标TXT文件工具,目前,软件已经 ...

  8. ARCGIS之征地坐标xls和报备坐标txt格式批量导出工具(定制开发版)

    一.软件简介 一.软件简介 本软件是基于arcgis二次开发的工具(插件),需要授权后才能使用: 本软件支持arcgis格式(shp/Mdb/Gdb/DWG )转换为报备坐标TXT.征地xls文件工具 ...

  9. 2019FME博客大赛——基于FME的报备坐标(Excel或txt)与shp转换

    参赛单元:传统GIS数据处理 作者:廖超毅 单位:成都市国土资源信息中心 一.前言 自2017年毕业以来,接触了很多国土行业的东西,最令我头痛的问题还是把国土用地报备坐标表(下文简称"坐标表 ...

  10. VMware报错“锁定文件失败“解决方法

    VMware报错"锁定文件失败"解决方法 参考文章: (1)VMware报错"锁定文件失败"解决方法 (2)https://www.cnblogs.com/cb ...

最新文章

  1. 生成器、迭代器的区别?
  2. vuex的命名空间有哪些_专业餐饮全案策划设计公司报价?具体做哪些服务?
  3. 【ACM】熊孩子的乐趣
  4. AI芯片的“战国时代”:计算力将会驶向何方?
  5. 推荐7个冷门逆天的网站,每一款都是精品!
  6. 使用smack对tigase进行压力测试
  7. python代码翻译-python实现在线翻译
  8. php动态交叉表,PHP Array交叉表实现代码
  9. 大数据之-Hadoop之HDFS的API操作_配置参数的优先级说明_以设置hdfs文件副本数量参数为案例---大数据之hadoop工作笔记0057
  10. jsp mysql demo_echart通过jsp连接查询mysql的demo - 贪吃蛇学院-专业IT技术平台
  11. VIVADO常见警告、错误及解决方法
  12. mysql挂科了咋办_大学第一学期挂科怎么办?
  13. 数据挖掘近年来的研究方向、方法总结
  14. matlab分析电梯,一种基于Matlab/Simulink的电梯驱动系统建模方法
  15. 以太网详解(一)-MAC/PHY/MII/RMII/GMII/RGMII基本介绍
  16. ps关于去除脸上的痘痘问题和美白问题
  17. word删除括号里内容
  18. 数据结构与算法教程——App推荐
  19. excel表格末尾添加一行_七夕表白,用Excel试试!抖音爆红,一晚点赞破百万
  20. Python爬虫之爬取酷狗音乐歌曲

热门文章

  1. php源码 学校版 cms,S-CMS学校建站系统PHP源码(含小程序) v5.0 bulid20201126
  2. 手把手教你做一个简单的VB数据库程序
  3. BXP无盘技术应用于网吧的一些经验(转)
  4. VBoxGuestAdditions加载不了
  5. My New Game2
  6. 图(一)| BFS与DFS算法 - Python实现
  7. 2013Esri全球用户大会QA之Esri公司概况及未来发展
  8. 再战图形,一图一世界
  9. Python机器学习笔记 GridSearchCV
  10. odis工程师使用教程_大众奥迪工程师软件ODIS-E车型代码说明大全完整版