IO classes🔗
osmium.io.File
🔗
A wrapper for an OSM data file.
has_multiple_object_versions: bool
property
writable
🔗
True when the file is in a data format which supports having multiple versions of the same object in the file. This is usually the case with OSM history and diff files.
__init__(filename: Union[str, os.PathLike[str]], format: str = '') -> None
🔗
Initialise a new file object. Normally the file format of the file is guessed from the suffix of the file name. It may also be set explicitly using the format parameter.
parse_format(format: str) -> None
🔗
Set the format of the file from a format string.
osmium.io.FileBuffer
🔗
A wrapper around a buffer containing OSM data.
has_multiple_object_versions: bool
property
writable
🔗
True when the file is in a data format which supports having multiple versions of the same object in the file. This is usually the case with OSM history and diff files.
__init__(buf: Buffer, format: str) -> None
🔗
Initialise a new buffer object. buf can be any buffer that adheres to the Python buffer protocol. The format of the data must be defined in the format parameter.
parse_format(format: str) -> None
🔗
Set the format of the file from a format string.
osmium.io.Header
🔗
File header data with global information about the file.
has_multiple_object_versions: bool
property
writable
🔗
True when the file is in a data format which supports having multiple versions of the same object in the file. This is usually the case with OSM history and diff files.
__init__() -> None
🔗
Initiate an empty header.
add_box(box: Box) -> Header
🔗
Add the given bounding box to the list of bounding boxes saved in the header.
box() -> Box
🔗
Return the bounding box of the data in the file. If no such information is available, an invalid box is returned.
get(key: str, default: str = ...) -> str
🔗
Get the value of header option key or return default if there is no header option with that name.
set(key: str, value: str) -> None
🔗
Set the value of header option key to value.
osmium.io.Reader
🔗
Low-level object for reading data from an OSM file.
A Reader does not expose functions to process the data it has read from the file. Use apply for that purpose.
__init__(filename: Union[str, os.PathLike[str], FileBuffer, File], types: osm_entity_bits = ...) -> None
🔗
Create a new reader object. The input may either be a filename or a File or FileBuffer object. The types parameter defines which kinds of objects will be read from the input. Any types not present will be skipped completely when reading the file. Depending on the type of input, this can save quite a bit of time. However, be careful to not skip over types that may be referenced by other objects. For example, ways need nodes in order to compute their geometry.
Readers may be used as a context manager. In that case, the
close()
function will be called automatically when the
reader leaves the scope.
close() -> None
🔗
Close any open file handles and free all resources. The Reader is unusuable afterwards.
eof() -> bool
🔗
Check if the reader has reached the end of the input data.
header() -> Header
🔗
Return the Header structure containing global information about the input. What information is available depends on the format of the input data.
osmium.io.Writer
🔗
Low-level object for writing OSM data into a file. This class does not expose functions for receiving data to be written. Have a look at SimpleWriter for a higher-level interface for writing data.