Thursday, July 09, 2009

Upgrading to Firefox 3.5 issues

Having recently upgraded to Firefox 3.5 from 3.1b3, I stumbled onto a few issues. In the 2 profiles we use, both showed a empty (blank) Options dialog box with only Ok & Cancel buttons. Also tabs behave strangely and won't close + web pages seemed strange, most had scrollbars on the left hand side.

Solution:

Tried a few different things, but deleting the localstore.rdf file from the profile directory (see How to find your profile) fixed everything. A bit like the Firefox Support article Toolbar keeps resetting and it's solution, Method 2: Delete localstore.rdf manually

Happy now :-)

Actual Solution:

Whoops, turns out my localstore.rdf solution was wrong :-(
It was because I forced SwitchProxy v1.4.1 (homepage & Mozilla Addons page) to be compatible with Firefox 3.5 when it is only claimed to be up to 3.0. Turns out it really was incompatible, who would of thought??

Labels: ,

Sunday, January 18, 2009

Fixing wrong date/times within a photo and setting the correct file time

I keep forgetting to correct the camera's time when changing back & forth from daylight savings. So a stack of my photo's are 1 hour behind. This is how I did it and present some of my research findings

Goals

My goal is to keep the photo byte-for-byte the same, except changing the embedded dates. This means I can easily verify that the process hasn't changed anything else (by doing a byte comparison). It also means backups are easier because a tiny binary change is required for each photo, not needing to do a full copy. Versioning systems that handle binary data like SVN, Git & Mercurial will find these changes very compact (making everyone happy :-).

  1. Modify all the embedded date/times so they are moved forward 1 hour.
  2. Change the file time of the photo to match the embedded Date Taken.
Programs used
  • Exifier v2.1.5 (build 263) Graphical image manage & metadata editor. No updates since 2002!!
  • Exiv2 v0.18 Console app, easy to use (nice syntax/manual)
  • ExifTool v7.62 Console app, Perl based but compiled for Windows. Has a million options, but hard to find all the right options (a bit of a rabbits warren).

Fixing the EXIF date/time within a photo

Most photo's taken with a digital camera will have 3 date/time's in them.

  • Date Taken
  • Date Digitised
  • Date Modified

Date Taken is the most important one, as that is what Windows Explorer and most Photo editors/viewers use. Usually they are all the same, unless the photo has been edited in some way.

Therefore, I'm trying to change all the embedded date/times by 1hour, relative to their original time. All these programs let you specify the relative time to alter.

This comes in handy if you notice that the camera is the wrong time, but not just a simple Daylight Savings difference of 1 hour.
Before you change the camera's time to the correct time, take a photo of a clock with the correct time. Ideally a GPS (which has to always have the correct time & sync's it with satellites) or something that shows seconds and has an accurate time. Then on the computer, look at the photo's time & the clock's time to work out the relative difference. You can then use this when fixing the time of photos.

ProgramversionByte for byte?Time (min)
Exifer2.1.5Yes2:121 (1:532)
Exiv20.18Yes3:27.31
0.17Yes4:05.25
ExifTool7.62No33:52.22
7.25No33:34.58

Notes:
1. Wall clock time
2. Exifer preloads all the EXIF data when selecting a folder, which means a lot of the Images are in the OS filesystem cache (cheating, kind of :-).
3. Looks like there are sections of the EXIF header removed, as well as random bytes have changed (looks like it might still have the same information). But it makes it very hard to verify proper changes, and stuff's up byte diffs for backup/version control.

You can see that the Exiv2 guys have been working hard on performance, making some serious improvements between v0.17 & v0.18.

Setting the photo's file time to match the EXIF date/time

Since we have changed the embedded date/time, the date/time of the file will not match, and it makes it much more convenient if the photo's file time is correct.

Programversion Time (seconds)
Exifer2.1.54 531 (22)
Exiv20.18 7.02
0.17.1 13.81
ExifTool7.62 14.64
7.25 15.16

