Ticket #2152 (closed defect: fixed)
[PATCH] ogr2ogr field types wrong, creating .SHP from .CSV/.CSVT
| Reported by: | halmueller | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.7.3 |
| Component: | OGR_SF | Version: | 1.5.0 |
| Severity: | normal | Keywords: | shapefile |
| Cc: | eadam@… |
Description
I'm getting weird results when trying to use CSVT files to specify field types, importing a CSV file and creating a shapefile.
I have it down to a 2 line CSV, 1 line CSVT, and an OGRVT.
Note that, upon conversion, all of the fields requested as Integer come up as Real, except for the final one, which comes up as String.
This is with GDAL 1.5.0 running on RHEL4, compiled from source. I also saw the problem on 1.4.2.
ships3.csv:
"FID","LAT", "LON", "CALL", "NAME", "TIMESTAMP", "TIMESTRING", "AGEHOURS", "TALLSHIP", "CRUISE", "RESEARCH", "YOTREP", "BUOY"
0,58.500000,-140.200000,WDD6494,"Polar Viking",1193414400,"2007-Oct-26 0900",1854,0,0,0,0,0
ships3.csvt:
"Integer","Real","Real","String","String","Integer","String","Integer","Integer","Integer","Integer","Integer","Integer"
ships3OGRVRT.xml:
<OGRVRTDataSource>
<OGRVRTLayer name="ships2">
<SrcDataSource>/home/ldm/csv-test//ships3.csv</SrcDataSource>
<SrcLayer>ships3</SrcLayer>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="LON" y="LAT"/>
</OGRVRTLayer>
</OGRVRTDataSource>
command: ogr2ogr shipsOut.shp ships3OGRVRT.xml
ogrinfo -al shipsOut.shp
INFO: Open of `shipsOut.shp'
using driver `ESRI Shapefile' successful.
Layer name: shipsOut
Geometry: Point
Feature Count: 1
Extent: (-140.200000, 58.500000) - (-140.200000, 58.500000)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
FID: Real (11.0)
LAT: Real (24.15)
LON: Real (24.15)
CALL: String (80.0)
NAME: String (80.0)
TIMESTAMP: Real (11.0)
TIMESTRING: String (80.0)
AGEHOURS: Real (11.0)
TALLSHIP: Real (11.0)
CRUISE: Real (11.0)
RESEARCH: Real (11.0)
YOTREP: Real (11.0)
BUOY: String (80.0)
OGRFeature(shipsOut):0
FID (Real) = 0
LAT (Real) = 58.500000000000000
LON (Real) = -140.199999999999989
CALL (String) = WDD6494
NAME (String) = Polar Viking
TIMESTAMP (Real) = 1193414400
TIMESTRING (String) = 2007-Oct-26 0900
AGEHOURS (Real) = 1854
TALLSHIP (Real) = 0
CRUISE (Real) = 0
RESEARCH (Real) = 0
YOTREP (Real) = 0
BUOY (String) = 0
POINT (-140.199999999999989 58.5)
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

