-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcm_7.py
More file actions
39 lines (28 loc) · 948 Bytes
/
cm_7.py
File metadata and controls
39 lines (28 loc) · 948 Bytes
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
39
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
cm_7.py
Read a shapefile with cartopy
"""
import cartopy.io.shapereader as shpreader
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
reader = shpreader.Reader('../../Data/map/shapefiles/ne_50m_admin_0_countries/ne_50m_admin_0_countries.shp')
features= reader.records()
my_crs = ccrs.PlateCarree()
fig = plt.figure(figsize=(15/2.54,10/2.54))
ax = fig.add_subplot(111, projection = my_crs)
poly = []
# print the dictionnary
for feature in features:
print('=================================================')
for key, val in feature.attributes.items():
print(key,val)
#print the last geometry
print(feature.geometry)
#plot the geometries
ax.add_geometries(reader.geometries(), crs=my_crs, facecolor='gray')
ax.coastlines()
ax.gridlines(draw_labels=True,xlocs=range(-180,181,60), ylocs=range(-90,91,30))
# plt.savefig('../../figures/cm_7.svg',bbox_inches='tight')
plt.show()