Changes between Version 12 and Version 13 of FAQVector


Ignore:
Timestamp:
Sep 18, 2012, 11:31:55 AM (12 years ago)
Author:
Even Rouault
Comment:

Add a "How do I flip coordinates when they are not in the expected order" section

Legend:

Unmodified
Added
Removed
Modified
  • FAQVector

    v12 v13  
    155155ogrinfo . -sql 'SELECT * FROM "B_Major Cities 1" WHERE FID = 49'
    156156}}}
     157
     158== How do I flip coordinates when they are not in the expected order ==
     159
     160The EPSG has a recommanded order for geographic SRS where the coordinates tuples of a geometry must appear in the (latitude, longitude) order, whereas most GIS will properly display such geometries if they appear in the (longitude, latitude) order. This issue can be often encountered in situation with GML3 files, WFS 1.1 data, etc... that adhere to the (latitude, longitude) order.
     161
     162When, for some reason, the coordinate order isn't the one that is wished, the following trick can be used to flip them :
     163
     164{{{
     165ogr2ogr -s_srs "+proj=latlong +datum=WGS84 +axis=neu +wktext"
     166        -t_srs "+proj=latlong +datum=WGS84 +axis=enu +wktext" dest.shp source.shp
     167}}}
     168
     169Note: this will work even if the SRS of your input data isn't using the WGS84 datum. The reason for the above magic incantation to work is that the values of -s_srs and -t_srs only differ by the value of the +axis parameter.
     170
     171This trick might also be used for some projected SRS that have unusual axis order.
     172
     173An alternative way of achieving the same result, providing using GDAL 2.0 compiled with Spatialite support to benefit from [http://gdal.org/ogr/ogr_sql_sqlite.html SQLite SQL dialect], is :
     174
     175{{{
     176ogr2ogr -dialect SQLite -sql "SELECT SwapCoordinates(geometry) AS geometry, * FROM source" dest.shp source.shp
     177}}}