Jump to content

Software to extract coordinates from text?


Parsa

Recommended Posts

I used to have a software program for Mac OS that would extract all the GPS or coordinate data from a text file and create a file with every set of coordinates on a line. I don't recall if it was comma or tab delimited, but either would be fine. I don't remember what app I was using. Does anyone know an application that will do this for me?

Link to comment

Let's say I had a document with entries like the following excerpt:

 

ARIZONA

 

Navajo National Monument (Kayenta) — 36.678227, -110.541034

Keet Seel (Kitsʼiil, Kiet Siel) — 36.760762, -110.496314

Betatakin (Bitátʼahkin) — 36.683988, -110.536184

Inscription House (Tsʼah Biiʼ Kin) — 36.670274, -110.819878

 

Canyon de Chelly National Monument (Chinle) — 36.153166, -109.539019

First Ruin — 36.144105, -109.501805

Junction Ruin — 36.145726, -109.489133

Ruin — 36.137805, -109.485667

White House Ruin — 36.133747, -109.470477

 

How would I enter this into GPSBabel? What format would I chose? Or would I have to do a lot of editing to make it comma delimited?

Link to comment

I believe the Mac comes with the awk utility (if not then you can probably install it from somewhere), and if so I think this should do it for you from a command line, although I've never used a Mac so I'm making some assumptions, but it's worth a try:

 

Assuming your list above is in a.txt, and you want to create a.csv which gpsbabel will accept

awk -F\— '{printf "%s , %s \n",$2,$1}' a.txt > a.csv

What this is doing is reading a.txt and splitting it at the — character, and printing the part on the right (the co-ord pair) first followed by a comma and then the part to the left (the name), to create a comma separated file in the format that gpsbabel likes. Note this won't work properly if the waypoint name has a — in it.

 

Now use gpsbabel to convert a.csv into a.gpx to go on the GPS

gpsbabel -i csv -f a.csv -o gpx -F a.gpx

 

Note if the name of the waypoint has a comma in it then it will produce an incompatible .csv file as there will be too many commas.

 

Catering for cases where the waypoint name has either a comma or a — in it would turn this into a "proper" program, rather than a 2 line solution so it would probably be simpler to tidy up the input file first to remove them if they exist [:)]

Link to comment

I believe the Mac comes with the awk utility ... <snip>

 

Marty, that's interesting. I suppose I could do that in command line app Terminal.

 

I think you could, in fact you could reduce the whole thing to a single line:

 

awk -F\— '{printf "%s , %s \n",$2,$1}' a.txt | gpsbabel -i csv -f- -o gpx -F a.gpx

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...