Kiến thức

Do you need to learn Geospatial Python?

21/05/2021 GeoLink Thu Giang 0 Nhận xét

Python is believed to be a great language for geospatial projects. Anita Graser is a legendary open-source geospatial Python expert. She’s been working with QGIS and Python since 2008 as an integration solution to automate mapping and to look at data in different fashions, not just from the command line or in graphs but also in maps. Let’s hear from her why Python may or may not be a good option for your GIS project.

Why should GIS practitioners learn Python?
It wasn’t always clear that Python would be the best language for GIS. Not until ArcPy and PyQGIS came out around 12 years ago. These two implementations taught us that Python is versatile and easy to learn, and you can manipulate data with it. Who in the GIS world wouldn’t want to use a flexible tool for wrangling their data from a file or a database into something usable?  Python does precisely that.

It’s also easy to interface it with PostgreSQL and PostGIS, and the possibilities are endless from then on for automating workflows with scripts.  For model builders, for example, it’s possible to export models as Python scripts or write them from scratch in whichever workflow you prefer. There is also a vast opportunity of building extensions for desktop GIS and server-side GIS applications using Python with plugins in open-source as well as in proprietary systems.

There are many reasons why Python is now the universal language of GIS – it’s a glue that holds things together. Once you know Python and realize its usefulness for geospatial data manipulation, you are no longer just pushing buttons provided to you, you are in control and have the freedom to create your own tools and processes. It has an element of self-documentation that’s hard to find.  You can’t forget to document a certain parameter when you’re writing code, and you can look it up later if you need to go back. This is helpful in cases when you inherit someone else’s workflow.

Python is widely adopted in the geospatial world and as such geospatial processes written in python are sharable and repeatable. While there may be different environmental variables that need to be tweaked and data that also needs to be shared, it is possible to share your work and let others use your code and build on top of your work.

Is Python difficult to learn?
If you already know some programming language, it’s possible to get into geospatial and apply Python specifics as you go because it’s not a hard language to learn.

If you don’t have a programming background, you’d be smart to cover the basics first, such as loops, functions, classes.

In both cases, most users, especially GIS people, do better if they have geospatial specific motivation and inspiration. They want to see something on a map, really quick.  They want the first steps into this new, unknown to be related to what they do in geospatial.

A good intro to writing Python code is to create a model in a graphical model building and then export it a Python script. You can play around with feeding data the different parameters in the script and see how they affect the outcome. This also gives you an understanding of how Python code is structured and how the different components are chained together.

When people see that they’re not tied to the standard tools in the graphical interface, they realize how flexible programming is and how much they can get out of a model builder.  This is real motivation.

Model builder scripts are only the first step.  Once you start executing things outside of the program, like manipulating parameters, you’ll come across things you can’t solve quickly with a model builder.  Knowing Python and how you can program something from scratch is a great motivation.

Source: Geospatial World
 

popup

Số lượng:

Tổng tiền: