DEV Community

Paweł Stadnicki
Paweł Stadnicki

Posted on

Geospatial is a function of your life

In this post I present Florence,
a low-code geospatial library for everyone that ranks city places with (life-inspired) functions.

Florence heavily laverages .NET Interactive/Polyglot Notebooks runtime to hide and execute code behind the scene (including breaking some language constraints).

I use open data for Zurich from, but you can use any geojson data, including imaginary Worlds.

Florence is still an experimental library, alpha release is due 24th Dec.

Is geospatial hard and boring?

Geospatial isn't hard, it is rather not accessible for a novice.

You may think that certain tools are expensive, reserved for municipal departments, and that advanced programming is required (in languages you don't necessarily like).

You can also treat this domain as (a little bit) boring.

Geospatial might be hard and boring
...unless you are not aware that you are doing geospatial.

Surprisingly a lot of geospatial analysis boils down to the question "what is the best place for/to ... (anything)?".

Also surprisingly to answer this very generic question, we can write a very simple function!

A function that takes place (or facility) and returns its value.

Image description

Such a function can be run against all well-known city districts, blocks, or custom areas.

How to get this data? "You said your library is for everyone but I don't have data-related digital skills...".

Correct, with Florence you don't care about data retrieval and types, you have it on hand. Just think about having fun(ction).

Florence: take a quick look

Florence requires at least one data file to be located in a geojson folder of your VS Code workspace. Once you load the Florence package, your files are loaded and you have strongly-type access.

Image description

Notebook's author can share all geojson files along with the notebook. However I created a special, so you can explore and download necessary files directly from the F# cell:

Image description
Under the cover it is some sort of a simplified Azure Storage Type Provider but with a capability to share cloud data without sharing the cloud access keys.

It is very handy, discoverable, and useful especially for bigger datasets, like addresses. Every dataset has necessary license data on folder or file level:

Image description

The function of your life

To do your analysis, you need to write just one function, like the function of your life. Such an activity is not just for fun, it can have many real applications. Imagine all residents are able to write it among plain data querying and joining: we can get exhaustive, the most powerful municipal platform possible.

As everything that Florence expects is a geojson, your life also must be defined in geojson file. Don't be scared, there will be a nice, graphical way to define your life space directly in the notebook:
Image description

For the time being, as most of us do not live in Zurich, we can ... rand our lifespace.

Image description

Once the cell is executed, quite a lot of magic happens under the cover. You put names of all your important places in a list, their locations are randed, and the special type called MyCityLife is created. When you feed the type with some location, you will get distances to your important places via their names.

Image description

The clue here is that those places can be anything, any citizen can name it differently.

Having your city life space type on your disposal, you can write the proper analytical function:

Image description

This function will be different for many people, even for the same person it can change overtime (there are times when we don't necessarily need our parents-in-law to be close, but it will dramatically change when children arrive).

You can run your function against the same or any other geospatial file containing city places:

Image description

Distance Type Provider

MyCityType used in the calculation is in fact a type created by a special F# Type Provider. It gets all geojson feature's properties and calculates the spatial distance to another provided location.

There are more applications for this than the presented function of life. You can get the distance between certain places similarly to asking plain questions (example for F1 fans, all you need is a single geojson with F1 tracks):

Image description

You can also measure a trip:

Image description

Other applications

In this post, I did focus on applying the function of life for geospatial purposes.
But this is only the tip of the iceberg of what you can do with Florence. The main capability is to include more data in the calculation. What if the best place should be determined based on route count of the 3 nearest stations ?

Image description

The tricky part is to join datasets in a readable, succinct manner. You can use the full F# power here. I'm pretty sure F# developers will have fun with it.

Top comments (0)