#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
#    PROJ implementations of current and legacy Icelandic coordinate systems
#
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
#  It is the official definition and implementation of transformations between different Iceland's systems.
#  
#  
#
#  Revision history:
#  -----------------
#
#  2019-11-30  Initial setup.
#              Dalia Prizginiene <dalia@lmi.is>
#
#  
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
<metadata> +version=1.0.0 +origin=LMI +lastupdate=2019-11-30
#
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#  Vertical datum 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISH2004> proj=vgridshift grids=is_lmi_Icegeoid_ISN2004.tif  # current, geoid height calculated using ISN2004 datum
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<ISN93_ISH2004> proj=vgridshift grids=is_lmi_Icegeoid_ISN93.tif  # Icegeoid_ISN2004.tif plus corrections for vertical difference between ISN93 and ISN2004.
<ISN2016_ISH2004> proj=vgridshift grids=is_lmi_Icegeoid_ISN2016.tif  # Icegeoid_ISN2004.tif plus corrections for vertical difference between ISN2016 and ISN2004.

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#  Deformation grids 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<ISN93_16h> proj=hgridshift grids=ISN93_ISN2016.tif
<ISN93_16v> proj=vgridshift grids=ISN93_ISN2016.gtx 

<ISN04_16h> proj=hgridshift grids=ISN2004_ISN2016.tif
<ISN04_16v> proj=vgridshift grids=ISN2004_ISN2016.gtx

<D_93_16> 
    proj=pipeline 
    step init=ISL:ISN93_16h   
    step inv init=ISL:ISN93_16v 
    
<D_04_16> 
    proj=pipeline 
    step init=ISL:ISN04_16h   
    step inv init=ISL:ISN04_16v

#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#  Velocity model
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
# grids=ISN_vel_beta.tif
#
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC ISN2016 (epoch 2016.5, IGS2014, GRS80):  The primary system  
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<ISN2016_LAM>  proj=lcc  lat_1=64.25 lat_2=65.75 lat_0=65 lon_0=-19 x_0=2700000 y_0=300000  ellps=GRS80

#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN2016_LAM
tolerance   0.1 mm
accept      -17 66
expect      2790800.4329    412932.6164 
</gie>


#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC ISN2004 (epoch 2004.6, IGb00, GRS80):  The other systems 
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<ISN2004_LAM>   proj=lcc  lat_1=64.25 lat_2=65.75 lat_0=65 lon_0=-19 x_0=1700000 y_0=300000  ellps=GRS80

#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN2004_LAM
tolerance   0.1 mm
accept      -17 66
expect      1790800.4329    412932.6164
</gie>


#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC ISN93 (epoch 1993.6, ITRF93, GRS80):  The other systems 
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<ISN93_LAM>     proj=lcc  lat_1=64.25 lat_2=65.75 lat_0=65 lon_0=-19 x_0=500000  y_0=500000  ellps=GRS80

#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_LAM
tolerance   0.1 mm
accept      -17 66
expect      590800.4329    612932.6164
</gie>


#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC Hjorsey1955 (ellipsoid: International 1924):  The historical systems 2D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<HJORSEY_LAM> 
    proj=pipeline
    step proj=lcc   lat_1=65  lat_0=65 lon_0=-18 x_0=-500000 y_0=500000 ellps=intl
    step proj=axisswap  order=-1,2,3,4 

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:HJORSEY_LAM
tolerance   0.1 mm
accept      -17 66
expect      454587.8410    611870.0974
</gie>

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC Reykjavik1900 (ellipsoid: Danish):  The historical systems 2D
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<RJ_LAM> proj=lcc lat_1=65  lat_0=65 lon_0=-19.022125 x_0=0 y_0=0 ellps=danish

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:RJ_LAM
tolerance   0.1 mm
accept      -17 66
expect      91794.9450    112953.3882
</gie>

#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#  LCC for Kinematic datum shifting/ dynamic transformation
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<KIN_LAM>  proj=lcc  lat_1=64.25 lat_2=65.75 lat_0=65 lon_0=-19 x_0=4700000 y_0=300000  ellps=GRS80
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:KIN_LAM
tolerance   3 cm
accept      -17 66 0 2017.5
expect      4790800.4329    412932.6164
</gie>

