项目作者: mrihtar

项目描述 :
Geographic Coordinate Converter for Slovenia
高级语言: C
项目地址: git://github.com/mrihtar/GeoCoordinateConverter.git
创建时间: 2015-01-10T01:26:39Z
项目社区:https://github.com/mrihtar/GeoCoordinateConverter

开源协议:GNU Lesser General Public License v2.1

下载


Geo Coordinate Converter http://geocoordinateconverter.tk

Travis AppVeyor Codecov

Za slovensko verzijo te datoteke glej PREBERIME.md.

gk-slo is a converter between geographic cartesian coordinates
(Gauss-Krueger/D48, Transverse Mercator/D96) and geodetic coordinates
(latitude/longitude on ETRS89/WGS84) for Slovenia. It can be used
as a replacement for the official conversion program SiTra (with
Helmert parameters for the whole Slovenia, no regional parameters)
or more precise when used with the built-in affine/triangle-based
transformation using the reference virtual tie points v3.0 (for
detailed description see AFT.md), which is similar as the official
conversion program 3Tra.

Program can read files in SiTraNet format (ASCII XYZ), LIDAR (ASCII
XYZ with semicolon, .asc) or ESRI shapefile (ArcGIS .shp format, use
gk-shp).

The following transformations are available (in both directions):

  1. xy (D96/TM) φλ (ETRS89)
  2. xy (D48/GK) xy (D96/TM) Helmert transformation
  3. xy (D48/GK) φλ (ETRS89) Helmert transformation
  4. xy (D48/GK) xy (D96/TM) Affine transformation
  5. xy (D48/GK) φλ (ETRS89) Affine transformation

For calculating heights with the help of geoid model two absolute
geoid models for Slovenia are available: Slo2000 and EGM2008.

It’s written in C language and can be compiled and used on all major
operating systems. Coordinate conversion routines can be easily adapted
to locations other than Slovenia (via definition of ellipsoid, projection
and Helmert parameters).

Detailed description of coordinate conversion routines and their API
(in module “geo.c”) is in file geo_api.md.

List of literature used (with links to documents) is in file literature.md.

Precompiled version of gk-slo/gk-shp for Windows (32-bit, compiled with
MinGW) can be downloaded from gk-slo-9.07.zip.

Conventions

Cartesian coordinates Geodetic coordinates
x = easting fi = phi (φ), latitude, Breite (N/S)
y = northing la = lambda (λ), longitude, Länge (E/W)
H = ortometric/above sea level height h = ellipsoidal height

Ng = geoid height

Files

  • common.h
    Include file with common definitions for Windows and Unix environment
  • util.c
    Collection of utility functions for use in other parts of program
  • geoid_slo.h
    Absolute geoid model for Slovenia from GURS (Slo2000)
  • geoid_egm.h
    Absolute geoid model for Slovenia from EGM2008
  • aft_gktm.h, aft_tmgk.h
    Pre-calculated affine transformation tables for Slovenia
  • geo.h
    Include file for using coordinate conversion routines
  • geo.c
    Collection of coordinate conversion routines
  • gk-slo.c
    Main cmd-line program for converting coordinates from XYZ files
  • gk-shp.c
    Main cmd-line program for converting coordinates from shapefiles
  • shapelib
    Files from Shapefile C Library needed for reading and writing ESRI
    Shapefiles

How to compile

Unix

$ cc -O2 -Wall -msse2 -mfpmath=sse gk-slo.c util.c geo.c -o gk-slo -lm -lrt
$ cc -O2 -Wall -msse2 -mfpmath=sse -Ishapelib gk-shp.c util.c geo.c \
shapelib\shpopen.c shapelib\dbfopen.c shapelib\safileio.c shapelib\shptree.c -o gk-shp -lm -rt
or
$ make -f Makefile.unix

MinGW on Windows

$ gcc -O2 -Wall -msse2 -mfpmath=sse -D_WCHAR gk-slo.c util.c geo.c -o gk-slo.exe
$ gcc -O2 -Wall -msse2 -mfpmath=sse -Ishapelib gk-shp.c util.c geo.c \
shapelib\shpopen.c shapelib\dbfopen.c shapelib\safileio.c shapelib\shptree.c -o gk-shp.exe
or
$ make -f Makefile.mingw

Microsoft C

$ cl /O2 /Wall -D_WCHAR gk-slo.c util.c geo.c
$ cl /O2 /Wall /Ishapelib gk-shp.c util.c geo.c \
shapelib\shpopen.c shapelib\dbfopen.c shapelib\safileio.c shapelib\shptree.c
or
$ nmake -f Makefile.msc

