Learning Geospatial Analysis with Python by Unknown

Learning Geospatial Analysis with Python by Unknown

Author:Unknown
Language: eng
Format: epub
Publisher: Packt Publishing


No complaints from BeautifulSoup! Just to make sure the data is actually usable, let's try and access some of the data. One of the fantastic features of BeautifulSoup is it turns tags into attributes of the parse tree. If there are multiple tags with the same name, it grabs the first one. Our sample data file has hundreds of the <trkpt> tags. Let's access the first one:

>>> soup.trkpt <trkpt lat="30.307267000" lon="-89.332444000"><ele>10.7</ele><time>2013-05-16T04:39:46Z</time></trkpt>

We're now certain that the data has been parsed correctly and we can access it. If we want to access all of the <trkpt> tags, we can use the findAll() method to grab them and then use the built-in Python len() function to count them:

>>> tracks = soup.findAll("trkpt") >>> len(tracks) 2321



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.