def extract(self, pbf, output):
        """ extract POI nodes from osm pbf extract """
        logging.info("Extracting POI nodes from {0} to {1}".format(pbf, output))
        with open(output, 'w') as f:
            # define callback for each node that is processed
            def nodes_callback(nodes):
                for node in nodes:
                    node_id, tags, coordinates = node
                    # if any tags have a matching key then write record
                    if any([t in tags for t in POI_TAGS]):
                        f.write(json.dumps(dict(tags=tags, coordinates=coordinates)))
                        f.write('\n')
            parser = OSMParser(concurrency=4, nodes_callback=nodes_callback)
            parser.parse(pbf)
        return output
def extract ( self , pbf , output ) : logging . info ( "Extracting POI nodes from {0} to {1}" . format ( pbf , output ) ) with open ( output , 'w' ) as f : def nodes_callback ( nodes ) : for node in nodes : node_id , tags , coordinates = node if any ( [ t in tags for t in POI_TAGS ] ) : f . write ( json . dumps ( dict ( tags = tags , coordinates = coordinates ) ) ) f . write ( '\n' ) parser = OSMParser ( concurrency = 4 , nodes_callback = nodes_callback ) parser . parse ( pbf ) return output
extract POI nodes from osm pbf extract