Image based Choropleth
shiroyc opened this issue · 3 comments
Google used to maintain this super simple and cool API to render a map with colors based on data.
But they’ve stopped supporting this: https://developers.google.com/chart/image/docs/gallery/map_charts
I’ve been trying for a while to figure out how to do the same thing with Azure Maps, but to no avail.
Their API used simple query string params and directly returned an image without the need to use JS and include libraries or determine country boundaries, etc.
I looked at Azure Maps Choropleth maps, but they require you to DRAW OUT the border of the entity you are looking to color (country / state / etc), which is crazy!!
We offer a Get Polygon API and a Get Search Polygon feature that you can use to create a Choropleth Map without having to draw it manually. This functionality is also available in Power BI through the Azure Maps visual (this we call Filled Map), allowing you to simply import your data without any additional development. To render the map as a static image you need the Get Map Static Image API, where you add the polygons for your map, see here additional documentation.
To be fair, Google Maps doesn't have this either, likely due to them not having enough of a business case to include this in their platform. The Google Chart team deprecated the static image map chart in 2019 and uses an interactive map control now. When it used static images, it was free (hard to justify building a competing solution when the competitor is free). In the 17 years I've worked with the map community, I've most either wanted an interactive map experience that could export a static image, or they wanted to use custom boundaries (Azure Maps web SDK can export a static image). All in all, there are many open-source solutions that achieve this capability, and running one of those in Azure would be significantly cheaper than calling into any map platform.
There are several options to achieve your desired experience depending on what capabilities you need. As Clemens mentioned, the Azure Maps static image service could be used if you pass in the polygon boundaries. However, since that API is a "GET" request, you won't be able to put all the polygons in the URL.
A custom solution can be created and would have a ton of benefits, the main one being that it would cost a lot less than using any major map platform. Here are some capabilities to consider that would dictate which path you take in creating a custom solution:
- Need for global support. Do you need this to work for users anywhere in the world or are all your users in a single country like the USA? There is a lot of disputed borders and names in the world and a lot of regulations around maps in different countries. If you need something that works everywhere, then you would be limited to working with a major map platform that handle the disputed borders and names for you as that is a lot of work, and in certain countries where maps are heavily regulated you will unlikely want to have to go through their certification process for a custom solution. If you plan to only support this for a subset of countries, such as UN countries in North America and Western Europe, a single set of polygons of admin boundaries could be used globally. There are free admin boundaries available globally that have a "UN" view. Storing these locally with your app and using these could significantly reduce costs and provide really good performance.
- Do you need place names or just boundaries? If you only need boundaries, then a custom solution isn't overly difficult to achieve, and there are lots of open-source solutions for this. If you need placenames, then disputed names becomes a potential issue, then there may also be a need for multi-language support which can complicate things. A custom solution could still be achieved but would be a bit more work.
- What kind of background do you need? If it is a flat color (e.g. white, black,...) then a custom solution is easy. If you want an actually map or satellite imagery, then you would either need to request a static image from a map platform and then draw your data on top (alternatively request tiles, draw those first, then your data).
- What level of admin boundaries do you need? Country and state/province level polygon data is freely available globally. City and zip code boundaries are much more difficult to source. Census boundaries access varies by country. If you only need country or state level data, then there are many open-source options out there.
Here are some open-source projects to consider (note you can host a python app in an Azure function).
Thank you! Really appreciate the detailed answer.
My use case is simple
- most users are in the US
- I just need a flat map
- I just need boundaries of the countries (no placenames or states).
- I just need countries of the world
I will review the solutions you have shared.