[gdal-dev] How clean a shapefile using ogrinfo

Jeff McKenna jmckenna at gatewaygeomatics.com
Fri Aug 12 12:35:58 PDT 2016


Hi Andrea,

This seems like a useful tip; would you mind documenting your steps on 
the GDAL wiki?  Maybe on this page? 
https://trac.osgeo.org/gdal/wiki/UserDocs/OgrInfo

thanks,

-jeff



-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2016-08-12 4:22 PM, Andrea Peri wrote:
> Hi Even,
> thx for your help and for the "repack" hint.
>
> A.
>
>
> 2016-08-12 17:22 GMT+02:00 Even Rouault <even.rouault at spatialys.com>:
>> Hi Andrea,
>>
>>> I need to clean a shapefile before export in it from a DB table.
>>>
>>> The option "-overwrite" of ogr2ogr is not feasible for me because
>>> AFAIK from the docs
>>> the overwrite option will
>>> "delete the shapefile and recreate it".
>>> Instead I need do not recreate it to maintain the original structure of
>>> dbf.
>>>
>>> So I try to delete the shapefile using this ogrinfo tools,
>>> but using this sintax
>>>
>>> ogrinfo -al -sql "delete from myshape" myshape.shp
>>
>> Add to the above command: -dialect sqlite
>>
>> And to really clean all records, you need to repack afterwards:
>>
>> ogrinfo -sql "repack myshape" myshape.shp
>>
>>
>> Even
>>
>> --
>> Spatialys - Geospatial professional services
>> http://www.spatialys.com
>
>
>




More information about the gdal-dev mailing list