Notes: 4. For some reason, Exifer creates a hidden "descript.ion" file that is empty in the folder. Can't find an option to turn that off, and there aren't many programs that use descript.ion anymore (used to be used in DOS days to enter a description for files within a directory, since images didn't always support some kind of embedded metadata).

Warning: NTFS formatted drives will show a different time when you change into Daylight Savings time, as NTFS saves file times in UTC (GMT) which is universal time and has not timezone offset. When your region moves into Daylight Savings time, your timezone offset from UTC changes, therefore Windows displays a different time. FAT32 stores only the local time, so it doesn't change with Daylight Savings changes. Camera memory cards (SD, Memory Stick, Compact Flash etc.) are Fat16 or Fat32 formatted, and some external backup drives are also FAT32 formatted. Assuming the file time has been set to the Date Taken time, these will always match.

Recommendations

  1. For normal usage, use Exifer to altering EXIF date/times & make file times match.
    If wanting to automate (using batch files etc.), use Exiv2.
  2. Keep all your photo's & any backups on the same formatted drive. I have everything on FAT32 formatted drives, but if you are going to be on NTFS for one, use NTFS for all (not typical with camera memory cards & USB falsh drives).

Test Specifications

  • Acer Travelmate 3220 Notebook
  • Windows XP SP3
  • Intel Pentium M 2.26Ghz
  • 2.26Ghz 1Gb
  • Toshiba MK8025GAS HDD
    • 2.5" 80GB
    • 4,200rpm
    • 8MB Buffer
    • ATA-6 Interface
    • 12ms Average Seek Time
    • NTFS formatted
  • Photo's taken with a Panasonic Lumix TZ-11 8Mpixel camera
    • All contained within a single folder
    • 251 photo's
    • Total size of 769MB (806,767,153 bytes)
    • Average size of 3.07MB (3,214,212 bytes)
  • All devices deactivated where possible
    • Wireless LAN turned off
    • Bluetooth turned off
    • CardBus turned off
    • LAN turned off
    • Firewire (IEEE1394) turned off
    • Extrenal drives disconnected
  • All programs shutdown where possible
    • Anti-virus turned off
    • Programs in system tray terminated
    • Explorer windows closed Had to retest when realised I had explorer opened on test directory, meaning Windows was updating the view during the test
  • Between test, Operating System File cache cleared by copying very large files (is there a better way/utility to do this for you?

Test commands

Exifer
Fix wrong time
  • Select images as needed (can show sub-folders as well)
  • "Edit EXIF/IPTC data" (Ctrl+E)
  • Select "EXIF data" tab
  • Select "Date" sub-tab
  • Tick [x] Apply to Date modified and Date digitized
  • Adjust "Date/Time offset" settings as needed
Set file date/time to match EXIF date
  • Select images as needed (can show sub-folders as well)
  • "Rename/redate images" (Ctrl+N)
  • Untick [ ] Rename
  • Tick [x] Redate (by EXIF date fields)

Note: Sets Fat32 2sec accuracy time on NTFS

Exiv2

Note: For testing Exiv2 & ExifTool, I wrapped the console commands in echo %time% to find out the elapsed time to run (I'm sure there's a nice chuck of DOS batch code that even does the duration time calculation for you).

Fix wrong time

exiv2.exe ad -a 1 -k *.jpg
Note:

  • ad -a 1 adds 1 hour to all 3 EXIF times (can use 1:03; -0:34.57 etc.)
  • -k keeps current file time
Set file date/time to match EXIF date

exiv2.exe mv -T *.jpg
Note: Sets 1sec accuracy time on NTFS
Manual talks about having to set TZ enviroment variable, but seems to work fine without...

ExifTool
Fix wrong time

exiftool.exe -overwrite_original -P -AllDates+=1 ./*.jpg
Note:

  • -AllDates+=1 adds 1 hour to all 3 EXIF times
  • -P keeps current file time
  • -overwrite_original doesn't create a backup copy of the image
Set file date/time to match EXIF date

exiftool "-DateTimeOriginal>FileModifyDate" ./*.jpg
Note: Sets 1sec accuracy time on NTFS

Please suggest any other programs or configurations to try...

Labels: ,

Monday, October 13, 2008

First update on mapping OpenStreetMap (long overdue)

Australia » Victoria » Melbourne
I signed up for OpenStreetMap about a year ago, and there were plenty of warnings that it's very addictive, but little did I know!!!
I do mapping in spits & spurts (like a lot of other people I'd imagine).

Progress

Turns out I have done a fair bit since I signed up:
Melbourne contributors
Looks like I'm the biggest contributor in greater Melbourne, scary stuff.

I've traced streets, added a lot of names and added some POI's like parks, foot/bike paths, pubs, schools etc.

Rough order of Suburbs I've done:

  • Essendon
  • Moonee Ponds
  • Aberfeldie
  • Strathmore
  • Ascot Vale
  • Flemington
  • Travancore
  • Kensington
  • West Melbourne (industrial area)
  • Strathmore Heights
  • Gowanbrae
  • Airport West
  • Keilor East
  • Avondale Heights
  • Maribyrnong
  • Maidstone
  • West Footscray
  • Footscray
  • Braybrook
  • North Sunshine
  • Sunshine
  • Keilor Park
  • Tullamarine

Since I don't have a GPS, I trace from Yahoo! imagery and fill in as many details as possible.

My usual steps:

  1. Trace streets, parks, foot/bike paths from Yahoo! imagery
    • Add as many tags as is obvious, leave alone if in doubt
      • eg. highway=residential, source=yahoo
  2. Ride along "main" roads to pick up all the side street names, scribbling on my Palm T3 Notepad application (exports to PNG)
    • Tag as name=blah, source:name=survey
    • Later on use Maplint or NoName layers to spot missing street names
      • Plan another ride that swings past all remaining streets
  3. Walk or ride down *every* street, after printing off a Mapnik layer map of the area
    • Note down:
      • All street names/references/lanes/bike lanes/speed limits
      • Schools, park, shopping centre names and shapes (to refine the rough tracing from Yahoo!
    • This takes a long time, and I've only done a little bit so far, but it does make the area almost 100% complete

Wishlist

  1. Either Yahoo! updates their Melbourne satellite photo's (~5 years old) and provide higher zoom levels (currently level 16) or Google provides their photo's to OSM
  2. Potlatch is my editor of choice, and it has improved a lot since I started using it
    • Zoom further in by scaling the Yahoo! tiles when hitting the highest zoom Y! provides
      • Potlatch used to do this, which made it much faster to trace, but a Flash bug that occurs when the auto-maximise feature was added means this had to be turned off :(
    • More tag "autocomplete" entries (especially source:name=survey/photo etc.)
    • When crossing a way with another (either as a T-intersection or cross), I think the snapping feature of Potlatch means the created node is not where the two ways mathematically cross, but the nearest snapped point
      • So the angles of ways change a bit, needing zooming in to fine tune
        • But snapping is very obvious at z18, which becomes dodgy when ways are close to (but not) orthogonal
      • I usually layout a grid of streets with a little overlap, then come through and join all crossing ways, crop T-intersections overhang and fine tune
  3. Get a GPS and:
    • Circumnavigate local parks etc. which are hard to see the boundry from Yahoo! imagery because of trees
    • Enter POI points like postboxes, speedhumps, changes of speedlimits
    • Take photos as I go of all the street signs, amenity names etc. which, with a GPS, can be geotagged (and upgrade name's to name:source=photo)

Ownership

I've noticed that there is a fair amount of pride/possessiveness around the contribution that OSM users have made, and I'm no different.

I get annoyed when other users come through and add inappropriate tags (not what was on the ground, "for the renderer", not "best-practise" etc.), move carefully smoothed ways around/offset. I guess the "pride" of one's contribution is a double edged sword.

Good tools for letting me know when someone has editing "my areas" would be fantastic, and I've just signed up for Itoworld's osmmapper (RSS feeds of changes to specific areas). But I think it's hard to communicate what has changed, how do you convey changes in a concise/meaningful way?

  • eg. Mary St is now oneway & nodes moved; Frank Rd deleted; Railway Hotel pub added+tagged opening hours; etc.

Crossposted at OSM diary

Labels: ,

Friday, July 11, 2008

Palm T3 Documents To Go problem

I sync my Palm T3 on 2 computers, which sometimes cause problems after I've had a hard reset (a complete data wipe). This time it was because it ran out of battery juice (I suspect - a button was held pressed when packed in a bag).

I mostly fixed all the issues (after having to manually hard reset again after not entering the correct time/date - stuffs up the forced sync for some reason), but Documents To Go (v6.008) sometimes gets confused about syncing existing documents.

The error message I see is:

Another file exists with the same name as this one...

But there is no documents with the same name!!!
DataViz support had nothing in their Knowledge Base. I have seen this with both "Sheets to Go" and "Microsoft Excel" formats.

I tried everything to fix this, but was left with the poor option of just changing the name of the document to something unique. But today I found a solution

Using either Filez or Resco Explorer, I deleted all of the Documents To Go Palm databases. I think that DocsToGoDB.DATA is the one that solved the problem, hard to tell. It did cause all the categories and their assignments to disappear, but easy for me to add again. So I deleted:

  • DocsToGoDB.DATA
  • DxtgTempDB.TDAT
  • (in Resco Explorer) all Documents [DTGP,xx].pref "files"

I was then magically able to see the "existing" files of the same name, delete them, rename each document to their "proper" name, assign a category and sync properly!!

Labels:

Wednesday, June 18, 2008

Firefox 3.0 released, download now!!

The Mozilla corporation/community have released Firefox 3.0 today, with many improvements (both UI wise and backend changes).

Similar to Firefox 2.0 & 1.5, this release has had some serious amount of QA pounding on it, I would say it is their most planned & executed release management to date.

The things that interest me for this release include:

  • Awesome bar (smart location bar)
  • one-click bookmarking
  • Tagging history/bookmarks
  • Better password manager (not getting in your face)
  • New EV certificates (better identification of secure sites)
  • Add-ons Manager with inbuilt Addons listing
  • Download Manager improvements (mainly resumable across sessions, more robust backend)
  • Full Zoom (images & text zoom together)
  • Improved Memory Management (cycle collector, reduced leaks, jemalloc allocator to use less memory)
  • Faster JavaScript
  • Faster Page Load
  • Advanced Graphics (reflow rewrite, better SVG/Canvas support, better graphics backend (Cairo))
  • Future Weave sync'ing

I only started using 3.0 with the release candidates (RC1), because of the "addons not yet updated" problem. But I found updates for my day-today addons during RC1, so upgraded.

Finally Firefox 3.0 has places support, which I think will make a real difference to users web browsing experience (mainly through the "Awesome bar"). Here's my anticipation from earlier:

When Firefox 1.5 came out, I was already excited about 2.0, what with Places & the SQLite backends, but that didn't really pan out, should be in Firefox 3.0 though...

Firefox 1.5 released today
... Already waiting for Firefox 2.0 (from the 1.8.1 Gecko branch) with its "Places" support (redoing bookmarks, history, feeds etc. into a new user interface and storing in a super fast SQLite DB).

Firefox 3.0 will come off the 1.9 branch, with it's massive Gecko improvements (rewrite rendering using Cairo on all platforms, reflow rewritten, complete SVG support??) and the aforementioned Places with tagging system for bookmarks/history etc.

Get Firefox!Download Firefox 3.0 now.
Hopefully download before 3am, 19th June AEST to create a new Guinness world record for the most downloads of a software program in a day!!

Labels: ,

Friday, September 28, 2007

Be careful of wet newspaper!

Riding into work today, I got about half way in before noticing that my rear shifting wasn't working very well. Looking down, it looked like a rag had got caught in the jockey wheels/cassette.

So I stopped on the Moonee Ponds Creek bridge and had a look. It turned out to be a single sheet of damp newspaper, all caught up and mashed around the jockey wheels & cassette & under the chain.

Cleaning it out was difficult because it was caught up under the chain, and that it disintegrated when picking it out. Took about 5 minutes to get it out but then I noticed that the cassette, the paper had somehow loosened the locknut on the cassette and the cassette & the separate sprockets were very loose. Tried finger tightening the locknut, but that only worked a little bit, it was still loose.

Seems that the paper must of compressed on each rotation, in the gap between the locknut & chainstays. And since the chainstays are "going backwards" in relation to the clockwise drive of the cassette when pedalling, it unscrewed the locknut!! Who would of guessed, I'm going to make it nice & tight when I get back home to my cassette locknut spanner.

PS. I've heard some horror stories of plastic shopping bags wrecking the rear derailleur, so I got away pretty cheaply, especially since I just replaced my Shimano Deore 2001 rear derailleur with a SRAM X.9 2007 one.

Labels:

Firefox Mouse Gestures (Optimoz extension): Snapback gesture

It seems the Optimoz gesture exchange page is down. But the project page on Mozdev seems to be up!!

matt added a comment (well 3) to the Firefox Extensions I use (2007-08-09) post, asking for it since the page is down and googling didn't find anything, so here it is:

  1. In Firefox, goto Add-ons -> Mouse Gestures -> Options -> "Edit Gestures" button (at the bottom of the General tab, and click New.
  2. In the Gesture code textfield, enter: LR
  3. For Function Type, select: Custom
  4. In Gesture Name textfield, enter: Go to first page
  5. In Custom JavaScript code textarea, enter: if (gBrowser.sessionHistory.index > 0) gBrowser.gotoIndex(0);

Now, you only have to hold down the Right mouse key, and flick the mouse to the Left and then back to the Right!!

Thursday, September 13, 2007

Bikely.com - Cleaner (Stylish site style)

Bikely.com - Cleaner site-style at userstyles.org

I been using the www.bikely.com site for a while now to plot my bike routes or to plan them. I've created some Stylish (a Firefox extension) site-styles to modify the page to remove some of it's clutter. I finally got around to publishing it, mainly because of the functionality lose (favourites adder missing in the header) that users in the forum's have been complaining about. Seems Bikely hasn't been actively developed for a while now, hopefully Jules or someone from BikeRadar continues to develop Bikely soon. Here is my created "site specific stylesheets" site-style:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix("http://www.bikely.com/maps/") {

/* Get rid of Flash object and make the title info wrap */
#headerline > OBJECT { display: none !important; }
#lblRoutetitle > BR { display: none !important; }
#lblRoutetitle { clear: none !important; }

/* Hide Google Ads & Map copyright details */
#mapadcontainer { display: none !important; }
#map > div:first-child + div { display: none !important; }
}

So install the Bikely.com - Cleaner site-style & enjoy!! The userstyles site let's you install it directly into Firefox via Stylish or optionally, as a user-script into Greasemonkey. The user-script also works with Opera.

Thursday, August 09, 2007

Firefox Extensions I use (2007-08-09)

Update from my previous post Firefox Extensions I use (2006-06-21) and Firefox Extensions I use.

Anyway, here is a list of the current Extensions I am using in Firefox 2.0.0.6:

  • Browser tweaks
    • Enhanced History Manager v0.5.8.05.1 (amo homepage)
      Ok, so I'm an old Mozilla App Suite user, and like my advanced History manager to prune my huge history list.
      Update: I'm running a custom EHM version from AnonEmoose that let's you filter by referrer.
    • Favicon Picker 2 v0.3.4.1 (amo)
      This is great for fixing favicon issues in bookmarks, especially for adding custom one's for Bookmarklets on the Personal Toolbar (and can therefore get rid of the text, making more visible).
    • Menu Editor v1.2.3.3 (amo homepage)
      Don't use this that much anymore, but used to aggressively prune the context menu to make it faster to use (by getting rid of stuff I don't use).
      Maybe should again, extensions add a lot of crap to the context menu :-(.
    • Google Toolbar for Firefox v3.0.20070525W (homepage)
      I don't use the toolbar (I have it hidden), other than use the pagerank feature. This means almost all pages I visit get checked for Pagerank at Google, and it saves all of that history to my Google History page. This means I have a full text search of (almost) all my browsing history.
    • Kelvin's Australian English Dictionary v2.2.0 (homepage)
      A strict Australian Dictionary.
  • Downloading
    • Download Statusbar v0.9.5 (amo homepage)
      Very nice, download's popup just above the statusbar (like the find bar), and I changed it so they disappear after 10 seconds. Great for directly opening ZIP, exe and PDF files after downloading them (which download by default now).
    • DownThemAll! v0.9.9.10 (amo homepage)
      Great when downloading lots of the same type of file linked from a page (ZIP downloads, images etc.).
    • Fission v0.8.8 (amo homepage)
      Adds a loading progress bar to the address bar (ala Safari).
    • Linky v2.7.1 (amo homepage)
      Lets you open multiple links in a variety of ways. I use it by selecting links I'm interested and opening them all in tabs.
    • Magpie v3.2.8 (amo old homepage new homepage)
      Great for downloading content/pictures from a series of open tabs. Hopefully DownThemAll! will be able to do this one day.
  • Navigation
    • ChromaTabs v2.0 (amo homepage)
      Changes the colour of a tab based on the pages site icon (can be configured based on other algorithms).
    • Grab and Drag v2.1 (amo homepage)
      Instead of the cursor being used for selecting text (except for links), it makes the mouse pointer act like Acrobat Readers', where you click and drag the page around to scroll. Feels weird using a browser without it.
    • Mouse Gestures v1.5.2 (amo homepage)
      Lets me use gestures, which for me involves shortcuts for going Back and Closing a tab/window (customised to use a down stroke).
      Also added a custom gesture to Go to first page in the tab's history (Snapback??) as L,R
    • SmoothWheel v0.44.9.20061102 (amo homepage)
      Makes scrolling so nice and smooth (includes de-acceleration when getting to the top or bottom, sweet).
    • Tab Preview v0.3 (homepage)
      Great use of the new Canvas feature in Firefox 1.5, it shows a thumbnail of each page when you mouse over non-current tabs. There are a lot of tab preview extensions out there, no idea how this compares.
  • Page Tweaks
    • Aardvark v2.0 (amo homepage)
      Lets you point to sections of a web page and delete, isolate, de-widify etc. Great for pruning a page before printing.
    • Adblock Plus v0.7.5.1 (amo homepage)
      Couldn't live without. While I have maintained my block list of many years, when setting up for other people, I subscribe to the EasyElement+EasyList & ABP Tracking Filter through Adblock Plus's Subscription feature (it's very easy to update them).
      I used to use FiltersetG list (usually via the updater extension), but apparently it isn't tuned for performance.
    • AJAX Yahoo! Mail v0.6 (amo homepage)
      Modifies Y! Mail so that I can open messages inline (meaning I can open many at once and see them all on the one page). It also lets you download attachments with one click and "instant reply" without having to load a new page.
    • Greasemonkey v0.7.20070607.0 (amo homepage)
      Uses JavaScript to modify a pages content. Many JS scripts are available from userscripts.org. Never got into it until I found a few useful scripts at Userscripts that make Y! default to secure login, remebers Y! account names, hides the search section on the Google Personalized page (redudant with FF searchbox) and makes some improvements to All music guide.
      I've also created a few of my own (published scripts).
    • Resizable Form Fields v0.2.4 (amo homepage)
      Means you can (sometimes) resize textareas & form fields.
    • Stylish v0.5.2 (amo homepage)
      Uses CSS to change the style of a page, similair to Greasemonkey. Many styles are available from userstyles.org.
      I used to put customisations in my usercontent.css and userchrome.css files, but with Stylish, I can see the changes instantly and toggle on and off.
      I use it to increase the size of the Firefox search box (used to use the Resize Searchbox extension, should be in FF v2), show a crosshair when over a link that opens a new window. I created a few styles, for removing clutter from Yahoo! mail and yourTV.com.au TV guides (I should submit those to userstyles.org one day.
  • Web Devel
    • Console2 v0.3.7 (amo homepage)
      Replaces the inbuilt JavaScript Console with the "Error Console", makes the console very useful and adds advanced features.
    • Firebug v1.05 (amo homepage)
      All web development tools in one, it's truly amazing. HTML & CSS inspection/editing, Network traffic analysis, JS profiling & debugging, logging & error console!!!
    • JavaScript Debugger v0.9.87 (amo homepage)
      Great for serious JavaScript development. Need to try Firebug as well.
    • Live HTTP Headers v0.13.1 (amo homepage)
      Works well when debugging what the browser is sending and what the server returns (especially for redirects).
    • View Source Chart v2.5.03 (amo homepage)
      Useful when trying to analyse how a website is structured, when checking out how it works or for customising.
    • Web Developer v1.1.4 (amo homepage)
      Analysis and debugging pages. I use mainly for outlining block elements in HTML, validation and resizing the window for common sizes.

Retired Extensions:

  • Download Manager Tweak v0.7.1 (amo homepage)
    Seems to add nice little tweaks to the Download Manager. Not as useful as Download Statusbar for me.

Old retired list:

  • Adblock - Switched to Adblock Plus mainly coz of the small icon on status bar.
  • Forecastfox - Used to like a lot, but the weather date provider (Accuweather) is usually way off for Melbourne weather, so I use the Bureau of Meteorology's plain text based forecast.
  • Performancing - Post to Blog's: Blogger, TypePad, LiveJournal, WordPress & MoveableType.
  • Google Suggest - adds "Suggest" to the Firefox Google searchbox
  • Hash Coloured Tabs - creates new tabs with colour coding
  • Link Visitor - lets you selectively mark links as visited or unvisited
  • Resize Searchbox - creates a grippy for the Firefox searchbox so it can be resized

Saturday, January 06, 2007

Excel formula to calculate distance between 2 latitude, longitude (lat/lon) points (GPS positions)

I've been looking for this one for ages, and the one I created based on an equation I found a little while ago didn't work too well :(

Investigation

Calculate distance, bearing and more between two Latitude/Longitude points shows lots of equations in math, and implemented in JavaScript. Chris Veness's page also contains an Excel formula of the ‘Haversine’ equation (actually, using the "spherical law of cosines") for distances between points in kilometres:

=ACOS(SIN(Lat1)*SIN(Lat2) +COS(Lat1)*COS(Lat2)*COS(Lon2-Lon1)) *6371

But it wasn't working, because my GPS points (Lat/Lon) were in decimal degrees, not radians. So I used the formula I found at Latitude And Longitude In Excel (under the "Great Circle Distances" section) by Chip Pearson:

=RadiusEarth*ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2)))

where Chip gives RadiusEarth as 6378.135 kilometres. This didn't match up with distances I had when calculated from other systems. But Chris's page has:

R = earth’s radius (mean radius = 6,371km)

Digging deeper, I found Chris's Vincenty formula for distance between two Latitude/Longitude points page which includes a table on different datum models (treating Earth as an ellipsoid), it shows WGS-84 & GRS-80 having the greatest radius on an ellipsoid as 6378.135km & the smallest as 6356.752km.

So Chip was using the maximum radius of the Earth, not the mean radius like Chris (I'm not sure where Chris gets the mean radius from). Substituting Chris's R for RadiusEarth in Chip's formula gives:

Solution

=ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *6371

and my final version that uses Excel cell references is:

=ACOS(COS(RADIANS(90-A2)) *COS(RADIANS(90-A3)) +SIN(RADIANS(90-A2)) *SIN(RADIANS(90-A3)) *COS(RADIANS(B2-B3))) *6371

PS. To calculate distances in miles, substitute R (6371) with 3958.756 (and for nautical miles, use 3440.065).