2017-12-26 2 views
0

파이썬 기본 맵을 사용하여 포인트 맵을 만들고 오버레이 된 경계를 오버레이했습니다. IUCN 데이터의 종 분포도 (species_13143)를 기반으로하는 다른 shapefile이 있습니다. 그 모양 파일을 이전 맵에 오버레이했습니다. 잘 돌아갔다. 그러나 불행히도, 그것과 관련된 다각형을 채우지는 못했습니다. 이지도에 따라 색상을 사용하여 폴리곤을 채우고 싶습니다. (색상에 대해서는 신경 쓰지 않고 단일 색상이 좋음)베이스 맵에서 색상을 사용하여 shp 파일의 폴리곤 채우기

this map.

나는 StackOverflow에서 비슷한 질문을 발견했다. 그러나 그 중 아무 것도 내 경우에 효과가 없었다. 코드와 여기에 연결된 관련 이미지 .. enter image description here

from mpl_toolkits.basemap import Basemap 
import matplotlib.pyplot as plt 
import numpy as np 
import pandas as pd 
plt.figure(figsize=(5,10)) 
map = Basemap(projection = 'merc', resolution = 'h',area_thresh = 0.5, llcrnrlon=79.2643, llcrnrlat=5.3135, urcrnrlon=82.0658, urcrnrlat=9.951) 
map.drawcoastlines(linewidth=0.5) 
map.drawcountries(linewidth=0.5) 
map.fillcontinents(alpha=0.5) 
map.drawmapboundary() 
map.drawmeridians(np.arange(0, 360, 0.5), labels=[False, False, False, True], linewidth=0.1,) 
map.drawparallels(np.arange(-90, 90, 0.5), labels=[False, True, False, False], linewidth=0.1) 
#Read district boundaries. 
sh_info=map.readshapefile('C:\\Users\\Tharindu\\Downloads\\species_13143\\species_13143',"areas",color='blue') 
shp_info = map.readshapefile('C:\\Users\\Tharindu\\downloads\\Compressed\\LKA_adm1',"areas") 
for index,row in sightings_dropped.iterrows(): 
    x,y = map(row['longitude'], row['latitude']) 
    map.plot(x, y, 'green', markersize=7, alpha=0.8,marker='o',markeredgecolor='black') 
map.drawmapscale(81.5, 5.8, 80.5, 6, 50) 
+0

출력물의 모습을 그림으로 그려야합니다 ... 수동으로 페인팅하면 링크에서 제외됩니다. – user1767754

+0

안녕하세요, 질문을 수정했습니다. 미리 감사드립니다. – Tharindu

+0

'sightings_dropped' 란 무엇입니까? – swatchai

답변

0

난 당신이 찾고있는 모두는 어떤 색상으로 Shape 파일을 작성하는 것입니다, 본질적으로 ...을 제대로 이해 해요 경우? 이것은 실제로베이스 맵 docs에 나열됩니다. 희망이 도움이 나는 귀하의 질문에 대답

from matplotlib.collections import PatchCollection 
from matplotlib.patches import Polygon 
import numpy as np 

fig = plt.figure() 
ax = fig.add_subplot(111) 

patches = [Polygon(np.array(shape), True) for info, shape in zip(m.states_info, m.states)] 
ax.add_collection(PatchCollection(patches, facecolor= 'green', edgecolor='k', linewidths=1., zorder=2)) 

:

from matplotlib.collections import PatchCollection 
from matplotlib.patches import Polygon 
import numpy as np 

fig = plt.figure() 
ax = fig.add_subplot(111) 

patches = [] 

for info, shape in zip(map.comarques_info, map.comarques): 
    patches.append(Polygon(np.array(shape), True)) 

ax.add_collection(PatchCollection(patches, facecolor= 'm', edgecolor='k', linewidths=1., zorder=2)) 

나는 지능형리스트의 팬입니다.

+0

고맙습니다. @Brandon Molyneaux, 잘 작동했습니다. 내가 basemap에 대한 초보자로서 나는 이것에 붙어있었습니다 .. 다시 한번 감사드립니다 :) – Tharindu

관련 문제