top of page
Search
  • Writer's picturechangsheng chen

Plotting Maps using vega

Updated: May 18, 2020

This week, we tried to figure out the problem of how to show our data on the map. There are two ways to make maps. One way is to make maps by importing the shapefile and we can show some information based on the shapefile. Another way is to make maps by using the online geographic data system provided by some packages, like folium in python. We tried both methods and the later one is better since it can combine the vega, vega-lite, or Altair plot with the maps in an interactive way. Details are provided in follows.


First of all, we download the shapefile from some geographic websites. The link (https://www.igismap.com/download-free-shapefile-maps/?amp) provides relevant websites that we can use to download shapefile. It is worthy to mention that there are two kinds of the unit in geo-data based on different coordinate reference system standards. One is meters and another is the decimal degree. The shapefile with different standards has a different format of longitude and latitude value. In the Airbnb dataset, we use the decimal degree as the unit. Hence, we also use the shapefile with the decimal degree.




Figure 1 presents the scatter plot with the longitude and latitude of rooms provided by the Airbnb data. Figure 2 is the map of Belgium based on the shapefile. We try to combine the location with the map and make Figure 3. It is obvious that this kind of plot is not good since it is static and not interactive. It cannot be zoomed in or out and just very limited information is presented.


Then, we decide to choose another way to draw informative maps. The python package folium is a better choice since it can use the online geographic data and make some interactive graphs, like google map. Besides, it can also combine the road map with markers and popups, which can give readers more details about the room information, like position and traffic condition. It can also add the vega, vega-lite or Altair plot into the popup to show more information.

Based on the package folium, we made two kinds of map plots. One is to combine the location with the map. Figure 4 presents that plot. We locate the room on the Brussel map based on the sub-dataset of Brussel. Readers can click the “+” or “—” sign to zoom in or out. Readers can get the physical position easily and when they click markers, they can get the name of rooms.


Another one is to combine the summarized information with the city's position. Figure 5 presents the plot where the average room price for different room types in three cities is presented. When readers click the circle representing the city, the popup will show the vega plot summarizing the information for that.


13 views0 comments

Recent Posts

See All
bottom of page