Personal tools

PROJ4

From MohidWiki

Revision as of 22:59, 10 October 2009 by Guillaume (talk | contribs)
Jump to: navigation, search

This section explains how to use PROJ4 library from Fortran. PROJ4 is a Cartographic Projections library originally written by Gerald Evenden then of the USGS. This library has almost all projection types. Fortran wrapper code was developed as part of the GLIMMER project and can be found in libfproj4-1.0.tar.gz.


Compilation

UNIX

Just follow the instructions.

Windows

  • Download \\kepler\Software\PROJ4\libfproj4.lib for Compaq Visual Studio, or
  • Compile W32 static lib:
    1. Extract proj4 source code and configure it (bash configure).
    2. New project W32 static lib
    3. 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.
    4. Project Settings / C/C++ / General / Preprocessor definitions : VISUAL_CPLUSPLUS ou IFORT
    5. Project Settings / C/C++ / Preprocessor / include : whatever\proj-4.6.0\src (the folder that has projects.h, because of directives #include <projects.h>)

Test Fortran API

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
  1. New Fortran console application
  2. add fortran files
  3. project settings:
    1. Link / Input / Obj/library modules : libfproj4.lib
    2. Link / Input / Additional include path : path to libfproj4.lib and proj4.inc)

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