plot data points on map
<p>While trying to plot gps coordinates on a map from a CSV file named test_gps.csv and i am getting the error:</p>

<pre><code>ValueError: Some errors were detected !
    Line #1 (got 2 columns instead of 2)
    Line #2 (got 2 columns instead of 2)
    ...
</code></pre>

<p>My code is:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

airports = np.genfromtxt("test_gps.csv",
                         delimiter=';', 
                         dtype=[('lat', np.float32), ('lon', np.float32)], 
                         usecols=(1, 2))

fig = plt.figure()

themap = Basemap(projection='gall',
              llcrnrlon = -15,             
              llcrnrlat = 28,               
              urcrnrlon = 45,               
              urcrnrlat = 73,               
              resolution = 'l',
              area_thresh = 100000.0,
              )

themap.drawcoastlines()
themap.drawcountries()
themap.fillcontinents(color = 'gainsboro')
themap.drawmapboundary(fill_color='steelblue')

x, y = themap(airports['lon'], airports['lat'])
themap.plot(x, y, 
            'o',                    
            color='Indigo',         
            markersize=4            
            )

plt.show()
</code></pre>

<p>The CSV has the format:</p>

<pre><code>-344.586.792;-585.306.702
-314.071.598;-641.856.689
-3.435.215;-587.938.194
-346.999.893;-583.838.615
-517.951.889;-594.954.567
-517.951.889;-594.954.567
474.808.006;97.561.398
</code></pre>

<p>I tried to change the data format to other extensions and the delimiter but i still get the same error.Any idea what can I be doing wrong?! Thanks</p>

<p>It is because the index in usecols starts from 0 not 1. And the code was expecting another column to read the data and throwing the error.</p>

<p>This change in the code is able to read the values.</p>

<pre><code>airports = np.genfromtxt("test_gps.csv",
                     delimiter=';', 
                     dtype=[('lat', np.float32), ('lon', np.float32)], 
                     usecols=(0, 1))
</code></pre>

<p>Also please try to change the values in the .csv file to have just one decimal point since the values are being read as <code>nan</code>, if it has two decimal points.</p>

python matplotlib-basemap