I would like to use one of the aspatial fields (the field containing 00256 in this case) as text for plotting a label. But how to do this?
Getting the text out and then figuring out the centroid as plotting position sounds like a plan, but seems intricate for such an easy task (…)
Easy task for the user if that was all implemented. text does no take data, computing a centroid, then gets a string and plots it. gmt spatial can compute centroids, but not sure how then to get the text item out for a polygon.
For now, I used QGIS with it’s spatialite(?) support and ran sql to produce a simple output of x, y, text (x and y of the centroid of the polygon), which I then exported as a gmt chewable csv file;
SELECT st_x(Centroid(geom)), st_y(Centroid(geom)), text FROM table
Petty, because ogr2ogr is wrapped so it should really be a one-liner. Except that I’m still to learn how to use it and hidden bugs are always around the corner.
I’m fairly sure I could’ve done this with a one liner in ogr2ogr as well. But, it’s so nice to get a visual confirmation that what you’re doing (at least) looks right.
One click solution in QGIS is Vector -> Geometry tools -> Centroids. Good thing here is that the resulting file also contains all your metadata so that you can pass x, y, MyLabelAttribute to gmt text