Definition of various projection systems can be found at the website spatialreference.org. Using org some functionality is available to convert projection system information to well known text or proj.4 format. The following code snippet is an example to translate information from a .prj file to proj.4 format. However ogr only provides a limited set of conversions.

Currently we require projection from world coordinates (wgs84) to meters (amersfoort new). The proj.4 definition of this projection is as follows (see also spatialreference.org).
"+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs"

update: ogr2ogr now supports:
"ogr2ogr -t_srs EPSG:28992 rivers_rdnew.shp rivers.shp", see example later on this page.

More examples for using ogr can be found at California soil resource lab

     public static string  EsriToProj4(string esriProjectionPath)
     {
           OSGeo.OSR.SpatialReference oSRS= new SpatialReference("");
           if (oSRS.SetFromUserInput(esriProjectionPath)!=Ogr.OGRERR_NONE)
           {
               throw new ApplicationException(string.Format("Error occured translating {0}",esriProjectionPath));
           }

            string proj4OutputString;
            if( oSRS.ExportToProj4(out proj4OutputString)==Ogr.OGRERR_NONE)
            {
                return proj4OutputString;
            }
            else
            {
                throw new ApplicationException("Export to proj4 failed");
            }
    }

This code snippet was based on the original c++ version by Frank Warmerdam. I have added the projection files contained with ArcMap. I don't think we should distribute these.

proj.4 is a utility for converting coordinates from one system to another. Proj.4 is written in c++ and can be downloaded from the Proj.4 website. Gdal /Ogr(currently version 1.61) depends on Proj.4 to convert raster or shapefiles from one coordinate system to another. To use proj.4 (windows) it is necessary to set the path to NAD27 grid shift files in an environmental variable, example: set PROJ_LIB=C:\Software\PROJ\NAD (we have to figure out some way to do this in deltashell).

The Shapelib library by Frank Warmerdam supports reprojection of shapefiles. I don't know if the syntax to define projections conforms to the proj.4 syntax.

Example
the following example projects file rowtest to row3, moving data from Stateplane NAD83 zone 1002 to utm zone 16 in meters

shpproj rowtest row -i="init=nad83:1002 units=us-ft" -o="proj=utm zone=16 units=m"
shpproj rowtest row3 -o="proj=utm zone=18 units=m" -i="zone=16 proj=utm units=us-ft"
shpproj rowtest row3 -o="proj=utm zone=18 units=m" 
shpproj rowtest row3 -i=myfile.prj -o=geographic
shpproj rowtest row3 -is=myfile.prj

You can try using ogr2ogr yourself by executing project_to_rdnew.cmd in the following attachment it will convert rivers.shp and project it from "GCS_WGS_1984" to "Amersfoort / RD New". The commandline for this is: "ogr2ogr -t_srs EPSG:28992 rivers_rdnew.shp rivers.shp"

  • No labels

6 Comments

  1. Unknown User (logch_o) AUTHOR

    Onno
    Intern werke we altijd met lang/long coordinaten zodat zodat elke kaartlaag zijn eigen coordinatesysteem kan hebben
    We ondesteunen mercator en orthographic als projectie.
    Voor de projectie (coordinaten naar pixel coordinaten) gebruiken we openmap.
    Voor de coordinate conversions gebruiken we oa geotools
    Groeten,
    Onno

    On 7/2/2009 10:25 AM, Onno van Logchem wrote:
    > Hoi Onno
    > Welk projectiesysteem gebruiken jullie binnen de kaart view van fews? Van welke bibliotheken maken jullie gebruik om naar dit systeem te projecteren?
    >
    > Groetjes
    > Onno

  2. Unknown User (logch_o) AUTHOR

    On the fly transformation in Sharpmap is very limited in functionality. For performance reasons it is better to convert source data beforehand. Using ogr2ogr and gdalwarp can help us to reproject shapefiles and rasterfiles. For shapefiles we could wrap ogr functionality to reproject on the fly. Most easy for now is to use projected map in m(how to treat all the projections?). Later on it would be more logical to use lat/lon.

    WMS layers (from the web) are in lat/lon coordinates. We cannot use them if we don't switch to lat/lon or reproject on the fly.

  3. Unknown User (logch_o) AUTHOR

    I recompiled both proj.4 and gdal. The proj.dll should be accompanied by the following files:

    datum shift files (environmental variable should be added to reference these files: ie PROJ_LIB="c:\proj\nad")
    gdal data (environmental variable should be added to reference these files: ie: GDAL_DATA="c:\gdal\data")

    I still have some trouble since ogr2ogr/gdal do not "see" these environmental variables.