[gdal-dev] beginner or bug: reprojecting using ogr2ogr
Alex Hagen-Zanker
ahh34 at cam.ac.uk
Tue Feb 2 06:45:34 EST 2010
Dear all,
I just did my first reprojection using ogr2ogr. The process went quite
patchy and I wonder if this is because of a bug or because I am not
understanding something really basic.
I want to reproject a point dataset from British National Grid
(EPSG:27700) to WGS84.
My input comes as comma separated values. Therefore I use GDAL 1.7 which
offers great support for VRT and CSV
I have two input files, input.vrt and input.cvs
input.vrt looks as follows:
<OGRVRTDataSource>
<OGRVRTLayer name="input">
<SrcDataSource>input.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:27700</LayerSRS>
<GeometryField encoding="PointFromColumns" x="X" y="Y"/>
<Field name="Z" src="Z" type="Real"/>
</OGRVRTLayer>
</OGRVRTDataSource>
input.csv as follows:
X,Y,Z
385500,815500,2
I assumed that the following command would do all my work:
% ogr2ogr -f csv -s_srs EPSG:27700 -t_srs WGS84 output.csv input.vrt
-lco GEOMETRY=AS_XY
It does not work however, and I get an error about "Failed to initialize
PROJ.4 " due to "unknown ellipical parameter name". See the full error
at the bottom of this email.
I thought that it might be better to separate the file conversions and
the reprojection and did the following:
First convert: % ogr2ogr input.shp input.vrt
Then reproject: % ogr2ogr -s_srs EPSG:27700 -t_srs WGS84 output.shp
input.shp
Then convert: % ogr2ogr -f csv output.csv output.shp -lco GEOMETRY=AS_XY
But the reproject step fails on exactly the same error.
Leaving out the -s_srs override because it is obsolete does not help
% ogr2ogr -t_srs WGS84 output.shp input.shp
(fails on same error)
Finally, it worked using the older 1.6 version of ogr2ogr, which I had
renamed to ogr2ogr16
% ogr2ogr16 -t_srs WGS84 output.shp input.shp
(now it works)
When I useArcGIS to map the points in both projections, they coincide
exactly. Output.csv looks as follows:
X,Y,Z
-2.240199963394935,57.230193361600563, 2.000000000000000
Out of interest I made the source projection explicit again, and the
same error returns:
% ogr2ogr16 -s_srs EPSG:27700 -t_srs WGS84 output.shp input.shp
(fails on same error)
This could be a bug in the new version, but I suspect that I have
misunderstood how ogr2ogr is really intended to be used.
Could somebody point me in the right direction?
Thanks in advance,
Alex
--
Alex Hagen-Zanker
University of Cambridge, Department of Architecture, 1-5 Scroope
Terrace, Cambridge, CB2 1PX, United Kingdom
Tel: +44(0) 1223 330573
Full error message:
ERROR 6: Failed to initialize PROJ.4 with `+proj=tmerc +lat_0=49
+lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy
+datum=OSGB36 +units=m +no_defs'.
unknown elliptical parameter name
Failed to create coordinate transformation between the following
coordinate systems. This may be because they are not transformable, or
because projection services (PROJ.4 DLL/.so) could not be loaded.
Source:
PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,
AUTHORITY["EPSG","7001"]],
AUTHORITY["EPSG","6277"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4277"]],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.9996012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
AUTHORITY["EPSG","27700"],
AXIS["Easting",EAST],
AXIS["Northing",NORTH]]
Target:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
TOWGS84[0,0,0,0,0,0,0],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9108"]],
AUTHORITY["EPSG","4326"]]
More information about the gdal-dev
mailing list