Getting Started with ArcPy
ArcPy is a Python site package that provides a useful and productive way to perform geographic data analysis, data conversion, data management, and map automation with Python. It is a powerful tool that allows GIS professionals and programmers from many different disciplines to access and work with geographic data.

What is ArcPy?
ArcPy is a Python site package used with ArcGIS Pro or ArcMap. It provides a rich, native Python experience offering code completion and reference documentation for each function, module, and class. It is interpreted and dynamically typed, which provides you with the ability to quickly prototype and test scripts in an interactive environment while still being powerful enough to support the writing of large applications.
Working with ArcPy
One of the first operations you do with an ArcPy script is to reference an existing project or layer file that you want to work with. Here is an example of how to reference a project currently loaded into ArcGIS Pro:
import arcpy
aprx = arcy-mp. ArcGISProject ("CURRENT")
This code references a project currently loaded into ArcGIS Pro and assigns it to the variable aprx.
Automating Map Creation
ArcPy can be used to automate the creation of map layers and export images. For instance, you can add a layer file to the map once you have a reference to a project. Here is an example of how to add a layer file to a map:
mxd = arcpy-mapping-MapDocument (r"C: \Project \Project.mxd")
for elm in arcpy mapping. ListLayoutElements(mxd, "PICTURE_ELEMENT"):
if elm.name == "Photo" :
elm. sourceImage = r"C: \Project \Data\NewPhoto.bmp"
mxd. save ()
del mxd
This script finds an image by name and sets its data source to a new location.
Difference Between Python and ArcPy
Python is a general-purpose programming language that is widely used in many fields, from web development to data science. It is known for its simplicity and readability, making it a great choice for beginners and experts alike.
On the other hand, ArcPy is a Python site package that provides a useful and productive way to perform geographic data analysis, data conversion, data management, and map automation with Python. It is a powerful tool that allows GIS professionals and programmers from many different disciplines to access and work with geographic data.
Here are some key differences between Python and ArcPy:
- Scope: Python is a general-purpose language used in a wide range of applications, while ArcPy is specifically designed for geographic data analysis and map automation.
- Functionality: Python provides a broad range of functionalities through its extensive standard library and third-party packages. ArcPy, as a Python package, extends Python’s functionality to include operations specific to ArcGIS, such as spatial data analysis, data conversion, data management, and map automation.
- Usage: Python can be used independently of any specific software, while ArcPy is used within the ArcGIS software environment.
- Licensing: Python is open-source and free to use and distribute. ArcPy, on the other hand, is part of the ArcGIS software suite, which requires a license.
Applications of ArcPy
- Geographic Data Analysis: ArcPy provides a range of functionalities for geographic data analysis. It allows GIS professionals and programmers to access and work with geographic data.
- Data Conversion and Management: ArcPy can be used for data conversion and management. It provides functions for converting data formats, managing data files, and automating data processing tasks.
- Map Automation: ArcPy can be used to automate map creation and manipulation. For example, you can use ArcPy to add layers to a map, set layer properties, or export a map to a different format.
- Scripting and Automation: ArcPy can be used to write scripts that automate repetitive tasks. This can save time and ensure consistency in your GIS workflows.
- Integration with ArcGIS: ArcPy is used within the ArcGIS software environment. It allows you to use, automate, and extend desktop GIS.
- Web GIS: ArcPy and ArcGIS API for Python are complementary libraries; ArcPy allows you to use, automate, and extend desktop GIS, and ArcGIS API for Python supports the same for Web GIS.
Conclusion
ArcPy is a powerful tool for automating and enhancing your GIS workflows. It provides a wide range of functionalities, from basic geographic data analysis to complex map automation. With ArcPy, you can write scripts that produce consistent results, save time on repetitive tasks, and customize your GIS applications. While Python and ArcPy might seem similar due to ArcPy being a Python package, they serve different purposes. Python is a versatile, general-purpose programming language, while ArcPy is a specialized tool for GIS professionals that extends Python’s capabilities into the realm of geographic data analysis.
Mr. Harshad Anirudha Mulkar (M.Sc Geoinformatics & Computer Science)



