Wednesday, August 13, 2014

Wednesday Search Challenge (8/13/14): Where can you find this in the street?

This weeks' challenge is from Regular Reader Bob Darkblue who writes: 


1.  Can you find the GPS coordinates of the manhole cover shown below?  And why does it have that odd shape?  (Neither triangular nor circular...)  


Let's make this a reasonable quest:  you don't have to find exactly this instance of a manhole cover, but just the coordinates of any manhole cover that has this particular shape.  


It reminds me of that mythical Google question, "Why are manhole covers round?"  I've certainly never used that question in an interview and don't know anyone who has.  (Besides, that's way too easy a question...)  

But I've spent the past week since Bob wrote to me with this Challenge looking around at manhole covers.  I haven't spotted anything quite like this in the streets near me, so we'll have to go looking together.  


I'm not sure if you knew or not, but I'm interested in such things. (See previous blog posts:  anode covers, SFFD cisterns, or sewers in San Francisco)  I rather enjoy the art that we can see in the world around us, even in the most unexpected places.  Here are a few of my favorites, photos I've taken in various places.  Can you figure out where they're from? 








Search on!

Tuesday, August 12, 2014

Handling USGS data for simple visualization

In yesterday's post I mentioned that I'd make a short video showing how I imported and handled the USGS earthquake data in detail.  

So I got up early this morning and put it together.  Here it is: 



But in the process of doing this, I realized that a short outline of the process might be useful.  

Here's what the video shows.... 

1. Using the USGS earthquake search tool to find earthquake data in North America and download to a CSV file.
2. Uploading the CSV into Google Spreadsheets. 
3. Good data practices (setting up the data import as an uneditable sheet, labeling the data with metadata about where it came from and when downloaded). 
4.  Copying the data into new tabs for cleaning / munging / manipulation. 
5.  Extracting the name of the state from the "location" column in the data.  (4:20 to 11:00 on the video)
6.  Extracting the year of the earthquake from the "time" column.  (14:15 to 15:00 on the video)  
7.  Using the spreadsheets "Filter" function to select data by state. 
8.  Counting the number of earthquakes by year by state (using the "countif()" function).  
9.  Pulling the California and Oklahoma data together into a sheet for creating the chart.  (21:00 to 22:00 on the video)  


Most of this is pretty straightforward stuff.  Search for the data, import into a spreadsheet, and then filter/clean/transform the data until you get it into the shape you want.  

If you think about the goal of my data transformation, what I WANT is this a data table like this: 




... where column B is the number of earthquakes of magnitude > 3.0 in California, and column C is for Oklahoma.  

Most of the video is me messing around, trying to pull out the name of the state from the location description (which is in column E).  Most of the entries look like this: 


The place column is what I got from the USGS--it's in the CSV file.  But what I NEED is state(extracted), in order to get my counts of earthquakes by state.  

The hardest part of this entire process is writing the spreadsheet function that can pull the state name out of the place column.  

I ended up using a =regexpextract (...) function.  That's not the simplest, I know, but it's the way my programmer's mind works.  (To learn more about regular expressions, which are probably the handiest tool in the programmer's toolbox, see regular expression tutorial.)  

Just after I made the video, I discovered another way to do the same thing.  This is from my Google colleague Ronald Ho, and it's so clever I have to show it to you.  (Just in case you also need to extract the last term in a string on some future spreadsheet.) 

=iferror (RIGHT(N1879, LEN(N1879)-FIND("*",SUBSTITUTE(N1879," ","*",LEN(N1879) -LEN(SUBSTITUTE(N1879," ",""))))), N1879)

This whacky expression is a clever bit of programming that basically does the following: 

   1.  It find/replaces blanks ("") for every space in the string of N1879, compacting it.

   2.  It computes how many spaces there are in N1879 by subtracting the
       full-length string
