Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Archive for June, 2013

Cartographic tricks and tips– making text readable, PostGIS edition

Posted by smathermather on June 29, 2013

Recall from previous post, I played a bit with using convex polygons and buffers to control noisy backgrounds behind text, ala:


golf_orig ——–>golf_final

I was tired of doing this in the GUI in QGIS, so I wrote some simple code to do it in PostGIS.

CREATE TABLE cm_label_cvx AS
WITH buffer_cvx AS (
    SELECT ST_Buffer(ST_ConvexHull(geom), 250) AS geom FROM cm_label_med)
    SELECT ST_Union(geom) FROM buffer_cvx;

Posted in PostGIS | Tagged: , , | 1 Comment »

OGR for merging shapefiles

Posted by smathermather on June 8, 2013

I upgraded to Ubuntu 12.10.  It’s nice, but it means I can no longer run QGIS 1.9 easily, so I’m limping along with 1.8, and without functional python extensions at that.

So, when I wanted to merge a directory of 60 some odd shapefiles, I turned to OGR.  GIS Programming at shows how to do it on Windows.  Here’s the linux/BASH way:

for f in *.shp; do ogr2ogr -update -append merge.shp $f -f "ESRI Shapefile"; done;

Posted in OGR | Tagged: | Leave a Comment »