Shiny, Google Maps, and Voronoi Diagrams

There was a comment on a recent Hacker News thread about a world airport Voronoi map that said “if only there was a webpage/software where someone could click/select points on a map…and a user Voronoi diagram would be created ;-).”

I knew such a tool already existed, but I thought I might as well try to implement one myself, so I put together the pieces:

  1. The deldir R package can quickly create Voronoi lines for a given set of two-dimensional points.
  2. Google Maps, since I knew how to handle events like clicking to add a point, dragging the points, and double-clicking to remove. Plus it’s easy to draw the Voronoi lines.
  3. Shiny can link that quick calculation of Voronoi lines with the front-end maps library API, so that user events and the server-side data stay in sync.

A live demo version is available on our Shiny demo server: https://shiny.modernresearchconsulting.com/create-voronoi

create-voronoi

The user interface is pretty simple – just click to add points, drag to change, and double-click to remove, and the Voronoi will update automatically.

There’s also an option to change the lines from straight to geodesics (following the curve of the earth).

The code is on Github and MIT-licensed.

I’d love to add a way to load sets of point at once (US state capitals, 100 tallest mountains, sports arenas, etc) when I have more time to work on this.

Open Data and Cool Maps

We’ve started offering clients open data and open source strategy consulting, and hope to have some case studies in the coming months.

Releasing data and software (or even both) to the public seems counterproductive to good business – how could it do anything but feed the competition, or draw attention to mistakes?

It’s worth thinking one step deeper:

  1. Releasing code and data can be a conspicuous demonstration of competence, a great way to draw incoming leads and even recruit to your organization.
  2. It also signals that your value is greater than the contents of files – you’re not worried about giving away the data, because where you really shine is customization and customer service, which is much harder to copy.
  3. In a world where a million companies are selling software and services for a monthly subscription, there’s a sharp discontinuity in user acquisition at $0. Start them for free, then offer upgrades in the form of additional features or support.
  4. Competitors may learn from your data and/or your code, but that’s a short-term effect – if the overall market grows, that’s good for you, even if your competitor gets a chunk of that market.
  5. If you have mistakes in your code or your data, you want to know as soon as possible, and what better way than to increase use by offering it for free – it’s almost like outsourced testing, and in our experience, fixing a publicly known bug or inaccuracy with grace and polite thanks to the finder does no harm to your reputation.

We talk about #4 a lot – if we’re unable to fit a project into our schedule, we don’t hesitate to refer to competitors. If there are more groups delivering successful projects in our field, that’s great!

Continue reading “Open Data and Cool Maps”

Growth and Development in Wake County, NC

I grew up in Raleigh, North Carolina, the state capital and seat of Wake County, which contains several other municipalities.

When I was in middle school in the year 2000, I would have laughed if you had told me any of the following:

  1. The county’s population would grow by 43.5%, from 627k to 900k, in the next ten years.
  2. The county’s population would actually reach 1 million in the next fifteen years.
  3. Cary would become the seventh-most-populous municipality in North Carolina.
  4. Holly Springs and Fuquay-Varina would be considered reasonable suburbs to Raleigh.
  5. By 2017 Wake County would have 172 public schools (27 high schools) for 155,000 students.

Well, here we are. Wake County and Raleigh have made a million of those “best places to live/work/retire” lists since the year 2000, and the county has seen growth that puts it in the top ten or fifteen fastest-growing counties in the country, depending on how you measure.

So what does that rate of development look like on a map of land parcels? Good question, keeping reading for more…

Continue reading “Growth and Development in Wake County, NC”

United States Topography

I downloaded a shapefile of North American topographical contours a while ago, and never spent much time with it until recently, when I noticed there are some really fascinating subsets of the United States.

For reference, the file comes from this page, and contains contours at 100-meter resolution. That’s actually not very detailed if you’re looking at a county or a city, but for an area this large with a pretty wide range in elevation, it’s plenty to get the big idea.

Speaking of big idea, here’s the full layer, with the color scale ranging from blue at the low end to red at the highest elevations:

overall
Might as well be honest – I could look at this map for hours and not get bored.

 

Okay, big deal – flat in the east and south, mountains in the west, right? Stay with me…

Continue reading “United States Topography”