Personal tools

Difference between revisions of "PROJ4"

From MohidWiki

Jump to: navigation, search
(PROJ4)
Line 1: Line 1:
This page explains what is [http://proj.maptools.org/ PROJ4] library and how to use it, both from command line and from a Fortran program.  
+
This page explains what is [http://proj.maptools.org/ PROJ4] library and how to use it from the command line, in Windows and in Linux.
  
[http://proj.maptools.org/ PROJ4] is a Cartographic Projections library originally written by Gerald Evenden then of the USGS. This library has almost all projection types. Being written in C, a Fortran wrapper was developed as part of the [http://www.cbcb.umd.edu/software/glimmer/ GLIMMER] project and can be found in [http://forge.nesc.ac.uk/download.php/10/libfproj4-1.0.tar.gz libfproj4-1.0.tar.gz].  
+
[http://proj.maptools.org/ PROJ4] is an open-source Cartographic Projections library originally written by Gerald Evenden then of the USGS. This library has almost all projection types and it is very usefull to convert coordinates for a series of points.
  
==PROJ4==
+
It is written in C but a Fortran wrapper was developed as part of the [http://www.cbcb.umd.edu/software/glimmer/ GLIMMER] project. More information can be found in [[libfproj4]]
===Installation===
+
 
====Windows====
+
==Installation==
 +
===Windows===
 
* Download http://download.osgeo.org/proj/proj446_win32_bin.zip
 
* Download http://download.osgeo.org/proj/proj446_win32_bin.zip
 
* Extract and copy "proj" folder to C:\
 
* Extract and copy "proj" folder to C:\
Line 22: Line 23:
 
*write "proj -V" to see the version of the library.
 
*write "proj -V" to see the version of the library.
  
====Linux====
+
===Linux===
 
* Go to your Package Manager or download source code from http://trac.osgeo.org/proj/ and follow the instructions.
 
* Go to your Package Manager or download source code from http://trac.osgeo.org/proj/ and follow the instructions.
  
===Usage===
+
==Usage==
  
==libfproj4 (Fortran Wrapper)==
+
The Proj4 is well documented. Here are some commands that I found useful.
  
===Compilation===
+
===Projections===
====UNIX====
 
  
*extract [http://forge.nesc.ac.uk/download.php/10/libfproj4-1.0.tar.gz libfproj4.tar.gz] to some place (e.g. DIR)
+
*List of projections in PROJ4: proj -lp
*cd $DIR
 
*export export CC=icc
 
*export CFLAGS=-Bstatic
 
*export FC=ifort
 
*export FCFLAGS=-Bstatic
 
*./configure --prefix=$DIR/libfproj4 --with-proj4=/usr/lib64 2>&1 | tee configure.mylog
 
  
*make 2>&1 | tee make.log
+
===Ellipsoids===
*make check 2>&1 | tee check.log
 
*make install 2>&1 | tee install.log
 
 
 
====Windows====
 
*Download [[\\kepler\Software\PROJ4\libfproj4.lib]] for Compaq Visual Studio, or
 
*Compile W32 static lib:
 
*#Extract proj4 source code and configure it (bash configure).
 
*#New project W32 static lib
 
*#Add fort-proj.c (from libfproj4-1.0.tar.gz) and all *.c files (from proj4 source), except all that have main function : css2css, geod, nad2bin, nad2nad, proj.c.
 
*# Project Settings / C/C++ / General / Preprocessor definitions : VISUAL_CPLUSPLUS ou IFORT
 
*# Project Settings / C/C++ / Preprocessor / include : whatever\proj-4.6.0\src (the folder that has projects.h, because of directives #include <projects.h>)
 
 
 
===Usage===
 
====UNIX====
 
 
 
*pgf95 -g  -o libfproj4_teste.exe  libfproj4_teste.f90 /home/jjdd/Downloads/libfproj4-1.0/libfproj4.a -lproj -lm
 
 
 
====Windows====
 
*Files needed: libfproj4.lib, proj4.inc, proj4.f90, test-proj.f90
 
#New Fortran console application
 
#add fortran files
 
#project settings:
 
## Link / Input / Obj/library modules : libfproj4.lib
 
## Link / Input / Additional include path : path to libfproj4.lib and proj4.inc)
 
 
 
==Ellipsoids==
 
 
*List of ellipsoids in PROJ4: proj -le
 
*List of ellipsoids in PROJ4: proj -le
 
*More popular:
 
*More popular:
Line 76: Line 44:
 
b = a*(1-f) = a*(1-1/rf)
 
b = a*(1-f) = a*(1-1/rf)
  
 
+
===Portuguese Coordinate Systems in PROJ4===
==Portuguese Coordinate Systems in PROJ4==
 
  
 
You might want to get the libraries containing the coordinate transformations with portuguese datum
 
You might want to get the libraries containing the coordinate transformations with portuguese datum
Line 83: Line 50:
  
 
Here's the command line on how to convert from military portuguese to wgs84:
 
Here's the command line on how to convert from military portuguese to wgs84:
> cs2cs +init=pt:dlxhgmil +to +init=pt:etrs89 < coords_input.txt
+
  cs2cs +init=pt:dlxhgmil +to +init=pt:etrs89 < coords_input.txt
  
 
===Portuguese Military Coordinates (Hayford-Gauss Military System)===
 
===Portuguese Military Coordinates (Hayford-Gauss Military System)===
Line 92: Line 59:
 
*Central Point: 39º40’N, 8º07’54.862’’W  
 
*Central Point: 39º40’N, 8º07’54.862’’W  
 
*Origin: -200Km horizontally and -300 Km vertically
 
*Origin: -200Km horizontally and -300 Km vertically
*Usage:  
+
 
**'''+init=epsg:20790''' <=> +proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1.000000  
+
Usage:  
 +
 
 +
*'''+init=epsg:20790''' <=> +proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1.000000  
 
+x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon +units=m +no_defs  no_defs <>
 
+x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon +units=m +no_defs  no_defs <>
**'''+init=esri:102164''' <=> +proj=tmerc +lat_0=39.666666667 +lon_0=-8.131906111 +k=1.000000  
+
*'''+init=esri:102164''' <=> +proj=tmerc +lat_0=39.666666667 +lon_0=-8.131906111 +k=1.000000  
 
+x_0=200000.000 +y_0=300000.000 +ellps=intl +units=m (no reference to Lisbon Datum!!)
 
+x_0=200000.000 +y_0=300000.000 +ellps=intl +units=m (no reference to Lisbon Datum!!)
  
Line 101: Line 70:
 
===Universal Transverse Mercator (zone 29N)===
 
===Universal Transverse Mercator (zone 29N)===
  
*Usage:
+
Usage:
**ModuleHorizontalGrid: '''+init=esri:32629''' <=> +proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m
+
*ModuleHorizontalGrid: '''+init=esri:32629''' <=> +proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m
  
 
=External Links=
 
=External Links=
 
*[http://proj.maptools.org/ PROJ4]
 
*[http://proj.maptools.org/ PROJ4]
*[http://forge.nesc.ac.uk/download.php/10/libfproj4-1.0.tar.gz libfproj4-1.0.tar.gz].
 
 
*[http://www.isa.utl.pt/dm/sigdr/sigdr04-05/9_SistRefPortugueses.ppt Sistemas Referencia Portugueses]
 
*[http://www.isa.utl.pt/dm/sigdr/sigdr04-05/9_SistRefPortugueses.ppt Sistemas Referencia Portugueses]
 
*[http://dl.maptools.org/dl/omsug/osgis2004/PROJ4_HandlingCoordinateSystems.pdf PROJ4_HandlingCoordinateSystems.pdf]
 
*[http://dl.maptools.org/dl/omsug/osgis2004/PROJ4_HandlingCoordinateSystems.pdf PROJ4_HandlingCoordinateSystems.pdf]
 
*[http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34.html Projections and Projected Coordinate System Formulas]
 
*[http://www.posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34.html Projections and Projected Coordinate System Formulas]

Revision as of 17:01, 19 August 2010

This page explains what is PROJ4 library and how to use it from the command line, in Windows and in Linux.

PROJ4 is an open-source Cartographic Projections library originally written by Gerald Evenden then of the USGS. This library has almost all projection types and it is very usefull to convert coordinates for a series of points.

It is written in C but a Fortran wrapper was developed as part of the GLIMMER project. More information can be found in libfproj4

Installation

Windows

  • Download http://download.osgeo.org/proj/proj446_win32_bin.zip
  • Extract and copy "proj" folder to C:\
  • Right-click "My Computer" and select "Properties"
  • Select "Advanced" tab
  • Select "Environment Variables"
  • In the "System Variables" box select "Path" and click "Edit".
  • At the end of the line, add "C:\proj\bin" and click "OK".
  • In the "System Variables" box, click "New".
  • "Variable Name" is PROJ_LIB and "Variable Value" is "C:\proj\nad".
  • Click OK to close windows.

Now test it:

  • Windows/Run/cmd
  • cd .. until prompt is C:\>
  • write "proj -V" to see the version of the library.

Linux

Usage

The Proj4 is well documented. Here are some commands that I found useful.

Projections

  • List of projections in PROJ4: proj -lp

Ellipsoids

  • List of ellipsoids in PROJ4: proj -le
  • More popular:
    • International 1909 (Hayford) intl a=6378388.0m b=6356912m rf=297.
    • New International 1967 new_intl a=6378157.5m b=6356772m
    • WGS 84 WGS84 a=6378137.0m b=6357002m rf=298.257223563
    • Normal Sphere (r=6370997) sphere a=6370997.0m b=6370997m

b = a*(1-f) = a*(1-1/rf)

Portuguese Coordinate Systems in PROJ4

You might want to get the libraries containing the coordinate transformations with portuguese datum pre-configured here. Install the libs in the proj_lib folder, inside the FWTools folder. By the way, you may want to install FWTools first.

Here's the command line on how to convert from military portuguese to wgs84:

 cs2cs +init=pt:dlxhgmil +to +init=pt:etrs89 < coords_input.txt

Portuguese Military Coordinates (Hayford-Gauss Military System)

  • Projection: Gauss-Kruger
  • Ellipsoid: Hayford (internacional 1924): a=6378.388Km, b=6356.912 Km
  • Datum : Lisbon (Castelo S.Jorge: 38º42’43.631’’N, 9º07’54.862’'W, 111.229m)
  • Central Point: 39º40’N, 8º07’54.862’’W
  • Origin: -200Km horizontally and -300 Km vertically

Usage:

  • +init=epsg:20790 <=> +proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1.000000

+x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon +units=m +no_defs no_defs <>

  • +init=esri:102164 <=> +proj=tmerc +lat_0=39.666666667 +lon_0=-8.131906111 +k=1.000000

+x_0=200000.000 +y_0=300000.000 +ellps=intl +units=m (no reference to Lisbon Datum!!)


Universal Transverse Mercator (zone 29N)

Usage:

  • ModuleHorizontalGrid: +init=esri:32629 <=> +proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m

External Links