#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#                                      Helmert transformations
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Helmert transformations are used to transform between Reykjavik1900 2D and ISN93 2D also between Hjorsey1955 2D and ISN93 2D
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<REYK19_ISN93>    proj=helmert  convention=coordinate_frame x=556.620 y=-167.901 z=945.664 rx=4.154 ry=-0.269 rz=-2.279 s=-3.729 
<HJ_ISN93>        proj=helmert  x=-72.4 y=46.8 z=-82.7
<REYK19_HJ>       proj=helmert  convention=coordinate_frame x=629.020 y=-214.701 z=1028.364 rx=4.154 ry=-0.269 rz=-2.279 s=-3.729 
#
#
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#                                      Actual transformations
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Reykjavik1900 (Geodetic) 2D -> ISN93 (LCC) 2D
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# from west of Greenwich
<RJ_G> 
    proj=pipeline
    step proj=push +v_3
    step proj=cart   ellps=danish  
    step init=ISL:REYK19_ISN93   
    step proj=cart  inv ellps=GRS80 
    step proj=pop +v_3
    step init=ISL:ISN93_LAM

# Example:
# echo  -21.930875   64.1421888889 0 0  | cct +init=ISL:RJ_G   

# from west of Copenhagen
<RJ_W> 
    proj=pipeline 
    step inv proj=longlat  pm=copenhagen
    step proj=push +v_3
    step proj=cart   ellps=danish  
    step init=ISL:REYK19_ISN93 
    step proj=cart  inv ellps=GRS80 
    step proj=pop +v_3
    step init=ISL:ISN93_LAM

# Example:
# echo  -34.50875   64.1421888889 0 0  | cct +init=ISL:RJ_W   
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:RJ_G
tolerance   50 m
accept      -21.930875   64.1421888889 0
expect      357557.5871   407700.8896  0
</gie>
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:RJ_W
tolerance   50 m
accept      -34.50875   64.1421888889  0
expect      357557.5871   407700.8896  0
</gie>
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Hjorsey1955 (Geodetic) 2D -> ISN93 (LCC) 2D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                
<HJORSEY_ISN93> 
    proj=pipeline  
    step proj=push +v_3
    step proj=cart  ellps=intl 
    step init=ISL:HJ_ISN93 
    step proj=cart inv ellps=GRS80 
    step proj=pop +v_3
    step init=ISL:ISN93_LAM  
                  
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:HJORSEY_ISN93
tolerance   15 m
accept      -21.9933555556   64.1533913888889 0
expect      354399.1771   409035.1420  0
</gie>
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (Geodetic) 3D -> ISN2004 (LCC) 3D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_ISN04> 
    proj=pipeline  
    step init=ISL:D_93_16   
    step inv init=ISL:D_04_16 
    step init=ISL:ISN2004_LAM  

# Example:
# echo -17.981614272222  66.5274148361111 75.737 0 | cct +init=ISL:ISN93_ISN04
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_ISN04
tolerance   5 cm
accept      -17.981614272222  66.5274148361111 75.737 0
expect      1745293.041  470683.539 75.653
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (LCC) 3D -> ISN2004 (LCC) 3D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_L_ISN04> 
    proj=pipeline 
    step inv init=ISL:ISN93_LAM 
    step init=ISL:D_93_16   
    step inv init=ISL:D_04_16 
    step init=ISL:ISN2004_LAM  

# Example:
# echo 545293.098 670683.324   75.737 0 | cct +init=ISL:ISN93_L_ISN04
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_L_ISN04
tolerance   5 cm
accept      545293.098 670683.324   75.737 0
expect      1745293.0413 470683.5387 75.6532
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (Geodetic) 3D -> ISN2004 (Geodetic + Vertical datum)
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_ISN04_v> 
    proj=pipeline  
    step init=ISL:D_93_16   
    step inv init=ISL:D_04_16 
    step init=ISL:ISH2004 

# Example:
# echo -17.981614272222  66.5274148361111 75.737 0   | cct +init=ISL:ISN93_ISN04_v
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_ISN04_v
tolerance   5 cm
accept      -17.981614272222  66.5274148361111 75.737 0
expect      -17.9816154690  66.5274167690  11.6147
</gie>

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN2004 (Geodetic) 3D -> ISN2016 (LCC) 3D
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN04_ISN16> 
    proj=pipeline   
    step init=ISL:D_04_16  
    step init=ISL:ISN2016_LAM
 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN04_ISN16
tolerance   5 cm
accept      -17.98161545  66.5274167694444 75.653 0 
expect      2745292.997 470683.7597 75.618
</gie>

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN2004 (LCC) 3D -> ISN2016 (LCC) 3D
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN04_L_ISN16>
    proj=pipeline 
    step inv  init=ISL:ISN2004_LAM  
    step init=ISL:D_04_16  
    step init=ISL:ISN2016_LAM
 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN04_L_ISN16
tolerance   5 cm
accept      1745293.042 470683.539 75.653 0 
expect      2745292.9970 470683.7595 75.6182
</gie>

