arcpy处理mdb中的要素数据集和要素类

最近在测试如何获取mdb中的要素数据集,并且查询mdb要素类的属性表内容。

测试数据

使用ArcMap的python环境(‪C:\Python27\ArcGIS10.7\python.exe),并使用下述代码进行测试,发现能够将mdb中要素数据集名称获取到,并且能够查询指定要素类的内容。

import arcpy
import os
ws = r"E:\test\testcwd.mdb"
arcpy.env.workspace = ws
fdss = arcpy.ListDatasets()
print fdss
fdss.append('')  # for those fc that reside in the root of the sde ws

for fds in fdss:
    fc_names = arcpy.ListFeatureClasses(feature_dataset=fds)
    for fc_name in fc_names:
        fc = os.path.join(ws, fds, fc_name)
        # do somthing with the fc
        print fc
#fc = r"E:\testing\test.gdb\b1"
fc_name1="area"

with arcpy.da.SearchCursor(fc_name1,"Shape@xy") as cursor:
	for row in cursor:
		print row

打印结果:

[u'jihetest']
E:\test\testcwd.mdb\jihetest\source2
E:\test\testcwd.mdb\jihetest\destination2
E:\test\testcwd.mdb\area
((6.790417257666718, 39.86516325366673),)
((6.92234888400003, 39.92592123933338),)
((6.823860585633426, 40.00989749142422),)

但是当使用C:\Python27\ArcGISx6410.7\python.exe环境,使用相同代码和数据,却不能获取mdb要素数据,打印结果如下:

[]
Traceback (most recent call last):
  File "D:/java/pycharmExample/ArcpyExample/ArcMapPython32/getListAndSearchFromMDB.py", line 18, in <module>
    with arcpy.da.SearchCursor(fc_name1,"Shape@xy") as cursor:
RuntimeError: cannot open 'area'

通过查找发现mdb在64位的python环境不被支持,详情见链接:
Python scripting with 64-bit processing - https://www.esri.com/arcgis-blog/products/arcgis-desktop/analytics/python-scripting-with-64-bit-processing/
Background Geoprocessing (64-bit) - https://desktop.arcgis.com/en/arcmap/latest/analyze/executing-tools/64bit-background.htm
因此如果想获取要素数据集以及查询要素类,可以通过使用gdb或者使用python 32位环境来实现需求。

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值