当前位置:网站首页>Arcpy 添加图层到地图文档
Arcpy 添加图层到地图文档
2022-06-22 12:20:00 【YuanYWRS】
【原理】:使用【AddLayer()函数】把图层添加到地图文档里。
【说明】:本实验的代码思路以及数据均来自于牟乃夏老师的书【基于Arcgis的python编程秘笈】。
【思路】:
1:导入【arcpy.mapping模块】,并获取对当前活动地图文档的引用。
2:创建一个新的变量【df】存储对crime数据框的引用,该引用是通过【ListDataFrames()函数】返回数据框列表使用【0】访问列表中的第1项元素来获取。
3:创建一个实例【layer】,layer变量引用存储在本地的为【school_Districts.lyr】的图层文件。
4:调用【AddLayer()函数】传入3个参数:【图层要添加到的数据库df】、【引用的图层layer】、【自动排序方式auto-arrange】。
【代码操作】:
import arcpy.mapping as mapping #导入【arcpy.mapping】模块。
>>> mxd=mapping.MapDocument("CURRENT") #引用当前的地图文档,并把引用赋值给变量。
>
>>> df=mapping.ListDataFrames(mxd)[0] #创建一个新变量【df】存储对【crime数据框】的引用,该引用是通过【ListDataFrames()函数】返回数据框列表使用【0】访问列表中的第1项元素来获取。
>
>>> layer=mapping.Layer(r"D:\暂时存放\ArcpyBook\data\school_Districts.lyr") #创建layer对象,该对象引用一个图层文件。
>
>>> mapping.AddLayer(df,layer,"AUTO_ARRANGE") #将图层加载到数据框中。
【结果】:
边栏推荐
- 天翼云探索云原生、边缘计算融合新思路
- Isn't this another go bug?
- Parallels Desktop 17.1.4pd虚拟机
- Es aggregation details
- 【极术读书】Arm64学习经验分享 by奔跑吧社区
- [Jishu reading] arm64 learning experience sharing by running bar community
- Sap-abap- how to open a local file
- Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值
- 智龄语音+php
- Sap-abap- how to transfer material master data, supplier master data, work orders, purchase orders and other information to external systems in real time - implicit enhancement.
猜你喜欢

Hurun Research Institute launched the list of potential enterprises of China's meta universe, and Jushan database was selected as the future star enterprise

MySQL_ Query of data processing

巨杉数据库受邀出席鲲鹏开发者年度盛会2022,共建国产化数字底座

建立自己的网站(5)

推荐一款M1芯片电脑快速搭建集群的虚拟机软件

仿网易云音乐的滑动冲突处理效果

Tianyi cloud explores a new idea of cloud native and edge computing integration

Final of the 11th Blue Bridge Cup embedded design and development project

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

SAP-FI-财务报表版本设定
随机推荐
SAP ABAP ole core code
MySQL_ Addition, deletion and modification of data processing
SAP-ABAP-如何打开本地文件
1961 check if string is a prefix of array
SAP-ABAP-如何用WEBAPI的方式调用外部接口
定金预售的规则思路详解
Correct posture of MySQL executing script
What is C language structure byte alignment and why?
Flutter mixed development exercise - large picture of collaborative loading of ever & method channel
Tis tutorial 01- installation
Small demo of QT page layout class
SNC processing failed SAP router certificate regeneration
[game] Zhou Yu's skills
智龄语音+php
Getenv, setenv functions (get and set system environment variables) and environment variables
银行支付接口开发之子账户
Wisdom age voice +php
【mysql】where 和 having 的区别
In C # development, the third-party components lambdaparser, dynamicexpresso and z.expressions are used to dynamically parse / evaluate string expressions
MAUI使用Masa blazor组件库