How to sum up values of neighbouring polygons in QGIS? This question was asked on gis.stackexchange, with two interesting answers. One answer explains how to use Spatialite and SQL to achieve this. The other answer, explained in more detail here, presents a script using pyqgis and shapely. In this post I am using an alternative approach, using GRASS GIS. Continue reading “Sum up values of neighbouring polygons – a GRASS GIS approach”
Tag: SQLite
Find and select duplicate values in your vector attribute table
Suppose you have a vector layer in your GRASS GIS database and you want to find all duplicate values in one of the columns of the attribute table of that layer?
If you are using SQLite or PostgreSQL as the database back-end (and you should), this is easy using a SQLite statement. Suppose you have the table sp1th and the column value with duplicate values: Continue reading “Find and select duplicate values in your vector attribute table”
Split strings in SQLite
I am just back from vegetation survey in Kenya and Uganda. Before starting with the analysis, I will have to go through the more boring data entry and organization. I will use a Spatialite database to store all the data as it plays nicely together with QGIS as well as R. For example, importing the waypoint data (gpx format) into a spatialite database is a breeze with the QSpatialite plugin for QGIS.
One problem is that data and time in the gpx file are given in one field, in the form ‘2011/11/01 5:49:41+00‘. There are various ways I could split this before importing in the SQLite database, e.g., using R or a spreadsheet. But how to do this after importing the data in the Spatialite database? The date + time are imported in the field ‘time‘. Continue reading “Split strings in SQLite”
Concatenate in SQLite
I wrote before on using concatenate in OpenOffice / LibreOffice and how this alternatively can be done in R using the paste function. You can do the same in SQLite using a query too. Continue reading “Concatenate in SQLite”
Select random sample from SQLite table
I came across this post by underdark about how to select a random sample from a table in PostgreSQL. You can achieve the same (selecting 1000 random features from a table) in SQLite using something like below: Continue reading “Select random sample from SQLite table”
Finding and removing carriage returns in your SQLite table
The problem with copy data from e.g., an excel or calc sheet into an SQLite database (or any database I reckon) is that the data you copy might include an carriage return. I found this out the hard way after having copied data from a spreadsheet into a attribute table of a GRASS GIS vector layer (which is stored in a SQLite database). Continue reading “Finding and removing carriage returns in your SQLite table”