Abstract: 1.Learn basic knowledge First of all, I suggest you learn the basic knowledge of Python first. In order to use Python in GIS, yo...
1.Learn basic knowledge
First of all, I suggest you learn the basic knowledge of Python first. In order to use Python in GIS, you need to understand Python syntax, data types, commands, built-in functions, loops, etc. If you are not familiar with programming, you may encounter many difficulties at the beginning because Python has many built-in functions. Of course, there is no need to go deep into all the knowledge points - with some basic knowledge, you can use Python in GIS. It is recommended that you learn how to view the help file in the IDE and list the available methods, functions and modules instead of searching the external help file. You let you save more time.
For python beginners, there are many free python beginner tutorials that can be learned online. Almost all the tutorials will teach you: string, function, data type, syntax, which are very important. But you can skip the theory of object-oriented programming, because for python scripts, you may not know this. If you want to use Python to develop GIS applications, you can learn again.
At this time, you must first install a local version of python (www.python. org) on your computer, or you can choose an online IDE, such as python fiddle, which can be written and run through a web browser. No matter what method you choose, you can choose different versions of python - it is recommended that GISer learn python 3, because this is the trend. However, this does not mean that python 2 has no value, on the contrary: for example, arcgis desktop uses python 2, which is likely to last for a period of time. To understand the differences between the two versions, you can search the engine yourself.
If Arcgis desktop is installed on the computer, python will be installed automatically, and IDLE (python-gui) is pre-installed. You can write code directly in it. Press Enter to execute the code and print the result.
2.Grasp basic knowledge through practice
Learning any language is the same, we must do a lot of practice. Once you are familiar with the basic knowledge, you should study the working principle of Python scripts and learn the difference between writing and running scripts and using interactive Python interpreters. Because this is not covered in many online courses, it may require some online search. Search skills are necessary for GISer.
It is recommended to use IDE (integrated development environment) to write and run Python scripts. This is just a software that works as a code editor, enabling you to write, run, debug and save code. You can download and install (free) IDE (such as python win) on your computer, and write, run and debug scripts from it. IDEs are the preferred place to write code because they can help you color your code to different colors, making it easier to find errors.
Here, you may need to check some built-in functions of Python, such as the math module in the standard library included with the Python installation, which is included with the Python installation. Handling simple mathematical problems is an important part of GIS and Python. Since python supports geometry objects in GIS, it is important to understand the geometry available in this library. For details, please refer to the help document of python. Other skills that will be useful in the future include using python to write data to a new file, setting the source data path correctly, how to write SQL statements correctly in python, using the "try and exception" code block, and understanding various error messages.
3.Using Python in ArcGIS
After some basic Python exercises, we will continue to use Python in Arcgis. ArcGIS users (including ArcMap and ArcGIS Pro) mainly use ArcPy package to deal with geographical problems, which includes all geographical processing functions. In particular, Arcgis Pro uses python 3, while Arcmap uses version 2. The python window in ArcGIS is a very friendly interactive help window. It can automatically complete functions and help write code by specifying the parameters of the tool, thus saving a lot of time. This is a good way to learn arcpy and should be your first step. Once you are sure to use arcpy, try to write some independent scripts with local GIS data, run them, and see what happens.
It is important to have some common sense: misspelled file names and paths are common, which may lead to errors. Even if a python script has been correctly checked by the IDE, it may contain errors, such as misspelled file names, paths, commands and tools. Using uppercase incorrectly is also a common error, and python is very sensitive to this. You can control the process of the script by letting the script print messages to view the progress. If there are no errors when the script terminates, you can open the result window in arcmap. If the output does not meet expectations, there may be a problem with the code.
To become familiar with arcpy and python scripts, there are many online tutorials. Similarly, we should start from the basics and then slowly deal with more complex problems. The arcgis help document is an important resource for learning arcpy. There are also a large number of annotated sample scripts and sample data in it.
4.Learn more
With some Python experience, you may be interested in knowing what to do next. Before delving into other languages and/or frameworks, you can improve the current Python code, for example, by refactoring it if possible. Find new geospatial modules to make your coding easier. Compare the work of others and use their good coding habits to improve your work.
The learning path described above is time-consuming and iterative - you will find yourself going back and forth between different stages, learning new things every day. But it is also interesting and full of surprises. The more you learn and practice, the easier it will be. Finally, you can also think about many other geospatial databases and learn R language.
After learning Python/Python scripts and programming using ArcGIS, there are many options to continue your GIS programming journey. Here are some options. Take the ArcGIS Python API released by Esri as an example. This API supports the use of Python and maps on the web to extend its application beyond desktop GIS. ArcGIS JavaScript API is another programming language that allows you to interact with maps through a browser. Because web technology is everywhere, the next step after learning Python is best to start with HTML CSS and then turn to JavaScript. After getting familiar with the basics, you will find that JavaScript also provides many useful libraries and frameworks worth learning.