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

António Rocha antonio.rocha at deimos.com.pt
Fri Oct 28 07:54:37 EDT 2011


Hi
I have tried qwhat you said:
First: ogrinfo -al -so GPS_Project.shp
INFO: Open of `GPS_Project.shp'
      using driver `ESRI Shapefile' successful.

Layer name: GPS_Project
Geometry: Point
Feature Count: 135
Extent: (643712.710081, 7794078.321332) - (649554.409908, 7796057.897650)
Layer SRS WKT:
PROJCS["WGS_1984_UTM_Zone_36S",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_1984",6378137.0,298.257223563]],
        PRIMEM["Greenwich",0.0],
        UNIT["Degree",0.0174532925199433]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["False_Easting",500000.0],
    PARAMETER["False_Northing",10000000.0],
    PARAMETER["Central_Meridian",33.0],
    PARAMETER["Scale_Factor",0.9996],
    PARAMETER["Latitude_Of_Origin",0.0],
    UNIT["Meter",1.0]]
ele: Real (19.15)
time: String (80.0)
magvar: Real (19.15)
geoidheigh: Real (19.15)
name: String (80.0)
cmt: String (80.0)
desc_: String (80.0)
src: String (80.0)
link1_href: String (80.0)
link1_text: String (80.0)
link1_type: String (80.0)
link2_href: String (80.0)
link2_text: String (80.0)
link2_type: String (80.0)
sym: String (80.0)
type: String (80.0)
fix: String (80.0)
sat: Integer (10.0)
hdop: Real (19.15)
vdop: Real (19.15)
pdop: Real (19.15)
ageofdgpsd: Real (19.15)
dgpsid: Integer (10.0)
label: String (80.0)

And then:
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                  
And I got:

         ERROR 1: SQL Expression Parsing Error: syntax error


What is wrong in my expression?
THanks and sorry
Antonio

Chaitanya kumar CH wrote:
> António,
>
> OGR comes as a part of GDAL. OGR utilities can be used like GDAL 
> utilities.
>
> First, run ogrinfo on the shapefile with the options "-al" and "-so" 
> to determine the field names in it.
>
> Next, use the ogr2ogr utility like this:
> ogr2ogr -sql "SELECT [field1a AS field1b, field2a AS field2b, field 3a 
> AS field3b] FROM shapefileA" shapefileB.shp shapefileA.shp
>
> This command changes the fields field1a, field2a and field3a in the 
> original shapefile, shapefileA.shp, to field1b, field2b and field3b 
> respectively in the new shapefile, shapefile.shp.
>
> 2011/10/26 António Rocha <antonio.rocha at deimos.com.pt 
> <mailto:antonio.rocha at deimos.com.pt>>
>
>     Hi
>     THanks for the feedback. I'm a bit lost on this. Is there any
>     examples and tutorials on using sql commands for OGR? I'm sorry
>     but I'm not use to use Vectorial data and neither OGR (only GDAL)
>     Thanks
>     Antonio
>     Chaitanya kumar CH wrote:
>
>         António,
>
>         The easiest way is to use the -sql option in ogr2ogr [1] and
>         set a new name with the AS clause in the SQL statement [2].
>
>         [1]: http://www.gdal.org/ogr2ogr.html
>         [2]: http://trac.osgeo.org/gdal/wiki/rfc28_sqlfunc
>
>         2011/10/26 António Rocha <antonio.rocha at deimos.com.pt
>         <mailto:antonio.rocha at deimos.com.pt>
>         <mailto:antonio.rocha at deimos.com.pt
>         <mailto:antonio.rocha at deimos.com.pt>>>
>
>
>            Greetings
>            I have to shage a column name in a Shapefile. I'm not much
>            familiar with OGR. How can I do that in OGR?
>            THanks
>            Best regards,
>            Antonio
>
>
>
>            __________ Information from ESET NOD32 Antivirus, version
>         of virus
>            signature database 6574 (20111025) __________
>
>            The message was checked by ESET NOD32 Antivirus.
>
>            http://www.eset.com
>
>
>            _______________________________________________
>            gdal-dev mailing list
>            gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>         <mailto:gdal-dev at lists.osgeo.org
>         <mailto:gdal-dev at lists.osgeo.org>>
>
>            http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
>         -- 
>         Best regards,
>         Chaitanya kumar CH.
>
>         +91-9494447584 <tel:%2B91-9494447584>
>         17.2416N 80.1426E
>
>
>
>
>     __________ Information from ESET NOD32 Antivirus, version of virus
>     signature database 6575 (20111026) __________
>
>
>     The message was checked by ESET NOD32 Antivirus.
>
>     http://www.eset.com
>
>
>
>
>
> -- 
> Best regards,
> Chaitanya kumar CH.
>
> +91-9494447584
> 17.2416N 80.1426E


-- 
António Rocha

Aerospace & Defence Portugal
DEIMOS Engenharia, SA
Av. D. Joao II, Lt 1.17.01 - 10º, Ed. Torre Zen
1998-023 Lisboa, Portugal
Ph:  +351 21 893 3010
Fax: +351 21 896 9099
http://www.deimos.pt 



__________ Information from ESET NOD32 Antivirus, version of virus signature database 6582 (20111028) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




More information about the gdal-dev mailing list