toys and tools homepage 这里推荐的是一个比较好玩的项目,是github上面的maptoposter,portal在这里
这个项目可以实现生成不同风格的城市地图。
首先是安装方式,作者提供了uv和python venv两种方式,我一直都是直接用rye的,没有直接且详细接触过uv,就按照pip+venv方式安装,直接运行pip install -r requirements.txt.
安装完需要的包之后就可以直接开始图片生成大法了,使用方法非常简单,python create_map_poster.py --city <city> --country <country> [options]
[options]这里可以指定主题,-t,这个项目主页展示了样例,现在来自己生成一张,比如说我想要世界第一城东京(2025年也是微弱优势战胜纽约了),就可以这样写:python create_map_poster.py --city tokyo --country japan -t forest,结果如下:
还有其他参数,比如自定义图片中心位置经纬度的参数-lat, -long, 强制修改图片上文字的--country-label, -dc, -dC, 设置图片显示半径的-d, 设置图片大小的-W, -H, 修改字体的--font-family.
作者还给出了推荐的尺寸:
Target
Resolution (px)
Inches (-W / -H)
Instagram Post
1080 x 1080
3.6 x 3.6
Mobile Wallpaper
1080 x 1920
3.6 x 6.4
HD Wallpaper
1920 x 1080
6.4 x 3.6
4K Wallpaper
3840 x 2160
12.8 x 7.2
A4 Print
2480 x 3508
8.3 x 11.7
还有一些推荐用法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 python create_map_poster.py -c "Tokyo" -C "Japan" -dc "東京" -dC "日本" --font-family "Noto Sans JP" -t japanese_ink python create_map_poster.py -c "Seoul" -C "South Korea" -dc "서울" -dC "대한민국" --font-family "Noto Sans KR" -t midnight_blue python create_map_poster.py -c "Bangkok" -C "Thailand" -dc "กรุงเทพมหานคร" -dC "ประเทศไทย" --font-family "Noto Sans Thai" -t sunset python create_map_poster.py -c "Dubai" -C "UAE" -dc "دبي" -dC "الإمارات" --font-family "Cairo" -t terracotta python create_map_poster.py -c "Beijing" -C "China" -dc "北京" -dC "中国" --font-family "Noto Sans SC" python create_map_poster.py -c "Phnom Penh" -C "Cambodia" -dc "ភ្នំពេញ" -dC "កម្ពុជា" --font-family "Noto Sans Khmer" python create_map_poster.py -c "New York" -C "USA" -t noir -d 12000 python create_map_poster.py -c "Barcelona" -C "Spain" -t warm_beige -d 8000 python create_map_poster.py -c "Venice" -C "Italy" -t blueprint -d 4000 python create_map_poster.py -c "Amsterdam" -C "Netherlands" -t ocean -d 6000 python create_map_poster.py -c "Dubai" -C "UAE" -t midnight_blue -d 15000 python create_map_poster.py -c "Paris" -C "France" -t pastel_dream -d 10000 python create_map_poster.py -c "Moscow" -C "Russia" -t noir -d 12000 python create_map_poster.py -c "Tokyo" -C "Japan" -t japanese_ink -d 15000 python create_map_poster.py -c "Marrakech" -C "Morocco" -t terracotta -d 5000 python create_map_poster.py -c "Rome" -C "Italy" -t warm_beige -d 8000 python create_map_poster.py -c "San Francisco" -C "USA" -t sunset -d 10000 python create_map_poster.py -c "Sydney" -C "Australia" -t ocean -d 12000 python create_map_poster.py -c "Mumbai" -C "India" -t contrast_zones -d 18000 python create_map_poster.py -c "London" -C "UK" -t noir -d 15000 python create_map_poster.py -c "Budapest" -C "Hungary" -t copper_patina -d 8000 python create_map_poster.py --city "New York" --country "USA" -lat 40.776676 -long -73.971321 -t noir python create_map_poster.py --list-themes python create_map_poster.py -c "Tokyo" -C "Japan" --all-themes
半径建议:4000-6000m用于小城市,8000-12000m用于中等城市,15000-20000m用于大城市。
同时内置的主题可以在themes下查看。
总之是一个很有意思的小工具,可以用来制作漂亮的地图,我也做了几个。
toys and tools homepage is here .