MacOS (10.12 Sierra and later)

$ make -f Makefile.macos gk-slo gk-shp

Options -msse2 -mfpmath=sse are needed because otherwise we’ll get
different results on different systems (for more explanation see
StackOverflow).

Usage

  1. $ gk-slo [] [ ...]
  2. -d enable debug output
  3. -ht calculate output height with 7-params Helmert trans.
  4. -hc copy input height unchanged to output
  5. -hg calculate output height from geoid model (default)
  6. -g slo|egm select geoid model (Slo2000 or EGM2008)
  7. default: Slo2000
  8. -dms display fila in DMS format after height
  9. -t select transformation:
  10. 1: xy (d96tm) --> fila (etrs89), hg?, default
  11. 2: fila (etrs89) --> xy (d96tm), hg
  12. 3: xy (d48gk) --> fila (etrs89), ht
  13. 4: fila (etrs89) --> xy (d48gk), hg
  14. 5: xy (d48gk) --> xy (d96tm), hg(hc)
  15. 6: xy (d96tm) --> xy (d48gk), ht(hc)
  16. 7: xy (d48gk) --> xy (d96tm), hc, affine trans.
  17. 8: xy (d96tm) --> xy (d48gk), hc, affine trans.
  18. 9: xy (d48gk) --> fila (etrs89), hg, affine trans.
  19. 10: fila (etrs89) --> xy (d48gk), hg, affine trans.
  20. -r reverse parsing order of xy/fila
  21. (warning is displayed if y < 200000 or la > 17.0)
  22. parse and convert input data from
  23. "-" means stdin, use "--" before
  24. -o -|=| write output data to:
  25. -: stdout (default)
  26. =: append ".out" to each and
  27. write output to these separate files
  28. : write all output to 1 file
  29. Typical input data format (SiTra .xyz or LIDAR .asc):
  30. [

A new program gk-shp, able to read [ESRI shapefiles] (ArcGIS .shp format),
has similar syntax:

  1. $ gk-shp []
  2. -d enable debug output
  3. -ht calculate output height with 7-params Helmert trans.
  4. -hc copy input height unchanged to output
  5. -hg calculate output height from geoid model (default)
  6. -g slo|egm select geoid model (Slo2000 or EGM2008)
  7. default: Slo2000
  8. -dms display fila in DMS format after height
  9. -t select transformation:
  10. 1: xy (d96tm) --> fila (etrs89), hg?, default
  11. 2: fila (etrs89) --> xy (d96tm), hg
  12. 3: xy (d48gk) --> fila (etrs89), ht
  13. 4: fila (etrs89) --> xy (d48gk), hg
  14. 5: xy (d48gk) --> xy (d96tm), hg(hc)
  15. 6: xy (d96tm) --> xy (d48gk), ht(hc)
  16. 7: xy (d48gk) --> xy (d96tm), hc, affine trans.
  17. 8: xy (d96tm) --> xy (d48gk), hc, affine trans.
  18. 9: xy (d48gk) --> fila (etrs89), hg, affine trans.
  19. 10: fila (etrs89) --> xy (d48gk), hg, affine trans.
  20. -r reverse parsing order of xy/fila
  21. (warning is displayed if y < 200000 or la > 17.0)
  22. parse and convert input data from
  23. write output data to
  24. Input data format:
  25. ESRI Shapefile (ArcGIS)

Example 1 (D48)

Input file VTG2225.XYZ (DMV, in SiTraNet format, Gauss-Krueger/D48):

  1. 0000001 509000.000 76000.000 343.30
  2. 0000002 509005.000 76000.000 342.80
  3. 0000003 509010.000 76000.000 342.30
Convert to new coordinate system (Transverse Mercator/D96); heights should be copied, not calculated:
  1. $ gk-slo -t 5 -hc VTG2225.XYZ
  2. VTG2225.XYZ: possibly reversed x/y
  3. 0000001 509487.490 575640.546 343.300
  4. 0000002 509492.490 575640.546 342.800
  5. 0000003 509497.490 575640.546 342.300
If you see the warning "**possibly reversed x/y**", use the option "**-r**" to get the correct conversion:
  1. $ gk-slo -t 5 -hc -r VTG2225.XYZ
  2. 0000001 76484.893 508628.990 343.300
  3. 0000002 76484.893 508633.991 342.800
  4. 0000003 76484.893 508638.991 342.300
Convert the same file to ETRS89/WGS84 coordinates. This time the height will be recalculated using Helmert transformation (default):
  1. $ gk-slo -t 3 -r VTG2225.XYZ
  2. 0000001 45.8281655853 15.1110624092 389.063
  3. 0000002 45.8281655218 15.1111267639 388.563
  4. 0000003 45.8281654582 15.1111911187 388.063
For better readout you can include the option "**-dms**":
  1. $ gk-slo -t 3 -r -dms VTG2225.XYZ
  2. 0000001 45.8281655853 15.1110624092 389.063 45 49 41.39611 15 6 39.82467
  3. 0000002 45.8281655218 15.1111267639 388.563 45 49 41.39588 15 6 40.05635
  4. 0000003 45.8281654582 15.1111911187 388.063 45 49 41.39565 15 6 40.28803
Store result in a file:
  1. $ gk-slo -t 3 -r VTG2225.XYZ -o VTG2225.flh
  2. (creates file VTG2225.flh)

Example 2 (D96)

Input file VTC0512.XYZ (DMV, in SiTraNet format, Transverse Mercator/D96):

  1. 0000001 412250 97000 606.2
  2. 0000002 412250 96995 606.9
  3. 0000003 412250 96990 607.9
Convert to ETRS89/WGS84 coordinates, height will be recalculated using geoid model Slo2000 (default):
  1. $ gk-slo -t 1 -r VTC0512.XYZ
  2. 0000001 46.0071929697 13.8669428837 652.772
  3. 0000002 46.0071479903 13.8669438021 653.472
  4. 0000003 46.0071030110 13.8669447206 654.472
If you want to use the EGM2008 geoid model, use the "**-g egm**" option:
  1. $ gk-slo -t 1 -r -g egm VTC0512.XYZ
  2. 0000001 46.0071929697 13.8669428837 652.660
  3. 0000002 46.0071479903 13.8669438021 653.359
  4. 0000003 46.0071030110 13.8669447206 654.359

Example 3 (ETRS89/WGS84)

Convert ETRS89/WGS84 coordinates to Transverse Mercator/D96 via keyboard
(ignoring height, use ““ to stop parsing options):

  1. $ gk-slo -t 2 -- -
  2. 46.0071929697 13.8669428837 0
  3. 97000.000 412250.000 -46.572
Convert file VTG2225.flh (with ETRS89/WGS84 coordinates, see Example 1) to Gauss-Krueger/D48:
  1. $ gk-slo -t 4 VTG2225.flh
  2. 0000001 76000.000 509000.000 342.896
  3. 0000002 76000.000 509005.000 342.396
  4. 0000003 76000.000 509010.000 341.896
If you compare the output with the original VTG2225.XYZ, you'll notice a small difference in heights. This is because the heights in VTG2225.flh were calculated using Helmert transformation but the default height calculation for "-t 4" is using geoid model. Which height calculation you use for conversion depends also on input data. There are some recommended defaults for each type of conversion (see Usage). #### Example 4 (processing many files) If gk-slo was compiled with MinGW on Windows or is being used on Unix, you can process many files with one command. Input files ∗.XYZ (DMV, Transverse Mercator/D96):
  1. VTH0720.XYZ
  2. VTH0721.XYZ
  3. VTH0722.XYZ
  4. ...

Convert all files to ETRS89/WGS84 coordinates (with some debug info to see
what’s going on):

  1. $ gk-slo -t 1 -r -d ∗.XYZ -o =
  2. Processing VTH0720.xyz
  3. Processing time: 4.854913
  4. Processing VTH0721.xyz
  5. Processing time: 4.846438
  6. Processing VTH0722.xyz
  7. Processing time: 4.846361
  8. ...
Results of conversion for each file are written to a new file with an extension ".out":
  1. VTH0720.XYZ.out
  2. VTH0721.XYZ.out
  3. VTH0722.XYZ.out
  4. ...

Example 5 (ESRI shapefiles)

Input file RABA_20151031.shp (GERK, in ESRI shapefile format,
Gauss-Krueger/D48), convert to ETRS89/WGS84 coordinates using affine
transformation (with debug info):


  1. $ gk-shp -t 9 -dd RABA_20151031.shp raba_conv.shp
    Processing RABA_20151031.shp
    Shapefile type: Polygon, number of shapes: 1601832
    Shape: 678 (0.04%)

Result of conversion is a set of files according to ESRI shapefile format:


  1. raba_conv.cpg
    raba_conv.dbf
    raba_conv.prj
    raba_conv.shp
    raba_conv.shx

In file raba_conv.prj an output projection (WGS84) is stored, so converted
files can be easily opened by GIS programs.