While most GIS applications work with delimited text inputs, sometimes you just have to have a shapefile. Amongst many other things, Frank Warmerdam wrote the Shapefile C Library, which comes with a few simple tools. I suspect Frank meant the little utilities to be code samples that wouldn’t see much use, but they do the job.
Let’s take the coordinates 43.73066°N, 79.26482°W from my first entry. I will make a single point shapefile with this coordinate.
First you have to make the SHP file and the DBF database:
dbfcreate junction -s Name 16 shpcreate junction point
This makes an empty shapefile for storing points, with one string field ‘Name’ of width 16 characters.
Now you have to add your point – this takes two stages, adding the database row, and then adding the geometry:
dbfadd junction.dbf 'Chevron/Kenmark' shpadd junction.shp -79.26482 43.73066
And that’s it – you’ve made a trivial shapefile.
One reply on “making trivial shapefiles with shapelib”
Just as a placeholder, here’s a handy way of adding labels with a line length: http://qgis.spatialthoughts.com/2010/10/calculating-line-lengths-and-statistics.html