Location calculation- is UTM appropiate?

2019-08-10 12:16发布

I'm wanting to calculate the location of point D, based on the location of point A B and C where I know the angle of point A relative to D and D relative to B and c relative to D.

In real terms, points A B and C are 3 locations i have marked with my GPS and point D is the location of a radiocollared animal I'm attempting to get a GPS location on. The angles I gain by knowing in which direction the radio collared animal is relative to north.

I've written the algorithm, but I know I can't put GPS co-ordinates straight into it and will have to convert them in and then out again. I've been googling, and I'm a bit confused, is the usage of cartesian or UTM more appropriate for this?

How do I go about converting GPS to UTM? I've searched and I'm a bit confused. Some conversions talk of degrees minutes adn seconds, my GPS appears to give me an addiitonal number to this, so its N 68.21.446 and `w 12.14.284

Incase its relevant, I've assumed that the area is 2d in my calculations to make things a bit simpler.

Thank you for your help. Here is the code though I'm not sure its needed:

#10/09/2013
#Enter your points for locations A B and C 
#AN and AW is your first GPS points AA is the angle
AN<-10
AW<-0
AA<-45
#BN and BW are your second  
BN<-10
BW<-0
BA<-0
#CN and CW are your third
CN<-0
CW<-10
CA<-90

#Convert these to ?



#work out distance 
#For each co ordinate and angle, you need to calculate y=mx+c to make a line
#From these 3 lines, you can work out where they intersect

#If the angle is 0 it wont work, so make it very close to 0. 
if(AA==0) {AA<-0.00001}
if(BA==0) {BA<-0.00001}
if(CA==0) {CA<-0.00001}

#Convert all angles to radians
AAr<-(AA*pi)/180
BAr<-(BA*pi)/180
CAr<-(CA*pi)/180

#Calculate M which is 1/tan(b)
AM<-1/tan(AAr)
BM<-1/tan(BAr)
CM<-1/tan(CAr)

#Calculate C the equation constant
#c=y-m*x
AC<-AW-AM*AN
BC<-BW-BM*BN
CC<-CW-CM*CN

#Caclulate intersections
#A and B 
XAB<-(AC-BC)/(BM-AM)
YAB<-(AM*XAB+AC)

#B and C 
XBC<-(BC-CC)/(CM-BM)
YBC<-(BM*XBC+BC)

#C and A
XAC<-(CC-AC)/(AM-CM)
YAC<-(CM*XAC+CC)

#Work out average of these 3 points
(XofABC<-(XAB+XBC+XAC)/(3))
(YofABC<-(YAB+YBC+YAC)/(3))


#Convert this back into GPS coordinate

`

标签: r gps
2条回答
Fickle 薄情
2楼-- · 2019-08-10 12:52

Coordinate system transformations are done using the spTransform function in the rgdal package. You'll need to convert your coordinates to decimal degrees before you can convert them to UTM coords.

So, what is your "N 68.21.446" in decimal degrees? Well I'm not sure. Its 68 + (21/60) but you need to find out what the last number is. It might be a) thousandths of a minute (and if the first digit of it is ever 6 or more then that would seem likely) or b) two digits for seconds and then tenths of seconds.

For a) N 68.21.446 is then 68 + (21/60) + (446/1000)/60 decimal degrees.

For b) N 68.21.446 is then 68 + (21/60) + (44/3600) + (6/36000) decimal degrees.

You'll have to use some string matching functions to split it up.

Once you've got decimal degrees, create a spatial points dataframe with those numbers, set its CRS to your GPS coordinate system (probably EPSG code 4326) and then use spTransform to convert to your UTM code - use the one appropriate for your longitude.

Unless its polar bears or emperor penguins and the distances are not tens of km then the UTM coordinates should be a good approximation to a regular square grid. The bigger source of error is going to be your angular measurements!

On that subject, I did start writing an R package for doing location finding from radio direction finding equipment, implementing some of the statistical methods in the literature. You'll find that here: https://github.com/barryrowlingson/telemetr

If you have any comments on that package, address them to me via that github site, and not here on StackOverflow.

查看更多
Rolldiameter
3楼-- · 2019-08-10 13:07

UTMs are handy for this sort of operation as they're based on a square mapping datum and are flat 2D x-y cartesian system.

But beware of their limitations especially towards higher latitudes. And be careful that the system you choose is relevant to your location – some datum systems will be very warped if you use the wrong one.

Not sure why this is tagged in R?

Code looks like it should be fine.

查看更多
登录 后发表回答