This project has moved. For the latest updates, please go here.

ShapeFile file based index

Topics: SharpMap v0.9 / v1.x
Mar 7, 2013 at 9:30 AM
Edited Mar 7, 2013 at 9:31 AM
As far as I know, when using a ShapeFile the spatial index is built when Open() is called on the provider.

Is it possible to save this index as a file and use it on the next load in order to increase loading performance?
sf = new SharpMap.Data.Providers.ShapeFile(shapeFilePath, true);
Mar 7, 2013 at 10:31 AM
Yes, if you use
var sf = new SharpMap.Data.Providers.ShapeFile(shapeFilePath, false); // equals new SharpMap.Data.Providers.ShapeFile(shapeFilePath);
a spatial index file will be created. As long as your shapefile does not change, you can reuse that with
var sf = new SharpMap.Data.Providers.ShapeFile(shapeFilePath, true);
Mar 7, 2013 at 12:15 PM
Thank you FObermaier for your answer.

Its just that I did not noticed any new file being created (index file). Where is that file created?
I need to be using it between application runs.
Mar 7, 2013 at 1:55 PM
It should be right next to the shapefile, it has an "sidx" extension.
Mar 7, 2013 at 1:59 PM
Great! Thank you! Found it.
It seems that it gets created the first time you call like so:
sf = new SharpMap.Data.Providers.ShapeFile(sPath, true);
I suppose that it gets reused on subsequent calls.

Thank you very much for taking the time to answer me.