Opened 18 years ago

Last modified 18 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
Cc:

Description

I changed the definition in my epsg file according to:

http://postgis.refractions.net/pipermail/postgis-users/2005-November/009894.html

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:
http://test.intranet.rijkswaterstaat.nl/services/geoservices/4326?service=WFS&request=GetFeature&typename=test&bbox=0,0,180,180&version=1.0.0

Output:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
   xmlns:wfs="http://www.opengis.net/wfs"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd 
                       http://mapserver.gis.umn.edu/mapserver http://test.intranet.rijkswaterstaat.nl/services/geoservices/4326?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=test&amp;OUTPUTFORMAT=XMLSCHEMA">
      <gml:boundedBy>
      	<gml:Box srsName="EPSG:4326">
      		<gml:coordinates>5.826035,51.850181 5.826380,51.850564</gml:coordinates>
      	</gml:Box>
      </gml:boundedBy>
    <gml:featureMember>
      <ms:test>

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

        </gml:LineString>
        </ms:msGeometry>
      </ms:test>
    </gml:featureMember>
</wfs:FeatureCollection>

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:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_1984",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
CTE: String (50.0)
DTM: String (50.0)
FIXTXT: String (50.0)
LAYER: String (50.0)
OMSCHR: String (50.0)
TCTYPE: String (50.0)
OGRFeature(dtbweg_lin_test_4326):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@… 18 years ago.
input shapefile in Dutch national system (EPSG:28992)

Download all attachments as: .zip

Change History (4)

by bartvde@…, 18 years ago

Attachment: ge.tgz added

input shapefile in Dutch national system (EPSG:28992)

comment:1 by warmerdam, 18 years ago

Bart,

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
+towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812
+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
+towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812
+no_defs"

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 by bartvde@…, 18 years ago

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.

Bart

comment:3 by bartvde@…, 18 years ago

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