Plotting a location given a starting LatLon and distance and bearing
up vote
0
down vote
favorite
So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.
Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!
It seems my hang up is all in the find_points function.
def find_points(dist, bear):
dist_adj = 63 / 10.71
bear = (bear - 90 - 29 + 360) % 360
print (bear)
bear_rad = radians(bear)
print (bear_rad)
adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
start_mat = [dist, 0]
xy = np.matmul(adj_mat , start_mat)
return xy[0], xy[1]
the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).
EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.
The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.
All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.
Anyways, count this one solved. :)
python
add a comment |
up vote
0
down vote
favorite
So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.
Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!
It seems my hang up is all in the find_points function.
def find_points(dist, bear):
dist_adj = 63 / 10.71
bear = (bear - 90 - 29 + 360) % 360
print (bear)
bear_rad = radians(bear)
print (bear_rad)
adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
start_mat = [dist, 0]
xy = np.matmul(adj_mat , start_mat)
return xy[0], xy[1]
the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).
EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.
The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.
All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.
Anyways, count this one solved. :)
python
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.
Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!
It seems my hang up is all in the find_points function.
def find_points(dist, bear):
dist_adj = 63 / 10.71
bear = (bear - 90 - 29 + 360) % 360
print (bear)
bear_rad = radians(bear)
print (bear_rad)
adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
start_mat = [dist, 0]
xy = np.matmul(adj_mat , start_mat)
return xy[0], xy[1]
the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).
EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.
The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.
All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.
Anyways, count this one solved. :)
python
So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.
Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!
It seems my hang up is all in the find_points function.
def find_points(dist, bear):
dist_adj = 63 / 10.71
bear = (bear - 90 - 29 + 360) % 360
print (bear)
bear_rad = radians(bear)
print (bear_rad)
adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
start_mat = [dist, 0]
xy = np.matmul(adj_mat , start_mat)
return xy[0], xy[1]
the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).
EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.
The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.
All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.
Anyways, count this one solved. :)
python
python
edited Nov 13 at 8:48
asked Nov 9 at 19:03
dreamsofhabit
14
14
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231851%2fplotting-a-location-given-a-starting-latlon-and-distance-and-bearing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown