ADaSci Banner 2024

Unlock the Power of Geospatial Data with Leafmap’s One-Line Google Open Buildings Download

Leafmap now supports one-line downloads of Google Open Buildings data, simplifying access to the largest building dataset for any country.

Leafmap, a powerful Python package designed for interactive mapping and geospatial analysis, has recently added an impressive feature: the ability to download Google Open Buildings data with just one line of code. This dataset is the largest of its kind and provides detailed information on buildings across various countries.

Getting Started with Leafmap

Leafmap makes geospatial data analysis accessible, whether you’re an experienced programmer or just starting. It leverages popular libraries like Folium and ipyleaflet for mapping, and WhiteboxTools for advanced geospatial analysis. The package’s user-friendly interface allows users to load and visualize data with minimal coding, making it ideal for Jupyter environments.


Before diving into the new feature, ensure you have Leafmap installed. You can install it using pip:

Downloading Google Open Buildings Data

With Leafmap, downloading the Google Open Buildings dataset for any country is incredibly simple. Here’s how you can do it in just one line of code:

This script will download the building footprints for the specified country and save them as a shapefile.

Visualizing the Data

After downloading the data, you can visualize it using Leafmap’s interactive mapping capabilities. Here’s an example of how to display the Google building footprints:

This code snippet will create an interactive map with the satellite basemap and overlay the downloaded building footprints.

Merging Microsoft and Google Building Footprints

If you want to compare or merge data from Microsoft Global Building Footprints with Google Open Buildings, Leafmap makes it easy. Here’s a step-by-step guide to downloading and merging these datasets:

  1. Download Microsoft Building Footprints:pythonCopy code# Download the Microsoft building footprints leafmap.download_ms_buildings(country, out_dir="buildings", merge_output=f"{country}_ms.shp", head=None)
  2. Display Microsoft Building Footprints:pythonCopy code# Display the Microsoft building footprints m = leafmap.Map() m.add_basemap("SATELLITE") m.add_vector(f"{country}_ms.shp", layer_name="MS Buildings") m
  3. Download Google Building Footprints:pythonCopy code# Download the Google building footprints leafmap.download_google_buildings(country, out_dir="buildings", merge_output=f"{country}_google.shp", head=None, overwrite=True)
  4. Display Google Building Footprints:pythonCopy code# Display the Google building footprints url = "" m = leafmap.Map() m.add_basemap("SATELLITE") m.add_geojson(url, layer_name="Google Building Coverage") m.add_vector(f"{country}_google.shp", layer_name="Google Buildings") m


Leafmap’s new feature for downloading Google Open Buildings data simplifies access to comprehensive building datasets, enabling researchers and developers to enhance their geospatial analysis. With its intuitive interface and powerful capabilities, Leafmap continues to be a valuable tool in the geospatial community.

For more information, check out the Leafmap GitHub repository and explore the Leafmap documentation.

Happy mapping!

Picture of Association of Data Scientists

Association of Data Scientists

The Chartered Data Scientist Designation

Achieve the highest distinction in the data science profession.

Elevate Your Team's AI Skills with our Proven Training Programs

Strengthen Critical AI Skills with Trusted Generative AI Training by Association of Data Scientists.

Our Accreditations

Get global recognition for AI skills

Chartered Data Scientist (CDS™)

The highest distinction in the data science profession. Not just earn a charter, but use it as a designation.

Certified Data Scientist - Associate Level

Global recognition of data science skills at the beginner level.

Certified Generative AI Engineer

An upskilling-linked certification initiative designed to recognize talent in generative AI and large language models

Join thousands of members and receive all benefits.

Become Our Member

We offer both Individual & Institutional Membership.