SHPREWIND(1)
π SHPREWIND β shplib π
okay so bestie, we're doing shprewind from the shplib crew, and honestly? it's a little glow-up tool for shapefiles. let's get into it β¨
β¨ NAME β¨
shprewind β it validates the winding order of rings and then resets it π
π¦ SYNOPSIS π¦
shprewind in_shp_file out_shp_file
πΈ DESCRIPTION πΈ
so basically: shprewind checks the winding order of the rings inside polygon geometries, and resets them so they match the ordering that the shapefile specification demands. why do we care? because it's literally made for shapefiles that are out here struggling β like, the ones that get messy when you check them with a shpdump -validate. π
what it actually does: it makes a copy of the shapefile in_shp_file to out_shp_file, and on the way it fixes the orientation of the points in the rings of Polygon, PolygonZ, and PolygonM typed shapes so they conform to the shapefile spec. and the spec says π outer rings' vertices should be oriented clockwise on the X/Y plane, and inner rings' vertices should be oriented counterclockwise. no cap.
now, a shapefile isn't one file, bestie β it's actually two files with the same basename and extensions .shp and .shx (or .SHP and .SHX), holding the shape data and the shape index respectively. it's giving duo. π―
the files it opens are figured out like this: first strip any filename extension off in_shp_file, then try to open in_shp_file.shp or in_shp_file.SHP, plus in_shp_file.shx or in_shp_file.SHX β those are the data and index files respectively.
and the files it creates from out_shp_file? same energy: strip any filename extension off out_shp_file, then append .shp and .shx suffixes for the data and index files respectively. periodt.
π OPTIONS π
in_shp_fileβ the name of an existing shapefile. the one you're bringing in, the patient, the main character pre-glow-up πout_shp_fileβ the name of the new fixed shapefile that will be created. the glow-up reveal β¨
π EXIT STATUS π
0β successful program execution. we ate. π½οΈ1β either you're missing thein_shp_fileorout_shp_filearguments, or it failed to open shapefilein_shp_file, or it failed to create shapefileout_shp_file. π
π₯ DIAGNOSTICS π₯
these ones may be issued on stdout, so watch for them:
Unable to open:in_shp_file
Unable to create:out_shp_file
count objects rewound.
π EXAMPLE π
shprewind badshapefile newshapefile
that's it, that's the whole flex. bad shapefile in, fixed shapefile out π¦
π AUTHOR π
shprewind is part of shapelib, maintained by Frank Warmerdam. this guide was created by Eduardo Patoo Kanegae and converted to manpage by Johan Van de Wauw. it was further enhanced with the man page written by Joonas Pihlaja (jpihlaja@cc.helsinki.fi). shoutout to the whole committee fr fr π«Ά
π BUGS π
okay so this is the part where we keep it real, because these caveats are real:
- the implementation assumes there is at most one outer ring in each shape, that it is the first ring in a shape, and that all other rings in a shape are inner rings. so yeah, that's an assumption, don't come for me. π«
- Polygons inside
MultiPatchshape types aren't rewound. not even a little bit. π
β SEE ALSO β
dbfadd(1), dbfcat(1), dbfcreate(1), dbfdump(1), dbfinfo(1), shpadd(1), shpcat(1), shpcentrd(1), shpcreate(1), shpdump(1), shpdxf(1), shpfix(1), shpinfo(1), shpproj(1), shptest(1)
okay that's the whole page bestie π§ this is from shplib, dated March 2026, and if you ever find a shapefile whose rings are going the wrong way, you know exactly who to call. go fix that winding order, you iconic little cartographer πβ¨πΈ
π¦ where this page comes from
- ubuntu stonking: shapelib 1.6.3-1 Β· MIT OR LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms