OpenSource-Hub

prettymaps

라이브러리

marceloprates/prettymaps

matplotlib으로 아름다운 OpenStreetMap 지도 그리기.

개요

OpenStreetMap 데이터를 기반으로 커스텀 지도를 그리는 미니멀한 Python 라이브러리로, 레이어, 스타일 및 프리셋을 지원하며 제너레이티브 아트와 지도 제작에 적합합니다.

README 미리보기

# prettymaps\n\nA minimal Python library to draw customized maps from [OpenStreetMap](https://www.openstreetmap.org/#map=12/11.0733/106.3078) created using the [osmnx](https://github.com/gboeing/osmnx), [matplotlib](https://matplotlib.org/), [shapely](https://shapely.readthedocs.io/en/stable/index.html) and [vsketch](https://github.com/abey79/vsketch) packages.\n\n\n\n# [](https://marceloprates.github.io/prettymaps/) [](https://pypi.org/project/prettymaps/) [](https://www.python.org/) [](LICENSE)\n\n\nThis work is [licensed](LICENSE) under a GNU Affero General Public License v3.0 (you can make commercial use, distribute and modify this project, but must **disclose** the source code with the license and copyright notice)\n\n## Note about crediting and NFTs:\n- Please keep the printed message on the figures crediting my repository and OpenStreetMap ([mandatory by their license](https://www.openstreetmap.org/copyright)).\n- I am personally **against** NFTs for their [environmental impact](https://earth.org/nfts-environmental-impact/), the fact that they're a [giant money-laundering pyramid scheme](https://twitter.com/smdiehl/status/1445795667826208770) and the structural incentives they create for [theft](https://twitter.com/NFTtheft) in the open source and generative art communities.\n- **I do not authorize in any way this project to be used for selling NFTs**, although I cannot legally enforce it. **Respect the creator**.\n- The [AeternaCivitas](https://magiceden.io/marketplace/aeterna_civitas) and [geoartnft](https://www.geo-nft.com/) projects have used this work to sell NFTs and refused to credit it. See how they reacted after being exposed: [AeternaCivitas](https://github.com/marceloprates/prettymaps/raw/main/pictures/NFT_theft_AeternaCivitas.jpg), [geoartnft](https://github.com/marceloprates/prettymaps/raw/main/pictures/NFT_theft_geoart.jpg).\n- **I have closed my other generative art projects on Github and won't be sharing new ones as open source to protect me f

FAQ (5)

문제 해결
prettymaps plotter 모드에서 `save_as`를 사용할 때 빈 SVG 파일이 생성되는 문제를 해결하는 방법은?

이 문제는 플로팅 파라미터의 문제가 아니라 prettymaps의 plotter 모드의 버그였습니다. 커밋 3f3b8be에서 수정되었습니다. 해당 수정 사항이 포함된 버전으로 업데이트한 후 플롯을 다시 실행하세요. Google Colab에서는 다음 명령으로 수정된 버전을 설치할 수 있습니다:

!pip install git+https://github.com/marceloprates/prettymaps.git@3f3b8be

메시지가 표시되면 런타임을 다시 시작한 후 코드를 다시 실행하세요. 예를 들면 다음과 같습니다:

prettymaps.plot(..., mode='plotter', save_as='barcelona_plot.svg')

생성된 SVG가 더 이상 빈 화면으로 표시되지 않을 것입니다.

원본 Issue #138
문제 해결
첫 Prettymaps 렌더링이 CPU를 거의 사용하지 않으면서 약 10분이나 걸리는 이유는 무엇인가요?

지연은 요청을 제한하는 공개 Overpass API를 OSMnx가 기다리면서 발생합니다. ox.config(log_file=True)로 로깅을 활성화하고 Pausing 56 seconds before making HTTP POST request와 같은 메시지를 찾아보세요. 따라서 첫 번째 가져오기는 CPU-bound가 아니라 network-bound입니다. OSM 응답은 디스크에 캐시되므로, 이후 동일한 영역의 렌더링은 훨씬 빨라집니다. 실행 간에 캐시를 유지하고, disk-cache 수정이 포함된 버전으로 업데이트하며, Overpass 요청을 최소화하기 위해 지도 영역이나 OSM 레이어 수를 줄이세요.

원본 Issue #22
문제 해결
prettymaps에서 이름으로 도시를 플로팅할 때 누락된 강 또는 수역 geometry를 수정하는 방법

이 문제는 geometry-perimeter 교차 연산에서 이름이 지정된 영역의 경계를 가로지르는 OSM 피처가 누락되기 때문에 발생합니다. 해결 방법으로, 장소 이름 대신 좌표와 반경(radius)을 사용하여 플롯하세요:

plot((48.8534, 2.3397), radius=7000, ...)

이름이 지정된 경계(perimeter)를 유지하려면 prettymaps/fetch.py의 get_geometries()를 패치하세요. 다음 코드를:

geometries = geometries.intersection(perimeter)

다음으로 교체하세요:

geometries = [geo.intersection(perimeter).buffer(0) for geo in geometries.geometry]

.buffer(0) 호출은 유효하지 않은 교차 결과를 복구하고 여러 개의 폴리곤을 보존합니다. 또는 issue #51 / "Fix geometry-perimeter intersection" PR에서 추적 중인 수정 사항이 포함된 prettymaps 릴리스로 업그레이드하세요.

원본 Issue #46
문제 해결
의존성이 많은 Python 패키지로 인해 기존 Python 설치가 손상되는 것을 방지하려면 어떻게 해야 하나요?

패키지를 시스템 Python 대신 격리된 가상 환경에 설치하세요. venv의 경우: python3 -m venv .venv를 실행한 다음, Linux/macOS에서는 source .venv/bin/activate로, Windows에서는 .venv\Scripts\activate로 활성화하고, pip install <package-name>으로 패키지를 설치하세요. Conda의 경우: conda create -n myenv python=3.11 -y를 실행한 다음 conda activate myenv를 실행하고, pip install <package-name> 또는 conda install <package-name>을 사용하여 패키지를 설치하세요. 이렇게 하면 종속성 버전이 OS Python과 분리되어 버전 충돌을 방지할 수 있습니다.

원본 Issue #16
문제 해결
도로 너비를 변경하지 않고 교량이나 특정 OSM 도로 태그의 색상을 다르게 지정하려면 어떻게 해야 하나요?

교량을 별도의 레이어로 플롯하고 레이어별 스타일을 적용하세요. 교량 구조물의 경우 "bridge": {"tags": {"man_made": "bridge"}}와 같은 레이어를 정의하세요. bridge 태그가 지정된 highway 세그먼트의 경우 bridge=yes인 way를 선택하는 custom_filter를 사용하여 별도의 도로 레이어를 사용하세요. 이 레이어에 다른 색상과 더 높은 zorder/z-height를 지정하여 일반 도로 레이어 위에 렌더링되도록 하되, 기본 highway 레이어의 너비 설정은 변경하지 마세요. 스타일링 API에 명시적인 값이 필요한 경우 교량 레이어를 도로 레이어에서 사용하는 것과 동일한 line-width 매핑으로 설정하세요.

원본 Issue #12