- Programming ArcGIS 10.1 with Python Cookbook
- Eric Pimpler
- 287字
- 2021-07-30 17:29:56
Referencing map documents on a disk
In addition to being able to reference the currently active map document file in ArcMap, you can also access map document files stored on a local or remote drive using the MapDocument()
method. In this recipe, you'll learn how to access these map documents.
Getting ready
As I mentioned earlier, you can also reference a map document file that resides somewhere on your computer or a shared server. This is done simply by providing a path to the file. This is a more versatile way of obtaining a reference to a map document because it can be run outside the ArcGIS Python window or a custom script tool.
How to do it…
Follow these steps to learn how to access a map document stored on a local or remote drive:
- Open the IDLE development environment from Start | Programs | ArcGIS | Python 2.7 | IDLE.
- Create a new IDLE script window by selecting New | New Window from the IDLE shell window.
- Import
arcpy.mapping
:import arcpy.mapping as mapping
- Reference the copy of the
crime
map document that you created in the last recipe:mxd = mapping.MapDocument("c:/ArcpyBook/Ch3/crime_copy.mxd")
- Print the title of the map document:
print mxd.title
- Run the script to see the following output:
Copy of Crime Project
How it works…
The only difference between this recipe and the last is that we've provided a reference to a map document file on a local or remote drive rather than using the CURRENT
keyword. This is the recommended way of referencing a map document file unless you know for sure that your geoprocessing script will be run inside ArcGIS, either in the Python window or as a custom script tool.
- ExtGWT Rich Internet Application Cookbook
- Learn Type:Driven Development
- Java游戲服務(wù)器架構(gòu)實戰(zhàn)
- 程序員考試案例梳理、真題透解與強化訓(xùn)練
- 編寫高質(zhì)量代碼:改善C程序代碼的125個建議
- Silverlight魔幻銀燈
- Learning OpenStack Networking(Neutron)
- Hands-On JavaScript for Python Developers
- Qlik Sense? Cookbook
- Lift Application Development Cookbook
- jQuery技術(shù)內(nèi)幕:深入解析jQuery架構(gòu)設(shè)計與實現(xiàn)原理
- Photoshop CC移動UI設(shè)計案例教程(全彩慕課版·第2版)
- Python機器學(xué)習(xí)開發(fā)實戰(zhàn)
- 金融商業(yè)數(shù)據(jù)分析:基于Python和SAS
- JavaScript前端開發(fā)基礎(chǔ)教程