In this task we will see how to get the attributes of a vector layer and export them in a text file. Furthermore, at the end of the task we will order these attributes alphabetically before writing them in the output file. As a sample, we will use the vector layer that we have filtered in […]Read more "How to export attributes from QGIS to a .txt file using Python"
In this task we will see how to generate a vector grid of regularly spaced points. The Processing algorithm Regular points does the same thing, but we want to do it using Python. We assume to start from a layer that is already loaded in QGIS (if not, please see here) because we need to […]Read more "How to generate regularly spaced points in QGIS using Python"
In this task we will see how to load a layer in QGIS and add it to the map. All the operation are similar for both raster and vector layers. The first operation is to select the Python Console from the Plugins menu: Then, if you have to load a Vector layer: If you have to load a […]Read more "How to load a layer in QGIS using Python"
In this task we will load a vector layer representing some data about population and use python scripting to select all the cities with more than one million people. We will use a dataset from Natural Earth: download the population shapefile here. The data about city population are contained in the attribute “pop_max”, as you can see […]Read more "How to select features in QGIS using Python"
We’ll perform a spatial operation, using Python, to select all the points that intersect a polygon. Firstly, we need a point layer and a polygon layer: Method 1 Use this method if your layers are not already loaded in QGIS. Otherwise, directly skip to Method 2. Method 2 Use this method if your layers are […]Read more "How to filter a layer by geometry in QGIS using Python"
Creating a layer using Python is quite simple. In the following steps, we’ll create a vector layer in memory and display it on the map. First of all, enable the Python Console from the Plugins Menu (it is available in the QGIS main window). A point is created as follows: The result is: We have just […]Read more "How to create a layer in QGIS using Python"
Hi to all! As you have read from the header, this is a blog about QGIS. I’m Marco and I’m using QGIS from more than three years for personal purposes. The goal of this site is to provide some suggestions for solving problems that may arise while using QGIS. When possible, these tips are offered through simple code samples […]Read more "Let’s start!"