Date8

Arcpy:

引用当前的地图文档:

__author__ = "Brill"
#引用当前的地图文档
import arcpy.mapping as mapping
mxd = mapping.MapDocument("CURRENT")
mxd.title = "Crime Project"
mxd.saveAcopy("C:/ArcpyBook/Ch2/crim_copy.mxd")
View Code

引用磁盘上的文档:

__author__ = "Brill"
#引用磁盘上的文档
import arcpy.mapping as mapping
mxd = mapping.MapDocument("C:/ArcpyBook/Ch2/crim_copy.mxd")
print(mxd.title)
View Code

获取地图文档中的图层列表:

__author__ = "Brill"
#获取地图文档中的图层列表
import arcpy.mapping as mapping
mxd = mapping.MapDocument("CURRENT")
layers = mapping.ListLayers(mxd)
for lyr in layers:
    print(lyr.name)
View Code

获取地图文档中的图层的子集:

__author__ = "Brill"
#获取地图文档中的图层的子集
import arcpy.mapping as mapping
mxd = mapping.MapDocument("CURRENT")
for df in mapping.ListDataFrames(mxd):
    if df.name == "Crime":
        layers = mapping.ListLayers(mxd,'Burg*',df )
        for layers in layers:
            print(layers.name)
View Code

缩放所选要素:

__author__ = "Brill"
#缩放所选要素
import arcpy.mapping as mapping
mxd = mapping.MapDocument("CURRENT")
df = mapping.ListDataFrames(mxd,"Crime")[0]
layer = mapping.ListLayers(mxd,"Burglaries*",df)[0]
df.extent = layer.getSelectedExtent
View Code

改变地图范围:

__author__ = "Brill"
#改变地图范围
import arcpy.mapping as mapping
mxd  =  mapping.MapDocument("CURRENT")
for df in mapping.ListDataFrames(mxd):
    if df.name == 'Crime':
        layers = mapping.ListLayers(mxd,'Crime Density by School District',df)
        for layer in layers:
            query = '"NAME" = \'Lackland ISD\''
            layer.definitionQuery  = query
            df.extent = layer.getExtent()
View Code

添加图层到底图文档:

__author__ = "Brill"
#添加图层到底图文档
import arcpy.mapping as mapping
mxd = mapping.MapDocument("CURRENT")
df  = mapping.ListDataFrames(mxd)[0]
layer = mapping.Layer(r"C:\ArcpyBook\data\School_Districts.lyr")
mapping.AddLayer(df,layer,"AUTO_ARRANGE")
View Code

 

转载于:https://www.cnblogs.com/genghenggao/p/9054923.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值