ich habe auf einer Seite folgendes gesehen:
Code: Alles auswählen
1 cities = ['London ', 'New York ', 'Madrid ', 'Cairo ', 'Moscow ', 'Delhi ', 'Dakar ']
lat = [51.507778 , 40.716667 , 40.4 , 30.058 , 55.751667 , 28.61 , 14.692778]
lon = [ -0.128056 , -74, -3.683333 , 31.229 , 37.617778 , 77.23 , -17.446667]
m = Basemap ( projection ='ortho ', lat_0 =45 , lon_0 =10)
m. drawmapboundary ()
m. drawcoastlines ()
m. fillcontinents ()
x, y = m(lon , lat )
plt . plot (x, y, 'ro ')
for city , xc , yc in zip(cities , x, y):
plt. text (xc +250000 , yc -150000 , city , bbox = dict ( facecolor ='yellow ', alpha =0.5))

Code: Alles auswählen
#Map create
# projection, lat/lon extents and resolution of polygons to draw
# resolutions: c - crude, l - low, i - intermediate, h - high, f - full
print('Creat a Basemap instance')
llcrnrlon=-29. #Lon. definition left border
llcrnrlat=1. #Lat. bottom border
urcrnrlon=29. #lon. right
urcrnrlat=39. #Lat. top
map = Basemap(projection='merc',llcrnrlon=llcrnrlon,llcrnrlat=llcrnrlat,urcrnrlon=urcrnrlon,urcrnrlat=urcrnrlat,resolution='i')
print('Location: \nEast:',llcrnrlon,'\nWest:',urcrnrlon,'\nNorth: ',urcrnrlat,'\nSouth: ',llcrnrlat)
#add the states, counties, coasts, national borders and a land-sea colored mask
map.drawcoastlines()
map.drawstates()
map.drawcountries()
map.drawlsmask(land_color='Linen', ocean_color='#CCFFFF') # can use HTML names or codes for colors
map.drawcounties() # you can even add counties (and other shapefiles!)
#plt.show()
#add Lat/Lon
parallels = np.arange(0,40,5.) # make latitude lines ever 5 degrees from 30N-50N
meridians = np.arange(-30,30,5.) # make longitude lines every 5 degrees from 95W to 70W
map.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
#Cities definition for Visualisation
cities = ['Niamey', 'Bamako', 'Dakar', 'Bobo-Dioulasso','Marrakesch', 'Tunis', 'Abuja']
lat = [13.511596 , 12.617098 , 14.716677, 11.164922 , 31.629472 , 36.806495, 9.076479]
lon = [ 2.125385 , -7.981084, -17.467686 , -4.305154 , -7.981084 , 10.181532, 7.398574]
#Plot the data on top of the map
lon,lat = np.meshgrid(lons,lats)
x,y = map(lon,lat)
# display blue marble image ( from NASA )
# as map background
map.bluemarble()
for city , xc , yc in zip(cities , x, y):
plt.text(xc, yc , city , bbox=dict(
facecolor='yellow', alpha =0.5))
TypeError: only length-1 arrays can be converted to Python scalars
was müsste ich da ändern?
Gruß