#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN2004 (Geodetic) 3D -> ISN2016 (Geodetic + Vertical datum)
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN04_ISN16_v>
    proj=pipeline   
    step init=ISL:ISN04_16h   
    step init=ISL:ISH2004 

# Example:
# echo -17.98161545  66.5274167694444 75.653 0   | cct +init=ISL:ISN04_ISN16_v 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN04_ISN16_v
tolerance   5 cm
accept      -17.98161545  66.5274167694444 75.653 0 
expect      -17.9816163818 66.5274187527  11.6145
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (Geodetic) 3D -> ISN2016 (LCC) 3D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_ISN16> 
    proj=pipeline   
    step init=ISL:D_93_16  
    step init=ISL:ISN2016_LAM  
 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_ISN16
tolerance   5 cm
accept      -17.981614272222  66.5274148361111 75.737 0
expect      2745292.996  470683.760 75.618
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (LCC) 3D -> ISN2016 (LCC) 3D
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_L_ISN16> 
    proj=pipeline 
    step inv   init=ISL:ISN93_LAM  
    step init=ISL:D_93_16  
    step init=ISL:ISN2016_LAM  
 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_L_ISN16
tolerance   5 cm
accept      545293.098 670683.324   75.737 0
expect      2745292.996 470683.759 75.618 
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN93 (Geodetic) 3D -> ISN2016 (Geodetic + Vertical datum)
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_ISN16_v> 
    proj=pipeline   
    step init=ISL:D_93_16  
    step init=ISL:ISN04_16v 
    step init=ISL:ISH2004 

# Example:
# echo -17.981614272222  66.5274148361111 75.737 0   | cct +init=ISL:ISN93_ISN16_v 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_ISN16_v
tolerance   5 cm
accept      -17.981614272222  66.5274148361111 75.737 0
expect      -17.9816164008 66.5274187522  11.6147
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC ISN93 3D -> ISN93 (Geodetic + Vertical datum)
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN93_ISH2004_v> 
    proj=pipeline   
    step inv init=ISL:ISN93_LAM   
    step init=ISL:ISN93_ISH2004 

# Example:
# echo 545293.098 670683.324   75.737  0   | cct +init=ISL:ISN93_ISH2004_v 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN93_ISH2004_v
tolerance   5 cm
accept      545293.098 670683.324   75.737  0
expect      -17.9816142725   66.5274148323   11.6147
</gie>

#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# LCC ISN2016 3D -> ISN2016 (Geodetic + Vertical datum)
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<ISN2016_ISH2004_v> 
    proj=pipeline    
    step inv init=ISL:ISN2016_LAM    
    step init=ISL:ISN2016_ISH2004 

# Example:
# echo 2745292.998 470683.759  75.618   0   | cct +init=ISL:ISN2016_ISH2004_v 
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<gie>
operation   init=ISL:ISN2016_ISH2004_v
tolerance   5 cm
accept      2745292.998 470683.759  75.618   0
expect      -17.9816163630   66.5274187459   11.6143
</gie>

#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN_DRF (Geodetic): epoch 2018.679 -> ISN_DRF (LCC): epoch  2017.5  3D
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<DRF_E>  
    proj=pipeline  
    step proj=cart  ellps=GRS80 
    step proj=deformation  dt=-1.179 xy_grids=ISN_vel_beta.ct2 z_grids=ISN_vel_beta.gtx  
    step proj=cart inv ellps=GRS80 
    step init=ISL:KIN_LAM 

# Example:
# echo -18.1224832715  65.6854274786 134.2043   | cct +init=ISL:DRF_E
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<gie>
operation   init=ISL:DRF_E
tolerance   3 cm
accept      -18.1224832715  65.6854274786 134.2043
expect      4740331.7212 376698.7742 134.2005
</gie>            

#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ISN_DRF (Geodetic): epoch 2018.679 -> ISN2016 (LCC)    3D
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<DRF_2016>  
    proj=pipeline 
    step proj=cart ellps=GRS80 
    step proj=deformation dt=-2.179 xy_grids=ISN_vel_beta.ct2 z_grids=ISN_vel_beta.gtx 
    step proj=cart inv ellps=GRS80 
    step init=ISL:ISN2016_LAM

# Example:
# echo -18.1224832715  65.6854274786 134.2043    | cct +init=ISL:DRF_2016
#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<gie>
operation   init=ISL:DRF_2016
tolerance   3 cm
accept      -18.1224832715  65.6854274786 134.2043 
expect      2740331.7315 376698.7505 134.1972
</gie>   
