Welcome, Guest
Username: Password: Remember me

TOPIC: Coordinate conversion

Coordinate conversion 11 years 2 months ago #10146

  • OGW
  • OGW's Avatar
Hello I am trying to convert the coordinates of Telemac2D results files but I am experiencing some difficulties. My model mesh is built in WGS84 coordinates, which is converted to Telemac mercator corrdinates in the CORRXY subroutine using the following code

DO I = 1 , N
X(I) = RADIUS*(X(I)-LON0)*DTR
Y(I) = RADIUS*( LOG(TAN(Y(I)*0.5D0*DTR+PI*0.25D0))
& -LOG(TAN(LAT0 *0.5D0*DTR+PI*0.25D0)))
ENDDO

I am then post processing the reults files to convert the Telemac mercator coordinates back to WGS84 using the following code which should just be the inverse of what was done previously

R=6371000
pi=3.14259
DTR=pi/180
RTD=180/pi
lon0=0
lat0=50

term2=R*log(tan(radians(lat0/2)+(pi/4)))

def x2lon(x):
lamda=lon0+degrees(x/R)
return lamda

def y2lat(y):
phi=(2*(arctan(exp((y+term2)/R))))-(pi/2)
phi=degrees(phi)
return phi

lono=x2lon(x)
lato=y2lat(y)

However this does not give a good coordinate conversion. I have tried changing the offset values (lon0 and lat0) and this does improve results however there is still a significant error. Has anyone had any experience with this and could you advise me where I might be going wrong?

Thanks

Olly
The administrator has disabled public write access.

Coordinate conversion 11 years 2 months ago #10178

  • OGW
  • OGW's Avatar
I am now trying to convert my WGS84 grid into UTM coordinates in the CORRXY subroutine. However I am experiencing some difficulties. I am printing the converted coordinates to a text file to check the calculation and they are of the same order of magnitude but not quite right. I also get the following error

*************************************
* END OF MEMORY ORGANIZATION: *
*************************************

INBIEF (BIEF): NOT A VECTOR MACHINE (ACCORDING TO YOUR DATA)
GEOELT: ELEMENT 100482 : NEGATIVE DETERMINANT

Has anyone done something similar to this before and could advise me as to where I am going wrong?

Thanks

Olly
Attachments:
The administrator has disabled public write access.

Coordinate conversion 11 years 2 months ago #10236

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Before looking further, it seems that your value of PI is not correct : 3.14259 ?? Is it not 3.1415926535897932384626433... ???

JMH
The administrator has disabled public write access.

Coordinate conversion 11 years 2 months ago #10238

  • OGW
  • OGW's Avatar
Hello, yes so it is. I have corrected that but I still can not seem to convert from Telemac Mercator to WGS84 with any accuracy. I have now debugged my code for converting to UTM which appears to work reasonably well. I will continue to try to convert to WGS84, if you could offer any advice it would be very much appreicated. Thanks for your time.

Olly
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.