coshp

Purpose

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.

See also

the sortshp utility

Description

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.

Syntax

coshp [infile] [outfile]

Example

This example uses a countries shapefile (countries.shp) :

coshp countries countries_sorted

Tip

Do not specify an extension for the shapefiles in the command above, as it could cause problems in the generated filenames.

Result

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

../_images/coshp-attributes-before.png

Figure2: Attributes After coshp

../_images/coshp-attributes-after.png