Plot GeoCircles from lat, lon, radius data?

Posted 1 month ago
231 Views
|
14 Replies
|
1 Total Likes
|
 Thus far I’ve been able to plot out points from a database table selecting the latitude and longitude. I want to be able to add a third parameter, accuracy in meters, and plot the map with GeoCircles with the accuracy in meters as the radius. I can’t seem to figure out how to get that third variable working.So I get to GeoGraphics[GeoCircle @@@ data], which works with latitude and longitude alone ({latitude,longitude}), but I can’t figure out a way to add the accuracy piece to specify the circle radius in meters ({latitude,longitude,radius} doesn’t work).Help? Answer
14 Replies
Sort By:
Posted 1 month ago
 Using Mathematica 12.0: data = {{{45., 11.}, Quantity[100., "km"]}, {{48., 10.}, Quantity[25., "Miles"]}}; Map[GeoGraphics[GeoCircle[#[], #[]]] &, data] Answer
Posted 1 month ago
 I’m pulling this data from a database (latitude, longitude, accuracy), so how would it format for that? I’ve got GeoCircle @@@ data, but is there a way to select a specific field in data so I could structure it like GeoCircle [{{data.latitude, data.longitude}, Quantity[data.accuracy,”m”]}? Answer
Posted 1 month ago
 You could do it this way: ds = Dataset[ Map[<|Thread[{"lat", "lon", "r"} -> #]|> &, {{45., 11., 100.}, {48., 10., 25.}}]] Map[GeoGraphics[ GeoCircle[Take[#, 2], Quantity[#[[-1]], "km"]]] &, (ds[Values] // Normal)] Answer
Posted 1 month ago
 Sorry, but I’m still confused. I’m pulling the data from an SQLite database, and your response suggests that I’m supposed to enter it all manually. This language has got a steep learning curve. Needs[“DatabaseLink"] conn = OpenSQLConnection["Dash"]; data = SQLExecute[conn, "SELECT latitude, longitude, accuracy FROM points WHERE DATETIME(time/1000,'unixepoch','localtime') >= DATETIME('now','start of day','-1 days') AND DATETIME(time/1000,'unixepoch','localtime') < DATETIME('now','start of day') ORDER BY time"]; This is going to give me tuplets (triplets, if you will) in response Answer
Posted 1 month ago
 Well, you did not supply any data earlier so I had to cook something up. If I understand correctly, the data you extract should look like what you get from (ds[Values] // Normal) in the example I attached. It is a vector of three numbers for each record. Can you bring it to this form? Answer
Posted 1 month ago
 The output from the query looks like this (showing just the first part because it’s 57,000 points in the database and growing); basically triplets/vectors of {latitude, longitude, accuracy in meters}:{{27.9842, -82.5698, 2.55041}, {27.9847, -82.5702, 4.30254}, {27.9847, -82.5702, 4.30254}, {27.9847, -82.5702, 4.30254}, … } Answer
Posted 1 month ago
 I suppose these are {{lat,lon,R},..} data each. So you extract the data from the sqldata base, call this resulting table "dbdata" or whatever and you replace (ds[Values] // Normal) (which is so to say the query from my dataset) with dbdata Map[GeoGraphics[ GeoCircle[Take[#, 2], Quantity[#[[-1]], "km"]]] &, dbdata] Answer
Posted 1 month ago
 OK, I did here with the data you supplied: dbdata = {{27.9842, -82.5698, 2.55041}, {27.9847, -82.5702, 4.30254}, {27.9847, -82.5702, 4.30254}, {27.9847, -82.5702, 4.30254}} Map[GeoGraphics[ GeoCircle[Take[#, 2], Quantity[#[[-1]], "km"]]] &, dbdata] Note that according to your spec "km" should be replaced with "m", but if you do so the resulting images will not show much interesting stuff due to the limited resolution of th emap Answer
Posted 1 month ago
 Didn’t quite work the way I wanted; it produced 265 page png with just the circles rather than a larger image with all the circles in one page. Needs["DatabaseLink"]; conn = OpenSQLConnection["Dash"]; data = SQLExecute[conn, "SELECT latitude, longitude, altitude FROM points WHERE DATETIME(time/1000,'unixepoch','localtime') >= DATETIME('now','start of day','-1 days') AND DATETIME(time/1000,'unixepoch','localtime') < DATETIME('now','start of day') ORDER BY time"]; img = Map[GeoGraphics[GeoCircle[Take[#, 2], Quantity[#[[-1]], "m"]]] &, data]; myFileName = "/Volumes/4TB External/Databases/Maps/" <> Riffle[ToString /@ PreviousDate["Day"][][[;; 3]], "-"] <> ".png"; Export[myFileName, img] Answer
Posted 1 month ago
 This is an example of what I started with; I wanted to create a new script that instead of the line would show the points with the accompanying margin of error. Most resulting maps would be zoomed enough to see large differences in the accuracy (the long excursion up to Atlanta and back was evacuating from Hurricane Irma in 2017). Needs["DatabaseLink"]; conn = OpenSQLConnection["Dash"]; data = SQLExecute[conn, "SELECT latitude, longitude FROM points ORDER BY time"]; img = GeoGraphics[{Blue, Thick, Line@GeoPosition@data}, GeoScaleBar -> "Imperial", ImageSize -> Full, GeoBackground -> GeoStyling["StreetMap"]]; myFileName = "/Volumes/4TB External/Databases/Maps/" <> Riffle[ToString /@ PreviousDate["Day"][][[;; 3]], "-"] <> ".png"; Export["/Volumes/4TB External/Databases/Maps/alltrips.png", img]  Answer
Posted 1 month ago
 If you want to have all the GeoCircles in one image you just pull the GeoGraphics command out of the expression following Map: GeoGraphics[ Map[GeoCircle[Take[#, 2], Quantity[#[[-1]], "km"]] &, dbdata]] Answer
Posted 1 month ago
 That didn’t quite work, neither: Needs["DatabaseLink"]; conn = OpenSQLConnection["Dash"]; data = SQLExecute[conn, "SELECT latitude, longitude, altitude FROM points WHERE \ DATETIME(time/1000,'unixepoch','localtime') >= DATETIME('now','start \ of day','-1 days') AND DATETIME(time/1000,'unixepoch','localtime') < \ DATETIME('now','start of day') ORDER BY time"]; img = GeoGraphics[Map[GeoCircle[Take[#, 2], Quantity[#[[-1]], "m"]]] &, data]; myFileName = "/Volumes/4TB External/Databases/Maps/" <> Riffle[ToString /@ PreviousDate["Day"][][[;; 3]], "-"] <> "_circles.png"; Export[myFileName, img]  Answer
Posted 1 month ago
 My command was: GeoGraphics[ Map[GeoCircle[Take[#, 2], Quantity[#[[-1]], "km"]] &, dbdata]] Apparently you have set the "]" brackets differently which you can spot if yoe look at the very end of your command (yours -> dbdata], mine -> dbdata]] ) Answer
Posted 1 month ago
 That was the issue. Thanks everyone for all the help; this product’s got a bit of a learning curve. :-)  Answer