[gdal-dev] Shapefile with one feature and many incrementally-added vertices is huge

Even Rouault even.rouault at spatialys.com
Thu Jan 19 03:31:45 PST 2017


On jeudi 19 janvier 2017 21:21:20 CET Nik Sands wrote:
> Hi,
> 
> My iOS app has a feature where it uses GDAL 1.11 to record to two shapefiles
> simultaneously.  One is a point 2.5D feature class and it writes a point
> feature to this feature class for every location that iOS sends.  The other
> is a line 2.5D feature class with a single line feature and a vertex is
> added to the line for every location that iOS sends.
> 
> I’ve found that the line shapefile ends up being huge, while the point
> shapefile is manageable.  For example, I recently tested it out tracking a
> walk I did over a few hours and 6,000 vertices in the one line feature
> resulted in a shapefile of 500 MB (this is the .shp file itself, not the
> .dbf, etc).  The shapefile is not sync’d to disk in between adding
> vertices.  Just once at the beginning and once the end.
> 
> Is this sort of file size expected?  Can I do this in a way that would use
> less storage space?

Nik,

When editing a geometry and growing it, the low level shapefile writer code isn't really smart 
and just adds the new version at the end of the .shp. So in your use case, the file size will 
increase quadratically. In that particular case the writer could realize that we are editing the 
last geometry, so it could safely overwrite in place, but this isn't implemented yet.

A workaround is to create a brand new shapefile each time you add a point to your line 
shapefile.
Or (rather equivalently) you could delete the feature, run REPACK and add the new version 
of the feature.

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170119/a1d7868f/attachment-0001.html>


More information about the gdal-dev mailing list