Using GeoSeries as bpolys parameter raises TypeError
Exception:
bpolys = 0 POLYGON ((8.67760 49.41586, 8.67760 49.41792, ...
1 POLYGON ((8.63446 49.42679, 8.63446 49.42966, ...
dtype: geometry
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = {'bbox': (8.6284769976, 49.4158635794, 8.677604496, 49.4296553394), 'features': [{'bbox': (8.674922287, 49.4158635794,....), (...), (...), (...), (...)),), 'type': 'Polygon'}, 'id': '1', 'properties': {}, ...}], 'type': 'FeatureCollection'}
skipkeys = False, ensure_ascii = True, check_circular = True, allow_nan = True
cls = <class 'json.encoder.JSONEncoder'>, indent = None, separators = None
default = None
def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
default=None, sort_keys=False, **kw):
"""Serialize ``obj`` to a JSON formatted ``str``.
If ``skipkeys`` is true then ``dict`` keys that are not basic types
(``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
instead of raising a ``TypeError``.
If ``ensure_ascii`` is false, then the return value can contain non-ASCII
characters if they appear in strings contained in ``obj``. Otherwise, all
such characters are escaped in JSON strings.
If ``check_circular`` is false, then the circular reference check
for container types will be skipped and a circular reference will
result in an ``RecursionError`` (or worse).
If ``allow_nan`` is false, then it will be a ``ValueError`` to
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
strict compliance of the JSON specification, instead of using the
JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.
If specified, ``separators`` should be an ``(item_separator, key_separator)``
tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and
``(',', ': ')`` otherwise. To get the most compact JSON representation,
you should specify ``(',', ':')`` to eliminate whitespace.
``default(obj)`` is a function that should return a serializable version
of obj or raise TypeError. The default simply raises TypeError.
If *sort_keys* is true (default: ``False``), then the output of
dictionaries will be sorted by key.
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
``.default()`` method to serialize additional types), specify it with
the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.
"""
# cached encoder
if (not skipkeys and ensure_ascii and
check_circular and allow_nan and
cls is None and indent is None and separators is None and
default is None and not sort_keys and not kw):
return _default_encoder.encode(obj)
if cls is None:
cls = JSONEncoder
> return cls(
skipkeys=skipkeys, ensure_ascii=ensure_ascii,
check_circular=check_circular, allow_nan=allow_nan, indent=indent,
separators=separators, default=default, sort_keys=sort_keys,
**kw).encode(obj)
E TypeError: JSONEncoder.__init__() got an unexpected keyword argument 'na'
Process finished with exit code 130 (interrupted by signal 2:SIGINT)
Solution: Differentiate between GeoSeries and GeoDataFrame when dumping to json and not passing argumentna ->
Using GeoSeries as
bpolys
parameter raises TypeErrorException:
Solution: Differentiate between GeoSeries and GeoDataFrame when dumping to json and not passing argument
na
->https://github.com/GIScience/ohsome-py/blob/37c23cf4ede45b47e13e29fd80b783270a258c65/ohsome/helper.py#L215-L216