Sorts an Esri shapefile and its associated qix spatial index (that was created with the shptree utility). Useful for «Cloud Optimized Shapefiles», to enable fast bounding box spatial filtering.
the sortshp utility
The idea here is that the contents of the shapefile will be sorted in the same order in the shp file and sorted for its qix spatial index file as well.
coshp [infile] [outfile]
This example uses a countries shapefile (countries.shp) :
coshp countries countries_sorted
Do not specify an extension for the shapefiles in the command above, as it could cause problems in the generated filenames.
Wrote 177 spatially sorted shapes into shapefile 'countries_sorted'
and the following filenames were generated:
countries_sorted.qix countries_sorted.shp countries_sorted.dbf countries_sorted.shx
Therefore a new shapefile named countries_sorted.shp is created with shapes sorted (and qix file sorted), as shown below.
Figure1: Attributes Before coshp
Figure2: Attributes After coshp