#Extracting and Converting OpenStreetMap data in Python
OpenStreetMap is an open source collaborative mapping project that has tons of really valuable and freely available data. However, in order to use it in most applications it needs to be converted to another format. If working with large amounts of data, the best approach is to use a tool such as imposm or osm2pgsql, both of which first import the data into a PostgreSQL/PostGIS database. From there the data can be queried or exported. However, if working with smaller amounts of data where a spatial database is not necessary, there is a quick and easy way to extract data from an OSM file (XML based) using a driver in the Python OGR library. I demonstrate this approach below using a sample of data in my neighborhood in San Francisco. The OSM file that I use in this example can be downloaded from the following link on the OpenStreetMap website (http://www.openstreetmap.org/export#map=17/37.78292/-122.46336). The area I downloaded represents the Inner Richmond neighborhood, roughly between 6th and 3rd Avenues, along Geary and Clement. Below, I go through an example where I read in the points layer from the OSM data using the OGR driver, extract relevant attributes and location, convert the data to a GeoPandas GeoDataFrame, and then plot it on a map.