2017-10-08 7 views
1

셰이프 파일로 작업하고 있습니다. 나는 그것을 읽고, 그 계획을 세우며, 예쁜 그림을 그려 보는 데 아무런 문제가 없다. 그러나 QGIS를 사용하여 올바른 EPSG로 다시 투영 한 후에 플롯하면 가장자리가 모두 들쭉날쭉합니다 (아래 그림 참조). 파이썬을 사용하여 부드럽게하는 방법이 있습니까? 이 모양 파일에 대한 enter image description here셰이프 파일 출력 매끄럽게하기 - Basemap python

import matplotlib.pyplot as plt 
from mpl_toolkits.basemap import Basemap 
from matplotlib.patches import Polygon 
from matplotlib.collections import PatchCollection 
import numpy as np 

#insert code for basemap setup m = Basemap(...) 
m.arcgisimage(service = 'ESRI_StreetMap_World_2D', xpixels = 1000, verbose = True) 
states_info = m.readshapefile('shapefiles/states', 'states') 
spc_info = m.readshapefile('shapefiles/corrected_epsg', 'spc', drawbounds = False) 

patches = [] 
ax = plt.gca() 

for info, shape in zip(m.spc_info, m.spc): 
    x, y = zip(*shape) 
    if info['DN'] == 2: 
     color = '#80c580' 
     zorder = 2 
     patches.append(Polygon(np.array(shape), True)) 
    if info['DN'] == 5: 
     color = '#f7f780' 
     zorder = 3 
     patches.append(Polygon(np.array(shape), True)) 
    ax.add_collection(PatchCollection(patches, facecolor= color, zorder=zorder, alpha = 0.7)) 

Source.

답변

1

This question의 답변은 Shapely Package가 Douglas-Puecker 알고리즘을 기반으로 한 Simplify 방법을 어떻게 설명하는지 설명합니다.