[gdal-dev] How to exploit the spatial index (*.qix) file for spatial filtering?

Chaitanya kumar CH chaitanya.ch at gmail.com
Thu Feb 13 21:39:05 PST 2014


Chuiqing,

You can create an index through SQL. This is the preferred method even if
you stick to the shapefile format for your vector data.

OGRDataSource::ExecuteSQL()

OGR's Shapefile driver supports these SQL commands among others:
CREATE SPATIAL INDEX ON layer_name [DEPTH n]
DROP SPATIAL INDEX ON layer_name
REPACK layer_name
RECOMPUTE EXTENT ON layer_name



On Fri, Feb 14, 2014 at 10:56 AM, C. Zeng <chqzeng at gmail.com> wrote:

> Hi Chaitanya,
>
> Thank you for your response,
> I know I can do this through GDAL binary, and my question is: how can I
> integrate this function into my code?
>
> I have a platform like QGIS, I would like the program itself have the
> ability to create and load .qix file. For example, when I open the .shp
> file, I can detect whether there is .qix, if not then create a new qix file;
> When the user zoom the map window, it will filter the map content via the
> qix file to accelerate the searching.
> Does GDAL/OGR has similar functions/classes, something like
> OGRSFDriverRegistrar::Createqix(savepath),
> OGRSFDriverRegistrar::Loadqix(path),to open and use qix files?
>
>
> Thank you,
>
> Chuiqing,
>
>
> On Thu, Feb 13, 2014 at 11:46 PM, Chaitanya kumar CH <
> chaitanya.ch at gmail.com> wrote:
>
>> Chuiqing,
>>
>> The OGR Shapefile driver supports spatial indexing through qix files. To
>> explicitly create a spatial index use the Create Index command:
>>
>> CREATE SPATIAL INDEX ON tablename [DEPTH N]
>>
>> Depth can range from 1 to 12. You can issue the SQL command using ogrinfo.
>>
>> ogrinfo -sql 'CREATE SPATIAL INDEX ON shapefilename [DEPTH N]' path/to/shapefile/directory
>>
>> http://www.gdal.org/ogr/drv_shapefile.html -> Spatial and Attribute Indexing.
>>
>>
>>
>> On Fri, Feb 14, 2014 at 3:12 AM, <chqzeng at gmail.com> wrote:
>>
>>> Hi chaitanya_ch,
>>> I know you are an expert on this, I want to know how can I use GDAL
>>> library to implemented qix reading and using in spatial filtering.
>>> I have many large shape files in Gigbyte level, they are very slow when
>>> navigating in my app. I want to use *.qix file through GDAL library to
>>> accelerate it.
>>>
>>> How can I do that?
>>> Thank  you,
>>>
>>> C. Zeng
>>>
>>>
>>> _____________________________________
>>> Sent from http://osgeo-org.1560.x6.nabble.com
>>>
>>>
>>
>>
>> --
>> Best regards,
>> Chaitanya kumar CH.
>>
>> +91-9494447584
>> 17.2416N 80.1426E
>>
>
>


-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140214/5de8d651/attachment.html>


More information about the gdal-dev mailing list