-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractical_geopandas.py
38 lines (31 loc) · 1.04 KB
/
practical_geopandas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# conda install geopandas
# conda install geopandas pandas fiona gdal shapely
import matplotlib.pyplot as plt
import geopandas as gpd
def simplest_plot(shape):
shape.plot()
plt.show()
def plotting(shape, col, label, leg=True):
fig, ax = plt.subplots()
shape.plot(column=col,
legend=leg,
ax=ax,
scheme='quantiles',
cmap='inferno', # 'veridis'
# missing_kwds={'color': 'white'},
legend_kwds={'fmt': '{:,.0f}', 'frameon': False}
)
shape.boundary.plot(ax=ax, color='white', linewidth=.5, edgecolor='grey')
ax.set_title(label)
ax.set_axis_off()
plt.tight_layout()
plt.show()
if __name__ == '__main__':
bsb = gpd.read_file('data/53.shp')
simplest_plot(bsb)
sales = gpd.read_file('data/sales_bairros.shp')
simplest_plot(sales)
# Maps
maps = {'price': 'Preço total', 'days_in_ma': 'Dias no mercado', 'price_util': 'Preço por m$^2$'}
for each in maps:
plotting(sales, each, maps[each])