[Qgis-user] Re: Delete columns of a .shp file with GDAL/OGR 1.9.0

Simon Cropper simoncropper at fossworkflowguides.com
Thu May 17 00:10:26 PDT 2012


On 17/05/12 16:44, iomeneandrei wrote:
> Hi Karlis,
> thank you.
>
>
> Zirneklitis wrote
>>
>> OpenOffice Calc is very usefull for working with *.dbf files. The only
>> restrictions – you must not add, rearrange or delete rows.
>>
>
> I'm not looking for a solution to delete a dbf column. I thought that with
> GDAL 1.9  I could use QGIS standard interface without any extension or
> external software.
>
> Best regards,
>
> Andrea
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Delete-columns-of-a-shp-file-with-GDAL-OGR-1-9-0-tp4916642p4975284.html
> Sent from the Quantum GIS - User mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user

Andrea,

I recently had a problem of converting a very large shapefile and 
include some coordinate data in the file. In the end I was directed to 
and successfully used the following command (albeit in a bash file).

The point is that if you can use SQL you can send only those fields you 
want to the duplicate file. Hence, albeit with a little programming, you 
could 'leave out' the field you want to delete and make a copy of the 
file. I know ogr2ogr can be programmed can be handed stuff in python so 
an sql command can be constructed and handed to the library as 
parameter. To get specifics try the gdal forums.

ogr2ogr -sql "SELECT OGR_GEOM_WKT AS GEOM_WKT, * FROM $FileName" ./dbf 
$TheFile


-- 
Cheers Simon

    Simon Cropper - Open Content Creator / Website Administrator

    Free and Open Source Software Workflow Guides
    ------------------------------------------------------------
    Introduction               http://www.fossworkflowguides.com
    GIS Packages           http://www.fossworkflowguides.com/gis
    bash / Python    http://www.fossworkflowguides.com/scripting



More information about the Qgis-user mailing list