BBBikeReader.read_geojson_xz¶
-
BBBikeReader.
read_geojson_xz
(subregion_name, data_dir=None, fmt_geom=False, download_confirmation_required=True, verbose=False)[source]¶ Read a .geojson.xz data file of a geographic region.
- Parameters
subregion_name (str) – name of a region/subregion (case-insensitive) available on BBBike’s free download server
data_dir (str or None) – directory where the .geojson.xz data file is located/saved; if
None
(default), the default directoryfmt_geom (bool) – whether to reformat coordinates into a geometric object, defaults to
False
download_confirmation_required (bool) – whether to ask for confirmation before starting to download a file, defaults to
True
verbose (bool or int) – whether to print relevant information in console as the function runs, defaults to
False
- Returns
tabular data of the .csv.xz file
- Return type
pandas.DataFrame or None
Examples:
>>> import os >>> from pyhelpers.dir import cd >>> from pydriosm.reader import BBBikeReader >>> bbbike_reader = BBBikeReader() >>> sr_name = 'Leeds' >>> dat_dir = "tests" >>> leeds_geojson_xz = bbbike_reader.read_geojson_xz(sr_name, dat_dir, ... verbose=True) Confirmed to download .geojson.xz data of the following geographic region(s): Leeds ? [No]|Yes: yes Downloading "Leeds.osm.geojson.xz" to "\tests" ... Done. Parsing "\tests\Leeds.osm.geojson.xz" ... Done. >>> print(leeds_geojson_xz.head()) feature_name ... properties 0 Feature ... {'ref': '40', 'name': 'Flushdyke', 'highway': ... 1 Feature ... {'ref': '44', 'name': 'Bramham', 'highway': 'm... 2 Feature ... {'ref': '43', 'name': 'Belle Isle', 'highway':... 3 Feature ... {'ref': '42', 'name': 'Lofthouse', 'highway': ... 4 Feature ... {'ref': '42', 'name': 'Lofthouse', 'highway': ... [5 rows x 4 columns] >>> print(leeds_geojson_xz[['coordinates']].head()) coordinates 0 [-1.5558097, 53.6873431] 1 [-1.34293, 53.844618] 2 [-1.517335, 53.7499667] 3 [-1.514124, 53.7416937] 4 [-1.516511, 53.7256632] >>> leeds_geojson_xz_ = bbbike_reader.read_geojson_xz(sr_name, dat_dir, ... fmt_geom=True) >>> print(leeds_geojson_xz_[['coordinates']].head()) coordinates 0 POINT (-1.5558097 53.6873431) 1 POINT (-1.34293 53.844618) 2 POINT (-1.517335 53.7499667) 3 POINT (-1.514124 53.7416937) 4 POINT (-1.516511 53.7256632) >>> # Delete the downloaded .csv.xz data file >>> os.remove(cd(dat_dir, "Leeds.osm.geojson.xz"))