Download buildings
In [1]:
Copied!
# %pip install open-buildings
# %pip install open-buildings
Iimport libraries
In [2]:
Copied!
import os
import leafmap.foliumap as leafmap
import geopandas as gpd
import os
import leafmap.foliumap as leafmap
import geopandas as gpd
Read the tile geojson.
In [3]:
Copied!
url = 'https://sites.research.google/open-buildings/tiles.geojson'
gdf = gpd.read_file(url)
gdf.sort_values(by='size_mb', ascending=True, inplace=True)
gdf.head()
url = 'https://sites.research.google/open-buildings/tiles.geojson'
gdf = gpd.read_file(url)
gdf.sort_values(by='size_mb', ascending=True, inplace=True)
gdf.head()
Out[3]:
tile_id | tile_url | size_mb | geometry | |
---|---|---|---|---|
135 | 23b | https://storage.googleapis.com/open-buildings-... | 0.0 | POLYGON ((55.49148 -13.74670, 61.32685 -14.599... |
321 | 973 | https://storage.googleapis.com/open-buildings-... | 0.0 | POLYGON ((-84.94013 -22.54055, -84.94013 -28.5... |
320 | 971 | https://storage.googleapis.com/open-buildings-... | 0.0 | POLYGON ((-84.94013 -28.57907, -84.94013 -34.4... |
131 | 225 | https://storage.googleapis.com/open-buildings-... | 0.0 | POLYGON ((50.01877 -12.81566, 55.49148 -13.746... |
136 | 23d | https://storage.googleapis.com/open-buildings-... | 0.0 | POLYGON ((55.49148 -18.94995, 61.32685 -20.080... |
In [4]:
Copied!
print(f"Number of tiles: {len(gdf)}")
print(f"Number of tiles: {len(gdf)}")
Number of tiles: 333
In [5]:
Copied!
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Open Buildings")
m
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Open Buildings")
m
Out[5]:
Get the tile URLs.
In [6]:
Copied!
urls = gdf['tile_url'].tolist()
urls[:5]
urls = gdf['tile_url'].tolist()
urls[:5]
Out[6]:
['https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/23b_buildings.csv.gz', 'https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/973_buildings.csv.gz', 'https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/971_buildings.csv.gz', 'https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/225_buildings.csv.gz', 'https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/23d_buildings.csv.gz']
Specify the output directory.
In [7]:
Copied!
out_dir = os.path.expanduser('~/Downloads/')
out_dir = os.path.expanduser('~/Downloads/')
Download all the tiles might take a while. Let's download only the first 10 tiles.
In [8]:
Copied!
leafmap.download_files(urls[:10], out_dir=out_dir)
leafmap.download_files(urls[:10], out_dir=out_dir)
Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/23b_buildings.csv.gz To: /home/runner/Downloads/23b_buildings.csv.gz 100%|██████████| 39.2k/39.2k [00:00<00:00, 371kB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/973_buildings.csv.gz To: /home/runner/Downloads/973_buildings.csv.gz 100%|██████████| 4.22k/4.22k [00:00<00:00, 10.3MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/971_buildings.csv.gz To: /home/runner/Downloads/971_buildings.csv.gz 100%|██████████| 6.15k/6.15k [00:00<00:00, 14.0MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/225_buildings.csv.gz To: /home/runner/Downloads/225_buildings.csv.gz 100%|██████████| 9.48k/9.48k [00:00<00:00, 19.1MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/23d_buildings.csv.gz To: /home/runner/Downloads/23d_buildings.csv.gz 100%|██████████| 393/393 [00:00<00:00, 2.37MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/32b_buildings.csv.gz To: /home/runner/Downloads/32b_buildings.csv.gz 100%|██████████| 12.2k/12.2k [00:00<00:00, 23.4MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/39d_buildings.csv.gz To: /home/runner/Downloads/39d_buildings.csv.gz 100%|██████████| 16.2k/16.2k [00:00<00:00, 1.94MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/b5b_buildings.csv.gz To: /home/runner/Downloads/b5b_buildings.csv.gz 100%|██████████| 14.5k/14.5k [00:00<00:00, 65.0MB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/3ef_buildings.csv.gz To: /home/runner/Downloads/3ef_buildings.csv.gz 100%|██████████| 43.6k/43.6k [00:00<00:00, 274kB/s] Downloading... From: https://storage.googleapis.com/open-buildings-data/v3/polygons_s2_level_4_gzip/815_buildings.csv.gz To: /home/runner/Downloads/815_buildings.csv.gz 100%|██████████| 38.7k/38.7k [00:00<00:00, 279kB/s]
Last update:
2023-11-20
Created: 2023-11-20
Created: 2023-11-20