2

I am trying to read and head all the data from geofabrik specific country using this code:

from pyrosm import OSM, get_data

df = get_data("country_name")

df.head()

But I am getting this kind of error:

'str' object has no attribute 'head'

How can you simple read and then export data from downloaded osm.pbf file to CSV format for example?

1 Answer 1

0

I think get_data actually downloads the data to your machine and returns the filepath of where the data is saved. So df here is actually a string filepath. You can check by doing print(df) to see what its like.

To read the data in try:

osm = pyrosm.OSM(df) # here df is the filepath you generated above

custom_filter = {'amenity': True}

data = osm.get_pois(custom_filter=custom_filter)

data is the one you want

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.