You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had issues in mikeio when trying to create a Dfs2 file with a Lambert_Conformal_Conic_2SP projection. I can do this succesfully when trying manually (i.e. in MIKE Zero GUI), and in mikecore. So I traced the issue to the mikecore.projections.MapProjection class used to setup the Dfs2 projection info for the Dfs2 builder: when it tries to convert projected coordinates it runs into numerical issues. See example below:
Fail case: Lambert_Conformal_Conic_2SP projection
frommikecore.ProjectionsimportMapProjection# The projected and geographic coordinates here are the same# This can be converted back and forth using the Datum Converter tool in MIKE Zeroorigin_projected= [ -65900.32888812723, -678217.039068304]
origin_geographic= [ 24.01529,-34.987278]
# Custom projection stringproj_str='PROJCS["Custom",GEOGCS["Unused",DATUM["User defined",SPHEROID["WGS 1984",6378137,298.257223563]],'+\
'PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],'+\
'PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",24.751587],'+\
'PARAMETER["Standard_Parallel_1",-40],PARAMETER["Standard_Parallel_2",-10],'+\
'PARAMETER["Latitude_Of_Origin",-28.702538],UNIT["Meter",1]]'# Try conversion using MIKE MapProjectionproj_core=MapProjection.Create(proj_str)
# Projected to Geographic Failsprint(proj_core.Proj2Geo(*origin_projected))
# Geographic to Projected worksprint(proj_core.Geo2Proj(*origin_geographic))
As you can see the Lambert_Conformal_Conic_2SP coordinate pairs fail when trying to converted from projected to geographical coordinates, while the reverse works just fine. I haven't tested this in the .NET/C# code, but I'm confident this isn't correct behaviour.
Working case: Transverse_Mercator projection
frommikecore.ProjectionsimportMapProjection# Coordinate info# The projected and geographic coordinates here are the same# This can be converted back and forth using the Datum Converter tool in MIKE Zeroorigin_projected= [ -89907.8133323,-3873624.5460040]
origin_geographic= [ 24.01529,-34.987278]
# Custom projection stringproj_str='PROJCS["WG25",GEOGCS["Unused",DATUM["User defined",SPHEROID["WGS 1984",6378137,298.257223563]],'+\
'PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],'+\
'PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",25],PARAMETER["Scale_Factor",1],'+\
'PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]'# Try conversion using MIKE MapProjectionproj_core=MapProjection.Create(proj_str)
# Projected to Geographic Failsprint(proj_core.Proj2Geo(*origin_projected))
# Geographic to Projected worksprint(proj_core.Geo2Proj(*origin_geographic))
Solution/Fix:
The problem is the MzCart.dll version 20.0.0.15310. It's encrypted, so I can't trace the issue further, but I replaced it with the version 21.0.0.16308 from the MIKE 2023 SDK and that solves the issue.
Thanks for finding a solution. I think it is time to bump the references to the MIKE Core/SDK components from 20.0 to 21.0. I will put that on my todo-list.
Hi,
I had issues in mikeio when trying to create a Dfs2 file with a Lambert_Conformal_Conic_2SP projection. I can do this succesfully when trying manually (i.e. in MIKE Zero GUI), and in mikecore. So I traced the issue to the
mikecore.projections.MapProjection
class used to setup the Dfs2 projection info for the Dfs2 builder: when it tries to convert projected coordinates it runs into numerical issues. See example below:Fail case: Lambert_Conformal_Conic_2SP projection
As you can see the Lambert_Conformal_Conic_2SP coordinate pairs fail when trying to converted from projected to geographical coordinates, while the reverse works just fine. I haven't tested this in the .NET/C# code, but I'm confident this isn't correct behaviour.
Working case: Transverse_Mercator projection
Success - works as expected!
The text was updated successfully, but these errors were encountered: