Tag Archives: vector layer

Point coordinates to polygon – part II

In my previous article, I showed how you can convert point coordinates into a polygon vector layer in QGIS. So how about GRASS GIS? Like in my previous post, let’s assume you have a text file with two columns with the coordinates. With the v.in.ascii function you can import this text file as a point layer. Next, you can use v.hull or v.delaunay to create polygon layers.

With a little bit more work, you can convert the above mentioned text file into a ASCII vector file. Continue reading

Exporting vector layer as kml in QGIS

In my previous post I described how to export a vector layer from GRASS GIS as kml file. The key was to use the dsco parameter to define the columns that should be used for the Name and Description fields in your kml file.

In QGIS you use the ‘save as’ option in QGIS. You can get this using the context menu (right click mouse on the layer) or the menu ‘Layer | Save as..’. In the menu that opens, there are two fields under the header ‘OGR creation options’; ‘Data source’ and ‘Layer’. Continue reading

Exporting point file as kml in GRASS GIS

The v.out.ogr function in GRASS GIS let you export your vector layer to any format supported by OGR (it is basically an interface to the GDAL/OGR function ogr2ogr). This includes kml files. E.g.,

v.out.ogr input=labels layer=1 dsn=/home/paulo/test.kml format=KML

will export the vector layer ‘labels’ as the kml file test.kml Continue reading

From attribute table to QGIS style file – step 1

I have a large number of GRASS vector layers with in the attribute table a RGB column defining the colours of the corresponding mapping units. Unfortunately, unlike GRASS, QGIS does not offer the option to to set colours from an RGB column. The feature has been requested before, but it isn’t implemented (yet).

As an alternative, I want to create a R script that takes the RGB values from the attribute tables and uses this to create a QGIS style file (qml file). Continue reading

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

Extract X and Y coordinates from a spatial table in Spatialite

A quick note on adding two columns with X and Y values in a vector layer in spatialite. Spatialite stores the information about the geometry in binary format in the ‘Geometry’ field.

You can use the Spatialite function AsText() to convert and extract these values as a Well Known Text (WKT), which is an easy to read format. If you for example have a spatial table ‘Waypoints’ with two columns ‘PKUID’ and ‘Geometry’, you can extract a column with WKT values using: Continue reading