[Shapelib] shpsort

Frank Warmerdam warmerdam at pobox.com
Wed Jun 23 18:12:20 PDT 2004

Eric Miller wrote:
> I threw together the following script using your shapelib.  It basically
> copies a shapefile to a new shapefile after having sorted on a given
> field (or the "SHAPE" pseudofield for polygons and polylines).  It can
> be useful when you need to force a particular drawing order and don't
> have any way to do so other than changing the order of the items in the
> shapefile.  For instance, maybe a polygon layer has overlapping
> polygons, so you want the ones with small area drawn after the ones with
> large areas (small on top).
> I've tested it some, but probably not as thoroughly as I should. 
> Anyway, if you want to drop it in your contrib/ directory, you can.  If
> it sucks too hard, you can throw it away.  It needs both shpopen.c and
> dbfopen.c for compilation.


I have incorporated shpsort in the contrib area in CVS and it will be in the
next shapelib release, albeit there may not be any more documentation than
you have already provided.  I am also cc:ing your description to the shapelib
mailing list in case anyone else is interested in the utility before the next
shapelib release.

It can be found at:


Best regards,

I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the Shapelib mailing list