2017-12-06 3 views
0

Ich habe Probleme, meine Shape-Datei in mein Python-Notebook zu implementieren.Importieren und Verwenden von Shape-Dateien Python und Matplotlib

Es scheint nicht meine Datei zu verweisen, obwohl der Pfad Speicherort korrekt ist.

import shapefile as shp 
sf = shp.Reader("/Shape/mygeodata/northern-ireland") 

#create figure to draw map and set its size 
fig, ax = plt.subplots(figsize=(10,20)) 


#create map with the below code 
m = Basemap(resolution='h', # c, l, i, h, f or None 
      projection='merc', 
      lat_0=0, lon_0=0, 
      llcrnrlon=-8.239, llcrnrlat=53.9911, urcrnrlon=-5.3723, urcrnrlat=55.276) 


#define how map is displayed 
m.drawmapboundary(fill_color='#46bcec') 
m.fillcontinents(color='#f2f2f2',lake_color='#46bcec') 
m.drawcoastlines() 


#for loop to plot the longitude and latitude of each crime 
for i, row in crimeDataNI.iterrows(): 
     lat = row['Latitude'] 
     lon = row['Longitude'] 
     x,y = m(lon, lat) 
     m.plot(x, y, 'o', markersize=6, color='#444444', alpha=0.8) 

#try and read in Northern Ireland police force boundaries 
m.readshapefile(sf, 'northern-ireland') 

Und ich erhalte den folgenden Fehler:

ShapefileException: Kann nicht /Shape/mygeodata/northern-ireland.dbf oder /Shape/mygeodata/northern-ireland.shp öffnen.

+1

NICHT Code als Screenshot buchen. Bitte fügen Sie sowohl den Code als auch den kompletten Stack-Trace als korrekt formatierten Text ein! –

Antwort

Verwandte Themen