Hi! In Ona.io's CSV exports and I'm guessing in ODK Aggregate too, the geo-trace and area fields are stored in one column/field as a string of lat-longs, like so:
18.530663 73.875515 0 0;18.534935 73.874657 0 0;18.534925 73.87626 0 0
While the single locations are readily rendered on a map, these lines / polygons aren't. So, I have made a script to convert those values into KML format. One can then save them as a KML file and render them on any mapping software / service.
Here is the live script, and here is the code. Hope it helps.
@JuliusODK this might help.
Hi, can anyone tell me what the last 2 of the 4 values are for in the geotrace / shape string:
18.530663 73.875515 0 0;
I had not noticed the second zero earlier.. assumed it was just one and it represented height above ground as it does in KML. So currently my tool completely ignores the last value and registers the third value as height. I need to know what Ona's specifications are to make my tool accurate.
@Nikhil_VJ - The live script works perfect - You're a genius! Thank you!! However, it only allows for the conversion of one cell i.e one instance of geotrace record at a time. Do you by chance have a version that can grab values from a .csv table (with columns specified) and converts to kml? Or is there a way to batch process this for ~1000 records of geotrace?
Hello @Nikhil_VJ! Looks like just the thing I was looking for, but the strings I get from geotrace using ODK collect are different to your example from Ona, and end up producing some massive triangles around the globe when I run them through the converter.
Example string (2 points from a geotrace):
10.719660522754717 124.79800276052386 75.0725241471082 10.0;10.719660522754717 124.79800276052386 75.0725241471082 10.0;
As far as I can tell the 75.07.... is altitude, and the 10.0 is accuracy. Once it runs through the converter script, I think the 75.07... ends up being considered alternately as a lat or long - which then shifts the actual lat and long to also alternate between lat and long, hence the massive triangles. Would it be possible to edit the code to make it able to process stings like this?
On a side note - the above geopoints provide decimal places pinpointing a fraction of a micrometer of the earth's surface - give or take the 10m GPS reported accuracy! There really is no need for more than 5 decimal places on the lat/long (and I would happily ignore the GPS altitude entirely). Do you know if it is possible to constrain the number of decimals stored by geotrace?
I don't quite see the difference between your string's structure and what my script works with. Its:
latitude longitude height accuracy
..right? Thats what the script reads it as too, and it ignores the last accuracy value.
In the sample string you shared, both locations are identical. So output of that will be a line of no length at all.
Can you either share a whole geotrace, or at your end can you manually test each point? Go on openstreetmap.org or maps.google.com and enter the values in search like so:
On google maps you can keep starring your points so they'll all show up at the end. Check one full geotrace and verify that the data is proper.
I just discovered that if I upload the generated KML file into Google Maps - it works perfectly, so yes, actually the app works fine thanks However, when i open the KML in Google Earth on my computer - it doesn't show me the path. Strange.
The 2 geopoints I sent in the last one were from geotrace "auto" collect at 1 second intervals, so I guess or data collector was standing still for a moment!
Actually, the problem was one of the traces - someone started recording before having location locked, and so the trace started somewhere in West Africa before localizing in the Philippines...
Ah! It was precisely this reason why i built the tool.. To spot faulty recordings quickly
Because I know absolutely nothing about how this works - would there be any way to automate your script such that a trace "live" published via aggregate to a cell in Google Sheets is automatically processed, generates and saves a KML file, and includes a link to that file in a new column (or a new google sheet with UUID of source data in column A, link to KML in column B)?
I am trying to find the most end-user friendly way for using and presenting geotrace data. If we can avoid the step of someone having to manually generate each KML file that would be wonderful!
@philjones a macro/script in google spreadsheets could be created to do it. I'm not well-versed with that bit of tech yet.
Update : fixed some problems in the live script , mostly to handle unclean data properly. Should work better now.
Fence is great, I've tried it with your data and the line is perfect, but when using my odk collect data it does not show me anything, then an example.
12.52942603 -87.04165634 0.0 0.0; 12.52947502 -87.04171918 0.0 0.0
Another thing, how could you calculate the distance of those 2 points, even if it is not visual, only the value in meters.
Thanks in advance, greetings.
Hi @famador, answering your second question first: A "haversine distance formula" is the de-facto one used to calculate distances. There's quite some theory about it given on this page: https://www.movable-type.co.uk/scripts/latlong.html
Searching the net for "lat long distance calculator" throws up many results - online tools where you can paste in your values and find the distance.
Coming back to the first query : I was able to properly make a KML of the sample data you provide, using the same script. (it's just two locations so just makes a line) Their location is somewhere in the middle of the ocean.
FYI you might be interested in this thread with an in-form solution for converting a 'fence' (geoshape or geotrace) to KML.
how could you calculate the distance of those 2 points
If you have two geopoints, eg in a geotrace, you can use the build-in ODK function distance() to get their distance. These dont actually have to come from a geotrace question per se; eg if you have two separate geopoint questions you can still do it; see this thread for description.
Hi. I have this string of coordinates: -23.393592692 -57.319247895 146.24861145 3.1661; -23.39289479 -57.31873217 152.062393188 4.7; -23.393306373 -57.317805633 147.981460571 4.791231; -23.393979817 -57.318308804 141.856079102 4.7; -23.394075003 -57.318732476 133.329360962 4.7; -23.39358052 -57.319298762 151.696716309 4.9; -23.393592692 -57.319247895 146.24861145 3.1661
The script does not recognize the minus sign (-), how can this be solved?
Hi @Marcelo_Raul_SCARONE, thanks for pointing out this bug. I had been zapping minus signs too at the data-cleaning stage. I've corrected my script - please give it a spin again.
Your sample data is a field in Paraguay if my script is getting it right.
Hi. Now it works well. Yes, those coordinates correspond to Paraguay. Sorry for my bad English.
Question: This script allows to make several polygons? That is, I have several coordinate chains, of different polygons, I can only convert them one by one?