feat(draw): draw dataframe on map
This commit is contained in:
parent
a2ff08b195
commit
c490f2006b
41
draw.py
Normal file
41
draw.py
Normal file
@ -0,0 +1,41 @@
|
||||
from shapely.geometry import Point, MultiPoint
|
||||
from shapely.ops import cascaded_union
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import cartopy.crs as ccrs
|
||||
|
||||
df = pd.read_pickle('data_final.p')
|
||||
|
||||
biomes = {}
|
||||
biome_numbers = df['biome_num'].unique()
|
||||
for n in biome_numbers:
|
||||
biomes[n] = []
|
||||
|
||||
for (longitude, latitude), row in df.iterrows():
|
||||
biomes[row.biome_num].append(Point(longitude, latitude))
|
||||
|
||||
ax = plt.axes(projection=ccrs.PlateCarree())
|
||||
ax.stock_img()
|
||||
|
||||
colors={
|
||||
0: '#016936',
|
||||
1: '#B2D127',
|
||||
2: '#77CC00',
|
||||
3: '#99C500',
|
||||
4: '#B6CC00',
|
||||
5: '#00C5B5',
|
||||
6: '#EFFF00',
|
||||
7: '#FFEE00',
|
||||
8: '#009BFF',
|
||||
9: '#A0ADBA',
|
||||
10: '#5C62FF',
|
||||
11: '#00850F',
|
||||
12: '#FF9E1F',
|
||||
13: '#FF1F97'
|
||||
}
|
||||
|
||||
for n in biome_numbers:
|
||||
biomes[n] = MultiPoint(biomes[n]).buffer(1)
|
||||
ax.add_geometries(biomes[n], ccrs.PlateCarree(), facecolor=colors[n])
|
||||
|
||||
plt.show()
|
@ -5,3 +5,5 @@ descartes==1.1.0
|
||||
pysal==2.0.0
|
||||
rasterio==1.0.15
|
||||
tensorflow==1.12.0
|
||||
Cartopy==0.17.0
|
||||
numpy==1.16.1
|
||||
|
Loading…
Reference in New Issue
Block a user