Discussion:
Plot multiple lines using python / basemap
Boris Vladimir Comi
2012-11-15 09:20:50 UTC
Permalink
Hi all:

I have begun to learn about python / matplolib / basemap and really need some help.

My data is in an Excel workbook with the following structure:

Evento Fecha Latitud Longitud Hora (UTC)
1 02/mayo 19,7 -95,2 0045
19,3 -95.3 0115
19,8 -95,6 0145
19,9 -96,6 0215


2 03/mayo 20,2 -99,6 0815
21,5 -99,8 0845
22,5 -99,9 0915
23,5 -100,0 0945

3 15/mayo 21,3 -118,9 2215
21,5 -118,7 2245
22,8 -120,3 2315

. . . . .
. . . . .
. . . . .






How to open excel file in python?

I would like to plot multiple line joining the positions of each of the events, it is possible to do this? Have any idea how to do it?

The idea is to plot the trajectories on a particular region, for my case is Mexico.
Dave Angel
2012-11-15 10:29:19 UTC
Permalink
Received: from localhost (HELO mail.python.org) (127.0.0.1)
by albatross.python.org with SMTP; 15 Nov 2012 11:29:46 +0100
Received: from mout.perfora.net (mout.perfora.net [74.208.4.194])
(using TLSv1 with cipher RC4-SHA (128/128 bits))
(No client certificate requested)
by mail.python.org (Postfix) with ESMTPS;
Thu, 15 Nov 2012 11:29:46 +0100 (CET)
Received: from [192.168.1.106] (dpc6745181026.direcpc.com [67.45.181.26])
by mrelay.perfora.net (node=mrus0) with ESMTP (Nemesis)
id 0LZgYO-1Srwyy2VHY-00lcrx; Thu, 15 Nov 2012 05:29:42 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
rv:16.0) Gecko/20121011 Thunderbird/16.0.1
In-Reply-To: <***@BL2PRD0710MB373.namprd07.prod.outlook.com>
X-Provags-ID: V02:K0:ybbGYHA7ctRFY3Z/GKGOCCoO/HpPts/JQGAd9MqkOdW
CYdZHYM3sxaKyBsfU3JdSoU/bv9FsfAPUa1H/G0x/yB9SivF2x
jmy3fV7OQib8txlXsrI2+REylMGGcujREPlSLEnpuu12vRgyCd
D28Un7VpjWW7V0EKQHGw3TWK8B0frW+GQSRf45vIh+E8miDE1T
IRCbSFonOSTHWV2gziuuRO7YYdbgBesGl6zmRik4bSUkyk4lka
N3XqgR9Tb5/aj15DK1h+LLgowIEspXkjRa7R1r7BtZ/G9bbJ9U
MyJ42O3xk6bojeYVWhde4mnRhJaBWyyyVrDOiw/IoF22eErsQ= =
X-BeenThere: ***@python.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Discussion for learning programming with Python <tutor.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/tutor>,
<mailto:tutor-***@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/tutor/>
List-Post: <mailto:***@python.org>
List-Help: <mailto:tutor-***@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/tutor>,
<mailto:tutor-***@python.org?subject=subscribe>
Errors-To: tutor-bounces+python-tutor=***@python.org
Sender: "Tutor" <tutor-bounces+python-tutor=***@python.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.python.porting/307>
Post by Boris Vladimir Comi
I have begun to learn about python / matplolib / basemap and really need some help.
Evento Fecha Latitud Longitud Hora (UTC)
1 02/mayo 19,7 -95,2 0045
19,3 -95.3 0115
19,8 -95,6 0145
19,9 -96,6 0215
2 03/mayo 20,2 -99,6 0815
21,5 -99,8 0845
22,5 -99,9 0915
23,5 -100,0 0945
3 15/mayo 21,3 -118,9 2215
21,5 -118,7 2245
22,8 -120,3 2315
. . . . .
. . . . .
. . . . .
How to open excel file in python?
From Excel, save the file as a csv file, rather than a proprietary
format. Then, within Python program, use the csv module,
http://docs.python.org/2/library/csv.html


The essential parts:
import csv
def getdata(filename):
with open(filename, "rb") as infile:
csvreader = csv.reader(infile, delimiter ="\t", quotechar='"')
for row in csvreader:
---- process row ----

where row comes back as a list of items.

You may have to play with the delimiter and quotechar, as I don't use
Excel itself, to know what it defaults to. But a csv file is a text
file, so it should be pretty obvious if you just look at the file with a
text editor or viewer, what the separator and quote characters are. The
quote character generally only matters if some field has an embedded
separator or newline in it.
Post by Boris Vladimir Comi
I would like to plot multiple line joining the positions of each of the events, it is possible to do this? Have any idea how to do it?
Try matplotlib: http://pypi.python.org/pypi/matplotlib/1.1.0
It depends on numpy: http://numpy.scipy.org/
Post by Boris Vladimir Comi
The idea is to plot the trajectories on a particular region, for my case is Mexico.
--
DaveA

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Loading...