[gdal-dev] shapefile field indexing on OGR 1.x vs 2.1

Even Rouault even.rouault at spatialys.com
Mon Jan 30 12:01:22 PST 2017


On lundi 30 janvier 2017 16:56:29 CET Andrea Battisti wrote:
> Hi all,
> 
> I have a shapefile created by GDAL/OGR 1.7 which is using a .ind/.idm
> attribute index on an integer field.
> 
> If I SQL-query that integer field on OGR 2.1 I get the following:
> ERROR 7: BuildKey(): 8 bytes integer key length not supported
> 
> I think that is because the new GDAL interprets that field as Integer64
> while before it was just Integer (and was working fine).
> 
> On the other hand if I delete the old index and recreate it using the
> new GDAL I get:
> ERROR 1: Indexing not support for the field type of field myfield.
> 
> What is the proper way to use new GDAL on the old shapefile without
> modifying it?
> Is there a way to explicitly tell GDAL to use that field as Integer and
> to make the field indexing work?

I'm not sure if MapInfo indexes support 64 bit integers (probably not), but the code does not 
support them indeed.

You can try to open the shapefile with the ADJUST_TYPE=YES open option so that it can 
check if a potential colum with 64 bit integers really contains 64 bit integers or not. If not, it 
will be downgraded to integer and the attribute index will be available.

Another option would be to resize the column to 8 characters or less if the data fits in it (with 
the RESIZE=YES creation option)

Another option is to not use shapefiles and use more powerful alternatives like GeoPackage 
or Spatialite.

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/20170130/d62db071/attachment.html>


More information about the gdal-dev mailing list