London: F#inding the Best Place to Live

London: F#inding the Best Place to Live

Mar 23, 2023

I'm presenting how you can create your city context from a UI embedded into the Notebook and convert it to a reusable powerful type.

You can then use that type for various municipal analyses:

  • find the best place to live and work

  • setup a business

  • create a new bus station

  • build a new playground or another facility (collaborative governance

And to perform such an analysis, you typically need to write just one function.

PS. I'm not describing all the functionalities of the Florence library.

You can download the notebook from here, and/or watch how I use it here

Location, Location, Location: It Matters.

When using a property portal, job board, or searching for a place to eat with teammates, the first step is filtering options by criteria such as price, salary, amenities, skills, or cuisines. Once the search is narrowed down, the available options will be similar regarding these factors. At this point, the deciding factor is often the location.

Finding the best place is a highly subjective process, as it varies based on one's personality, material possessions, and relationship status, to name a few. And you are not the center of the world while making the decisions. Besides nearby facilities, you consider the location of your parents, partners, best friend, and children's schools. You know where the good vibes are and what areas to avoid.

You cannot conquer all that by just looking at the map!

When UI falls short, trust the formula.

We want to live as close to good places and as far as possible from bad places. But my criteria for good and bad places will differ from yours. Moreover, mine and your criteria will change over time.

Is there a universal way to specify all these requirements for every person?

It is, and it is called a function. A function of a magical argument that represents your city life.

Look at the example:

I can hear these two questions:

1) What does the type "MyTowerHamlets" comes from?

2) What are the values of the fields ObscurePlace, Partner, Mom, and so on

DSL for distances

Let's answer the latter question first. The fields represent the distance to a particular place.

To the place (location) the type has been constructed with. For instance:

We can display all distances at once:

We can explore distances between exact places important to us (and the times for different traveling profiles) with the following DSL:

UI stills matters

Now I will show how to use UI to specify your city context. Then with a button click, such a visual context will be transformed into a powerful type usable for a ranking function.

You need to search for addresses with Mapbox autofill, give them friendly names, and after pressing "To interactive" you will have type MyTowerHamlets (or whatever name you provide) ready for your disposal (to use in the very next cell of F# kernel.

Random city life

If you don't want to fill out places with UI (you explore the library or don't live in London), you can rand them. The effect will be the same:

Alternative vital function definitions

Our ranking function definition is very similar to the math one:

The farther to the obscure place, the better, so in the formula, the OsbcurePlace is a nominator. I also put one partner in a nominator and a second partner in the denominator because I assume they shouldn't know about each other!

The function above is very similar to math, and if that scares you a bit, don't worry. This is just one example. The vital function can be written in more ways.

You can give plain points for each distance, but not for places that are more than some maximum. The following will assign max 5 points, with 0 points for each place farther than 2km:

That enables one to rank a place by using plain points and weights, which for some may be easier to reason about:

Note that to see distances on the FSQ map, you may need to select it first from UI. I'm working on making it available by default.

What next

Assigning a value to all places is nice, and it looks amazing on a map. But the map doesn't solve tangible problems:

  • How to check top X results?

  • How to check how a particular place fits the function?

  • How to apply the ratings only for some points, like job offers or restaurants

To answer those questions, we need to dive into geospatial indexing systems like H3.

Florence supports it, and using it is easy. Please wait for the follow-up post.

If you like this one, consider buying me a coffee.

Enjoy this post?

Buy Paweł Stadnicki a coffee

More from Paweł Stadnicki