LEN(N1879) from the compacted form. 

   3.  It replaces every space by a "*" character. 

   4.  The expression returns the RIGHT part of the string, everything from the last "*" 
        position to the end of the string.  

   5.  The whole expression is wrapped in an iferror so that if the string doesn't have 
        any spaces, the FIND command will cause an error, and then iferror will return 
        just the value of the string in the cell.  

It's complicated, but cute.  And it highlights an important point:  The functions that are built-into your data handling system need to be powerful enough to allow you to do whatever alterations to the data that you need. 

In this case, the Google Spreadsheets scripting language is missing a function to "find from the end" (that is, find the last space in the string).   (IF there was a FINDBACKWARD function, I would have written  = right(N1879, findbackward(N1879, " ")) which would have given me the last word in the sentence.  

Ah well.  Every language is missing something, that's why programming is sometimes a bit tricky.  

Hope you find this video useful!  

Comments (especially about how to improve this) welcome. 

Search on! 


Monday, August 11, 2014

Answer: Earthquake data?

I asked a fairly simple question--or at least a question that seems simple when stated like this:  

1.  Can you find data about when and where earthquakes happen and then chart it so we can see location and number over time?  Ideally, you would create (or find) a chart showing number of earthquakes by US state over the past 10 years.  Even better, if that chart could show month-by-month, then we should be able to spot both any seasonality effects AND resolve the question about Oklahoma.  

As several Regular Readers pointed out, the obvious source of earthquake data is the USGS (United States Geological Survey).  But if you don't know that ahead of time, how do you find out? 

The discovery query: 
   
     [ earthquake data ] 

shows us that 8 out of the top 10 results are all links to various web pages in USGS.GOV.  A little drilling into those links shows that the USGS really IS a great source of earthquake data.  (And reading around a little bit reveals that they collect data worldwide; not just for the US or just the Americas.)  

It doesn't take long to figure out that USGS provides a very nice earthquake database that you can pull data from with a single query. 

  http://earthquake.usgs.gov/earthquakes/search/ is the go-to source for this stuff.  

http://earthquake.usgs.gov/earthquakes/search/

I set the date start / end range to 2004-08-01 and 2014-08-01, and the magnitude to be 3, and the geographic region to be West = -128, North = 49, East = -62, South = 20  (that's roughly from the coast off Vancouver to the ocean just east and a bit south of Cuba).  

I asked for the result to be delivered as a CSV file, that way I knew I could then pull it into Google Sheets and do whatever I wanted with it.   (To do that, just click on the radio button that says "CSV" in the upper right.) 

The USGS then runs the query against their backend (which is NOT indexed by Google), and downloads a 1.2Mb file onto your computer.  

I opened up that CSV file in Google Sheets and see something like this:   



Each earthquake is one row of data, time & date in column 1, lat/long in columns 2 and 3, etc.  

Conveniently, in column N there's a place name that looks like this: 

20km ESE of Anza, California

it's just a city, or a location (20 km ESE of...) AND a state designation. (Or, if you look through the data, you'll see lots of "Mexico" in there as well, along with the closest city names.)

For SearchResearchers, a great practice to follow is to ALWAYS provide the metadata with the Sheet. My common practice is to write a comment and insert it on cell A1 (upper left). That tells me when, where, and how I downloaded the original data.


My metadata comment in the Sheet. ALWAYS do this with your data,
even if you think you won't come back to it.  Maybe ESPECIALLY if you
don't think you'll come back--that's when you'll need it the most. 


Then, as you clean, filter, and munge the data, you NEVER work on the original data. Always make a copy.


As you can see, I made several tabs across the bottom.  ("cleaned up data" "NV" "OK" "CA" "Summary")  



If you look at the "cleaned up data," it's just a copy of the original data (all 7,386 rows) with a couple of extra columns.  The most important for us is that I wrote a little function that would pull the name of the state out of Column N.  (Remember, the name of the state is the text following the last comma--that was the magic spreadsheet function I wrote--check out Column F in the "cleaned up data" for the state names).  

NOW I'm ready to do my state-by-state comparison.  

I decided to look at just the top 3 states with the most earthquakes over the past 10 years.  That's California (CA), Nevada (NV), and Oklahoma (OK).  

I filtered the "cleaned up data" by California (click "Filter," then click on the little triangle at the top of the column to select the values, e.g., "California," that you want to filter-by).  

I copied the entire spreadsheet (now filtered to show only California earthquakes) into a new tab (the "CA" tab) using "Paste Special>Values" which then gives me a sheet of just the California earthquakes.  

Repeat that process for the Nevada quakes and the Oklahoma quakes. 

Now I'm set to pull the data for each of the states by year.  So I made a little table, one row / year, and wrote a function to count the number of earthquakes in each table by year.  


That countif(C2:C4000, "2014") function just counts all of the cells in the C column (which is the year of the earthquake). 

I did that in each of the three states sheets, and then copied all of the state's data into the Summary sheet. 



This answers our original question ("Is Oklahoma having more earthquakes?") with an emphatic YES!  In the early 2000's, Oklahoma had only a tiny number of quakes > 3.0 (onesies and twosies).  Starting in 2009, the number went way up (by a factor of 10X), and has been climbing ever since.  Oklahoma now has more earthquakes / year than California (which was the previous leader).  

And note that the chart only goes to August 1 for 2014: the year's not over yet, so expect both CA and OK numbers to grow.  

As you look at the chart, another question leaps out:  What happened in California during 2010?   Short answer:  I don't know.  Another Search Challenge? 

But the consensus seems to be that fracking in Oklahoma seems to be causally connected to the earthquakes that the region is experiencing.  By doing a search in Scholar for [Oklahoma earthquakes] I found a pretty compelling article in the journal Science, "Sharp increase in central Oklahoma seismicity since 2008 induced by massive wastewater injection" that makes the case that the two are connected.  (Of course, we can't infer that just from correlation, but the Science article goes into great detail about what the causal connection seems to be.)  

Just to double-check, I also poured this same data into Google Fusion Tables.  Why?  I know they have a handy "heat map" display that shows the number of earthquakes as a colored overlay on the map.  (My Fusion Table heatmap for US Earthquakes 2013-2014.)  


(Note that "only" the first 1,000 earthquakes are shown here. Those are the earthquakes for 2013 and 2014, up to August 1 of 2014.)  

As is evident, Oklahoma is feeling more than its "fair share" of quakes.  


Search lessons:  Often, searching out the answer is something that can't be done just by looking up a single number or article.  Sometimes you actually have to find the original data and then wrestle IT to the ground by doing some manipulations.  

In this case, I used spreadsheets to transform the data from a purely CSV format into something I could easily use, both as a line graph and as a heatmap.  

And, of course, always track your metadata.  (I say this through harsh personal experience.  I can't tell you how many data sets I've lost because I couldn't figure out how they'd been derived.  Don't let this happen to you!) 


Special Offer:  I'll make a short video showing HOW I did it.  (If enough people write in with comments asking for more details on "how did you do that spreadsheet trick with the USGS data?")  

Search on! 


Friday, August 8, 2014

Running late today... Answer on Monday


Gentle Readers, 

It happens to all of us eventually.  The laptop finally gets too crufty, too overloaded, too full... and it needs a total wipe and reinstall.  

Unfortunately, that day is today.  Not by choice, mind you, but an accident of timing. 

I'll finish writing up the answer when I have my computer back from the techstop guys.  (They're good, but they can't move a terabyte off the old computer and onto the new computer THAT quickly...)  

I'll post the answer on Monday, August 11th.  

Trust me, it's worth the wait. 

Until next week, take a break and enjoy the weekend!  


Dan 


Wednesday, August 6, 2014

Wednesday Search Challenge (8/6/14): Earthquake data?

The San Andreas Fault is the diagonal line running from Bodega Bay (upper left), through
Tomales Bay (in the middle) and down to Bolinas (lower right).
And then it continues on down to pass just a few miles west
of my house in Palo Alto.

THERE'S been a lot of discussion recently about the (apparently) growing number of earthquakes in Oklahoma.  There's suspicion about deep waste wells, or maybe it's the fracking, or maybe it's just that time of year.  

In California, you'll often hear people talking about "earthquake weather."  I don't think it's a real thing, but just something people say.  The last big earthquake I lived through was in October of 1989.  It was classic "earthquake weather," hot and dry.  

Since there's this really big fault zone near my house, I consider these kinds of questions from time to time. 

So this got me to thinking about earthquakes and whether or not there actually IS any kind of seasonality to them.  And, by the way, is Oklahoma (or any particular region) actually having more earthquakes now than just a few years ago?  So this is today's Search Challenge... 

1.  Can you find data about when and where earthquakes happen and then chart it so we can see location and number over time?  Ideally, you would create (or find) a chart showing number of earthquakes by US state over the past 10 years.  Even better, if that chart could show month-by-month, then we should be able to spot both any seasonality effects AND resolve the question about Oklahoma.  

Note that I have not yet created this chart, so I don't know how easy it will be.  (But I'll start working on it today.)  


NEWS FLASH:  Regular readers of SearchResearch probably recall the Challenge we had in April about  Comet 67P/Churyumov-Gerasimenko and the Rosetta Lander.  You might be interested to know the satellite just went into near-comet orbit successfully.  (See the New York Times article on the rendezvous, which includes some fantastic video of the comet.)  The Philae probe will be launched sometime in November.  Stay tuned! 


Twitter pic posted by ESA for the Rosetta team.  Closeup of 67P/Churyumov-Gerasimenko. 


Friday, August 1, 2014

Answer: Three Classic Mistakes



This week I asked for a little help in diagnosing what went wrong in each of the following little search hassles I had.  What happened in each of the following cases?  Imagine you're trying to remote tech-support.  What would you suggest as the key failure?  Let's do them one at a time.   
1.  My missing friend's article.  I have a friend by the name of Sean Carlson.  A former Googler, he now writes beautifully about Ireland and the experiences of an Irish transplant to America.  One day last year he mentioned to me that he had an article published in the New York papers about being Irish and an immigrant.  "That's fantastic!" I thought.  About a month later I remembered that I wanted to read it, so I started checking the New York Times for his article.  I did the obvious search:    [site:NYTimes.com  Sean Carlson]  But much to my surprise, I couldn't find his article.  I eventually found it by modifying my query, but what did I do wrong here? 

Ah clear case of "overly-specific-itis!"  

Note that I remembered that Sean had his story "...published in the New York papers..."  But my search for it was site: limited to just the New York Times.   I made a big leap of inference when I added in the site:NYTimes.com -- I should have just gone with the much simpler [Ireland Sean Carlson New York] and relied on Google to find me a recent article by "Sean Carlson, about Ireland, in some paper published in the New York.  (The article I was looking for, "An Irish Journey, Shared by All" is a lovely read.  If you have any interest in the experiences of immigrants--and face it, we were all immigrants at some point--I recommend it.)  

Search Lesson:  It's possible to OVERUSE clever search techniques and miss your search by being too specific.  When you're not sure of the site (or the filetype, or the exact phrase used), if the first search doesn't reveal what you seek, consider taking the magic operators OUT of your search.  I assumed it was the NYTimes, when in fact, it was the Daily News, a different newspaper in New York.


2.  Another friend's missing G+ post.  I have another friend named Jaime Teevan (a nice, uncommon name for searching!).  Most remarkably, this past week she and her 10-year-old son walked 100 miles from their home to a "local" amusement park.  I knew that she'd just put a post onto G+.  So I went to G+ and did a Control-F to find her name (and hence the post).  But there were no hits!  What?  Later, I went back and did the same thing, and FOUND her post.  What happened?  Why could I not find it the first time, but I could find it the second time?   (I checked--she had posted it to G+ several hours earlier, so it really was there, but Control-F couldn't find it.  And no, I didn't misspell her name.)  
Here's my G+ page as it looked when I wanted to find Jaime's post. 



When I did my Control-F in my G+ window, it looked like this: 



What?  I knew that she'd just had a posting... I'd seen it just a day or two ago.  

It took me a while to figure this one out, although I should have known better... 

Like many "streaming" services (for instance, your Twitter stream, your News stream, your Facebook stream--anything that keeps updating as you use it), the page you're currently reading is actually just a fraction of the entire page.  

If you stop and think about it for a second, it makes sense.  What is a stream?  In the case of G+, it's a never-ending flow of messages coming from all over.  What you're looking at in any one instant is just what happens to be currently available.  In other words, if you Control-F for something, it might not be in the current view of the steam.  Look at this diagram: 


The stuff in the blue dashed box represents the articles you see in the current view of the G+ page.  And therefore, the stuff in the green dashed box is the stuff you can see by scrolling up.  

However...  streams always have more stuff at the bottom that hasn't been loaded into the browser yet.  That is, you can't reach the bottom.  (Although some streams, like Facebook, loop their materials.  If you keep scrolling, at some point it will take you back to the top of the current list of posts.)  

In any event, if the thing you're trying to FIND (using Control-F) is not yet loaded into your browser, then you can't find it.  

How do you know when you're dealing with a stream?  Usually you'll see something like this when you get to the (current) bottom of the stream... look at the very bottom... 



see the circle and the text "Loading..."?  That's your clue that the web browser is going out and loading more content into the stream.  

I scrolled down a few more pages, then redid my Control-F, and found the page I was looking for: 


(Jaime, by the way, is the author, and Mom, of her own blog on search--Slow Searching.  If you enjoy this blog, I bet you'll enjoy hers as well.)  

As several readers pointed out, I should have just searched for her name in the search box at the top of the page.  But of course that won't work if you're searching for a particular term that's not a named person.  Suppose that I'd been searching for her son's name, Cale, then a search for his name wouldn't have worked.  

Search Lesson:  For streams, Control-F only works on the content that's been loaded into the browser.  As we start to see more and more streams, we have to be aware that some of the techniques we use to search don't work in quite the way you expect.  Sometimes, you have to know what the properties are of the thing you're searching!  


3.  A missing conversation with a friend.  My third friend and I had a long conversation last night; back and forth we messaged each other to figure out what to do about a particular technical problem that came up.  This morning, when I went to my Gmail to find the instant messaging thread, there was nothing there.  Oh, I could open up the IM I sent to him and find some text, but I couldn't figure out where the long text of our conversation had gone.  Do you have any idea about what could have happened here?  Where can I find out longish back-and-forth conversation?  Any ideas?  
There are two things that went wrong for me here!  

First, I have my Instant Message chats on my GMail set up to be "History is off."  That means that the IMs disappear after about 24 hours.  Even if I click on my IM chat icon for my friend, if we'd chatted more than a day ago, it would have been automatically deleted.  

But that actually wasn't the problem. 

The problem was actually more subtle than this, and it brings up a deep point about searching.  

In the first Classic Error (above) I overlimited my search because I thought that Sean's article would have been printed in the New York Times.  

The same error is happening here.  I thought my long conversation was in Gmail's IM.  But it wasn't there at all; that's just the place where I do most of my long IM conversations.  

When I went to check my Facebook chat window, I found the entire conversation.  Ah ha!  I'd overlimited my search to the wrong IM system!  (Truthfully, this is becoming more of a problem.  Now I have SnapChats, Twitter conversations, Facebook chat, different GMail accounts with different IM retention policies.)  And unfortunately, there's not one search engine to rule them all.  

But... 

Search lesson:  When searching for something that seems gone (although you're sure you saw it), consider other sources that you might confuse with the source you thought it was in.  For this example, I should have been faster to think "If it's not in this chat stream, what other chat streams do I use?"  and then gone off to search there.   

More generally, start your searches broadly, and rapidly iterate through the searches, honing in on a particular source only when you have to.  

Search on!  (And search on broadly!) 


Wednesday, July 30, 2014

Wednesday Search Challenge (7/30/14): Three classic mistakes



In the annals of SearchResearch history, there are sometimes tiny errors, sometimes huge blunders, and sometimes there are things that are small, but deeply annoying, and often repeat themselves. 

Here, today, are "Three Classic Mistakes" that I've made over the years.  These aren't huge, but if you can learn from them and save yourself the hassle--so much the better.  

To answer these, please post what you think I did wrong in each case.  What's your diagnosis, doctor? 



1.  My missing friend's article.  I have a friend by the name of Sean Carlson.  A former Googler, he now writes beautifully about Ireland and the experiences of an Irish transplant to America.  One day last year he mentioned to me that he had an article published in the New York papers about being Irish and an immigrant.  "That's fantastic!" I thought.  About a month later I remembered that I wanted to read it, so I started checking the New York Times for his article.  I did the obvious search:    [ site:NYTimes.com  Sean Carlson ]  But much to my surprise, I couldn't find his article.  I eventually found it by modifying my query, but what did I do wrong here? 
2.  Another friend's missing G+ post.  I have another friend named Jaime Teevan (a nice, uncommon name for searching!).  Most remarkably, this past week she and her 10-year-old son walked 100 miles from their home to a "local" amusement park.  I knew that she'd just put a post onto G+.  So I went to G+ and did a Control-F to find her name (and hence the post).  But there were no hits!  What?  Later, I went back and did the same thing, and FOUND her post.  What happened?  Why could I not find it the first time, but I could find it the second time?   (I checked--she had posted it to G+ several hours earlier, so it really was there, but Control-F couldn't find it.  And no, I didn't misspell her name.)  
3.  A missing conversation with a friend.  My third friend and I had a long conversation last night; back and forth we messaged each other to figure out what to do about a particular technical problem that came up.  This morning, when I went to my Gmail to find the instant messaging thread, there was nothing there.  Oh, I could open up the IM I sent to him and find some text, but I couldn't figure out where the long text of our conversation had gone.  Do you have any idea about what could have happened here?  Where can I find out longish back-and-forth conversation?  Any ideas?  

I'm posting these "Classic Mistakes" because each illustrates a kind of Search Challenge (and therefore a Search Lesson) that I've had in my own life.  (Yes, these are all real problems where I couldn't find something, and had to figure out what to do next.)  

So tell me:  When you read these situations, what would you do?  How did I solve each of these little search problems?  What did I do wrong in each case? 

Let us know what YOU think I messed up.  

Answers on Friday.  

Search on! 

Friday, July 25, 2014

Answer: How are nuclear blast zones like choosing a good place to live?

MY work sometimes intervenes.  I try to write my SearchResearch posts early in the morning before anything else can worm its way onto my schedule, but I didn't succeed yesterday.  I've got a deadline coming up on Monday, and well... you know how it goes.  Yesterday turned into a longish day and so I didn't get around to posting the hint I'd meant to share with you.  

But here's the hint:    Think geometrically.  

I know, how long would it have taken to write that down yesterday?  

Reminder:  This week's challenge was to... 



1.  Can you find the place that's "in the middle" of all four cities?  (The capitals of California, Washington, Nevada, and Montana.)  
That is, find the place you'd like to live that's equidistant from all four city centers.  (Feel free to ignore curvature of the Earth effects.)  


I have to tell you, the discussion on the Challenge was excellent.  I did not know about the "Let's Meet in the Middle" app.  Doing a search for:  

     [ travel equidistant tool ] 

(as Fred did) was an excellent move.  Everyone who did some variation on that theme gets a gold star because I didn't think of it, and I should have.  That's just great!  

The discussion about whether or not we should compute "crow flies" vs. "distance driven by car" was also excellent.  (For the record, I meant just as the crow flies, but I like the fact that we discussed other options as possible solutions.)  

To solve this problem, I started by searching out (as I hope you all did) the actual capitals of each of the states.  

Didn't we all learn the state capitials in school?  (At least the US kids should have.) We did, but memory is notoriously fallible.  So it's worth checking, as Ramón did with his queries:  


     [California capital]       A: Sacramento
     [Washington capital ]  A: Olympia
     [Montana capital]         A: Helena
     [Nevada capital]           A: Carson City


I suspect that many people will get the Washington and Nevada capitals wrong.  Check your initial data to be sure you're solving the right problem.  

Now my PLAN was to use a tool to just draw circles around each city, and then size them until I found a common meeting point.  

So my first query was: 

     [ draw circles on Google Maps ] 

and sure enough, I found a very nice circle-on-Google Maps drawing tool at MapDevelopers.com -- it lets you draw circles centered anywhere on the map.  You can vary the radius and color.  I put in the four cities and drew the following diagram.  (There are the four capitals, each surrounded by a radius of a different amount.  The fifth pin, midway between Helena and Seattle is a draggable pin, used to set the radius from the center.)  


I quickly realized that the equidistant point was going to be somewhere around 400 miles away from each of the cities.... and I also realized that just fiddling with the radii wasn't a good strategy.  

As I was telling someone else about my solution, I realized that I was implicitly trying to find the center of a circle with four points.  And--this is the key point--three points define a circle with a common radius.

This was, in effect, a little remembrance of my old high school geometry.  If three points lie on a circle, then the only point that is the same distance from all of them is in the center.  Right?  Let's call that distance r (for radius).  A fourth point (say, a fourth city) that's NOT on the circle must be at some distance from the center of the circle that's NOT r distance away.  

Just a glance at the diagram above shows that there can't possibly be any circle that fits all four of these points.  You can fit three, just not these four.  

So we have to think of a better solution than finding one point that's equidistant.  What would that be?  

My next query was to find a good method of computing the midpoint between four locations: 

     [ center between four points ] 

and that's when I found my calculator:  Geographic Midpoint.  



And this map has (at the lower left) a nice set of options for determining HOW you want to define "midpoint."  

Do you want "Center of Gravity"?  "Center of minimum distance"?  "Average lat/long"?  

Here you can see I chose "Center of gravity," which is (I looked it up) the balance point of a figure that's defined by its shape.  That's the blue dot above.  We could have used the average of the lat/long (in effect, looking for the midpoint of the lines), or we could have computed the Centroid.  But they all would be about the same, pointing to a location in southern Oregon.  

You can read a lengthy discussion about the tradeoffs and ways to compute the midpoints.  (Which Ramón pointed to in his comments.)  

Of course, we could also have taken the lat/longs for each city, and computed the intersection of diagonals.  For a roughly trapezoidal shape (as you see above), it wouldn't be that far off. 

Helena: 

     46.595806, -112.027031

Sacramento: 

     38.555556, -121.468889

Carson City: 

     39.160833, -119.753889

Olympia: 

     47.042500, -122.893056


I'll leave it as an exercise for the reader (who remembers high school geometry) to compute the intersection of the two lines. 


Search Lessons: 

There's a big one here for me:  This wasn't at all what I'd expected the answer to be!  When I wrote it up, I figured it would be a simple process to take a Google Map and drop in a few circles, compute the distance, and be done with it.  

Moral for people who write questions (I'm looking at you, teachers!), problems often are much more challenging that you first think.  

I'm really pleased that we found so many alternate solutions!  

I have to admit that I hadn't thought about the "How Far Can I Drive" aspect of the problem.  But clearly, if you're going to live there, that's a great factor to consider. 

And I really hadn't dreamed that there would be a tool to compute this, although now I know about it.  

Excellent finds and analysis from everyone.  Nicely done. 

(But of course, be sure to check your state capitals.)  

And the last lesson, of course, has to be:  You never know when geometry will be needed. 


Search on!