[gdal-dev] Renaming a column's name in a Shapefile

Chaitanya kumar CH chaitanya.ch at gmail.com
Fri Oct 28 08:50:51 EDT 2011


António,

The field name 'desc' is one of the SQL keywords[1]. It needs to be quoted
for OGR to process it. So the following command should work.
ogr2ogr -f "esri shapefile" -sql "SELECT ele, time AS t, magvar,geoidheigh,
name, cmt, 'desc', src FROM GPS_Project" new.shp GPS_Project.shp

[1]: http://trac.osgeo.org/gdal/wiki/rfc28_sqlfunc#CompatabilityImplications

2011/10/28 António Rocha <antonio.rocha at deimos.com.pt>

> Hi Ralf
> Thanks for the feedback but it did not work.
> I tried:
> ogr2ogr -f "esri shapefile" -sql "SELECT ele, time AS t, magvar,geoidheigh,
> name, cmt, desc, src FROM GPS_Project" new.shp GPS_Project.shp
>
> And I got:
> ERROR 1: SQL Expression Parsing Error: syntax error
>
> Even I tried:
> ogr2ogr -f "esri shapefile" -sql "SELECT ele, magvar,geoidheigh, name, cmt,
> desc, src FROM GPS_Project" new.shp GPS_Project.shp
>
> And I got:
> ERROR 1: SQL Expression Parsing Error: syntax error
> Any other suggestion?
> Thanks
> Antonio
>
>
>
> Ralf Suhr wrote:
>
>> ogr2ogr -f "esri shapefile" -sql "SELECT ele, time AS t, magvar,
>> geoidheigh, name, cmt, desc, src FROM GPS_Project" new.shp GPS_Project.shp
>>
>> Gr
>> Ralf
>>
>> On Freitag 28 Oktober 2011 13:54:37 António Rocha wrote:
>>
>>
>>> ogr2ogr -sql "SELECT [ele AS ele, time AS t, magvar AS magvar, geoidheigh
>>> AS geoidheigh, name AS name, cmt AS cmt, desc_ AS desc_, src AS src] FROM
>>> GPS_Project.shp", new.shp GPS_Project.shp
>>>
>>>
>>
>>
>>
>>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 6582 (20111028) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
> ______________________________**_________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/gdal-dev<http://lists.osgeo.org/mailman/listinfo/gdal-dev>
>



-- 
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/20111028/3349869f/attachment-0001.html


More information about the gdal-dev mailing list