Opened 14 years ago

Last modified 14 years ago

#1307 closed defect (invalid)

reprojection from Dutch system to WGS84 is incorrect

Reported by: bartvde@… Owned by: warmerdam
Priority: highest Milestone:
Component: OGR_SRS Version: unspecified
Severity: blocker Keywords: VERIFIED


I changed the definition in my epsg file according to:

Input shapefile with only 1 linestring will be attached later.

I tried 3 approaches:

1) using cs2cs:

[bart@hades ge]$ cs2cs -f "%.12f" +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs +to +proj=latlong +datum=WGS84 +to +proj=init:epsg:4326 test.txt

test.txt contains:
185259.548000000009779 429201.456000000005588

Output is:
5.826379891942  51.850564241678 43.840475496731

2) using Mapserver WFS to reproject the linestring:

Request used:,0,180,180&version=1.0.0

<?xml version='1.0' encoding="ISO-8859-1" ?>
      	<gml:Box srsName="EPSG:4326">
      		<gml:coordinates>5.826035,51.850181 5.826380,51.850564</gml:coordinates>

        	<gml:Box srsName="EPSG:4326">
        		<gml:coordinates>5.826035,51.850181 5.826380,51.850564</gml:coordinates>
        <gml:LineString srsName="EPSG:4326">
          <gml:coordinates>5.826380,51.850564 5.826035,51.850181 </gml:coordinates>


3) using ogr2ogr:

[bart@hades ge]$ sudo ogr2ogr -f "ESRI Shapefile" -s_srs "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs +to +proj=latlong +datum=WGS84" -t_srs "EPSG:4326" dtbweg_lin_test_4326.shp dtbweg_lin_test.shp

[bart@hades ge]$ ogrinfo dtbweg_lin_test_4326.shp dtbweg_lin_test_4326
ERROR 4: Unable to open dtbweg_lin_test_4326.shp or dtbweg_lin_test_4326.SHP.
Had to open data source read-only.
INFO: Open of `dtbweg_lin_test_4326.shp'
using driver `ESRI Shapefile' successful.

Layer name: dtbweg_lin_test_4326
Geometry: Line String
Feature Count: 1
Extent: (5.826482, 51.851169) - (5.826827, 51.851552)
Layer SRS WKT:
CTE: String (50.0)
DTM: String (50.0)
FIXTXT: String (50.0)
LAYER: String (50.0)
OMSCHR: String (50.0)
TCTYPE: String (50.0)
  CTE (String) = R750101
  DTM (String) = N
  FIXTXT (String) = (null)
  LAYER (String) = 1
  OMSCHR (String) = kraanspoor
  TCTYPE (String) = (null)
  LINESTRING (5.826827152036284 51.851552296984316,5.826482477958643 51.851168942401422)

So 1) and 2) are similar, but 3) is not.

Attachments (1)

ge.tgz (343 bytes) - added by bartvde@… 14 years ago.
input shapefile in Dutch national system (EPSG:28992)

Download all attachments as: .zip

Change History (4)

Changed 14 years ago by bartvde@…

Attachment: ge.tgz added

input shapefile in Dutch national system (EPSG:28992)

comment:1 Changed 14 years ago by warmerdam


In the ogr2ogr command you use the following -s_srs directive:

-s_srs "+proj=sterea
+lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000
+y_0=463000 +ellps=bessel +units=m
+no_defs +to +proj=latlong +datum=WGS84"

But this argument includes two coordinate systems separated by a +to. 
For the cs2cs command the +to is the separator between coordinate 
systems, but for ogr2ogr it does not mean anything, so the parser ends
up overriding the custom coordinate system with the +datum=WGS84 that
follows.  ogr2ogr seems to produce the correct results if the argument is:

-s_srs "+proj=sterea
+lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000
+y_0=463000 +ellps=bessel +units=m

I'd add you also have two +to separators in your cs2cs command, though I 
don't think it is doing any harm there. 

Please reopen if I have missed something.

comment:2 Changed 14 years ago by bartvde@…

Hi Frank,

thanks, you're right, I'll test it tomorrow morning.

I did just a copy/paste from Jan Hartman's e-mail on postgis-users and did not release that there was a +to tag in there.


comment:3 Changed 14 years ago by bartvde@…

Frank, I have verified that this was the problem. Thanks again!
Note: See TracTickets for help on using tickets.