After creating some maps with Basemap I got enthusiastic. I want to integrate shapefile information, let's say a polygon, but there are some problems. I downloaded the boarders of bavarian villages here:
https://www.arcgis.com/home/item.html?id=b752861d1a08489b9a40337668d4367e
Now I want to integrate a polygon for, let's say, Regensburg. I am able to fetch the information with this code, but I have a few problems
#!/usr/bin/env python
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import shapefile
map = Basemap(projection='merc',
resolution='l',
area_thresh=0.01,
llcrnrlon=9.497681, llcrnrlat=47.827908,
urcrnrlon=12.683716, urcrnrlat=50.408517)
map.drawcountries(color="gray")
map.fillcontinents(color='#c8dfb0', lake_color='#53BEFD')
map.drawmapboundary(color='black', linewidth=0.5, fill_color='#53BEFD')
sf = shapefile.Reader("BY_Gemeinden/BY_Gemeinden_WM.shp")
shapes = sf.shapes()
records = sf.records()
for record, shape in zip(records, shapes):
if record[3] == "Regensburg":
print(shape.shapeType)
lons, lates = zip(*shape.points)
print(record)
print(lons)
print(lates)
plt.savefig("foo.eps")
The output looks like this:
5
[797, 'BY', '6001', 'Regensburg', 'Regensburg', 'Freistaat
Bayern','Oberpfalz', '09362000', '6.42920556908e+004',
'8.05927936478e+007']
1350746.04018
6287601.12826
My Questions:
- I assume that
lon[1],lon[1]
is one point of the boarder. Obviously there are a lot more. - How do I find out what the file says. What is
shapeType
? What are the numbers inside ofrecords
? - The coordinates seem not to be in "standard" WGS84? What is it?
- Is there a quick way to paint the polygon?
Thanks a lot!!!
Aucun commentaire:
Enregistrer un commentaire