3D city Map Barcelona

3D city Map Barcelona

thingiverse

Used custom mapbox script and blender to make this.All SVG files are included as well as the blender project file.Here is the python script used to generate high resolution png images of the roads and land. paste in your own mapbox api token (free).import asyncioimport aiohttpfrom PIL import Imagefrom io import BytesIOfrom IPython.display import display# Mapbox API detailsUSERNAME = "ryleymcc"STYLE_LAND_WATER = "clnj1nkob081q01p91o6rbziw"STYLE_ROADS = "clnj20v7q07vz01p78d6dc69m"ACCESS_TOKEN = " "ZOOM_LEVEL = 14 # Adjust as neededdef latlon_to_tile(lat, lon, zoom): """Convert latitude and longitude to tile coordinates""" import math lat_rad = math.radians(lat) n = 2.0 ** zoom xtile = int((lon + 180.0) / 360.0 * n) ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n) return xtile, ytile# Input bounding box coordinatesmin_lat = 41.338928 min_lon = 2.139630max_lat = 41.400877max_lon = 2.230308# Convert bounding box to tile coordinatesmin_x, max_y = latlon_to_tile(min_lat, min_lon, ZOOM_LEVEL)max_x, min_y = latlon_to_tile(max_lat, max_lon, ZOOM_LEVEL)tile_size = 512 # Default Mapbox tile sizecanvas_width = tile_size * (max_x - min_x + 1)canvas_height = tile_size * (max_y - min_y + 1)# Semaphore for rate limitingsemaphore = asyncio.Semaphore(10) # Adjust this value based on how many requests you want to allow concurrentlyasync def fetch_tile_async(session, style, z, x, y): url = f"https://api.mapbox.com/styles/v1/{USERNAME}/{style}/tiles/{z}/{x}/{y}?access_token={ACCESS_TOKEN}" async with semaphore: # Use the semaphore to limit the number of concurrent requests async with session.get(url) as response: if response.status == 200: content = await response.read() img = Image.open(BytesIO(content)).convert('RGBA') #display(img) return img else: print(f"Failed to fetch tile {z}/{x}/{y}. HTTP Status: {response.status}") # Return a placeholder image or None return Image.new('RGBA', (tile_size, tile_size), (255, 255, 255, 0)) # Transparent placeholderasync def stitch_tiles_async(style, filename): canvas = Image.new('RGBA', (canvas_width, canvas_height)) total_tiles = (max_x - min_x + 1) * (max_y - min_y + 1) processed_tiles = 0 async with aiohttp.ClientSession() as session: tasks = [] for x in range(min_x, max_x + 1): for y in range(min_y, max_y + 1): task = asyncio.ensure_future(fetch_and_paste_tile(session, canvas, style, x, y, processed_tiles, total_tiles)) tasks.append(task) processed_tiles_list = await asyncio.gather(*tasks) processed_tiles = sum(processed_tiles_list) display(canvas) # Display the final stitched image canvas.save(filename) print(f"Map saved as {filename}")async def fetch_and_paste_tile(session, canvas, style, x, y, processed_tiles, total_tiles): tile = await fetch_tile_async(session, style, ZOOM_LEVEL, x, y) canvas.paste(tile, ((x - min_x) * tile_size, (y - min_y) * tile_size)) processed_tiles += 1 #print(f"Processed {processed_tiles}/{total_tiles} tiles...") return processed_tiles# Run the asynchronous functionsasync def main(): await stitch_tiles_async(STYLE_LAND_WATER, "land_water_map.png") await stitch_tiles_async(STYLE_ROADS, "roads_map.png")

Download Model from thingiverse

With this file you will be able to print 3D city Map Barcelona with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on 3D city Map Barcelona.