我正在尝试将点绘制到带有大熊猫的地图上,但是当我绘制点时,地图消失了。
{'a': ['c'], 'b': ['d'], 'c': ['a'], 'd': ['e'], 'e': ['d'], 'f': ['d']}
地图没有显示点
fp = "./nyu_2451_34490/nyu_2451_34490.shp"
map_df = gpd.read_file(fp)
map_df = map_df.to_crs(epsg=4326)
geometry = [Point(x) for x in zip(df['longitude'], df['latitude'])]
gdf = gpd.GeoDataFrame(df, crs = {'init': 'epsg:4326'}, geometry=geometry)
但是当我这样做
fig, ax = plt.subplots(figsize=(20, 20))
base = map_df.plot(ax=ax, color='gray')
# gdf.plot(ax=ax, markersize=5)
答案 0 :(得分:3)
如果形状文件中包含经度和纬度,如何使用散点图绘制点?
def download_files(url):
driver.get(url)
for item in driver.find_elements_by_css_selector("a[href$='.doc']")[:2]:
filename = item.get_attribute("href").split("/")[-1]
#Define the path in the following line in order to resuse later
file_location = os.path.join(desk_location, filename)
item.click()
time_to_wait = 10
time_counter = 0
try:
while not os.path.exists(file_location): #use the file_location here
time.sleep(1)
time_counter += 1
if time_counter > time_to_wait:break
#Now rename the file once it is downloaded
os.rename(file_location, os.path.join(desk_location, "its_"+filename))
except Exception:pass
此外,这些点看起来比例不同,或者绘图显示的区域太宽。设置x和y轴的限制可能会有所帮助。
plt.scatter("longitude", "latitude", data=df)
希望这会有所帮助。