Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Decode Error #30

Closed
afhalperin opened this issue Nov 26, 2020 · 1 comment
Closed

JSON Decode Error #30

afhalperin opened this issue Nov 26, 2020 · 1 comment

Comments

@afhalperin
Copy link

Hello, I am new to Github and Python, so I apologize if this is a dumb question. (Feel free to tell me if it is).

I tried to run (from your sample code) after installing OSMPythonTools in a cloned ArcGIS Pro environment. I got the following error (and ignored it):
image

Then I ran the code.

from OSMPythonTools.nominatim import Nominatim
nominatim = Nominatim()
heidelberg = nominatim.query('Heidelberg')

I subsequently got the following JSON DeCode Error. Is the problem the error I got with the installation?

JSONDecodeError Traceback (most recent call last)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\geo_accessor.py in from_layer(layer)
2288 from arcgis.features.geo._io.serviceops import from_layer
-> 2289 return from_layer(layer=layer)
2290 except ImportError:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\geo_io\serviceops.py in from_layer(layer, query)
104 raise ValueError("Invalid inputs: must be FeatureLayer or Table")
--> 105 sdf = layer.query(where=query, as_df=True)
106 sdf.spatial._meta.source = layer

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py in query(self, where, out_fields, time_filter, geometry_filter, return_geometry, return_count_only, return_ids_only, return_distinct_values, return_extent_only, group_by_fields_for_statistics, statistic_filter, result_offset, result_record_count, object_ids, distance, units, max_allowable_offset, out_sr, geometry_precision, gdb_version, order_by_fields, out_statistics, return_z, return_m, multipatch_option, quantization_parameters, return_centroid, return_all_records, result_type, historic_moment, sql_format, return_true_curves, return_exceeded_limit_features, as_df, datum_transformation, **kwargs)
1047 params['returnCountOnly'] = True
-> 1048 record_count = self._query(url, params, raw=as_raw)
1049 if 'maxRecordCount' in self.properties:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py in _query(self, url, params, raw)
2047 else:
-> 2048 raise queryException
2049

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py in _query(self, url, params, raw)
2017 result = self._con.post(path=url,
-> 2018 postdata=params, token=self._token)
2019 except Exception as queryException:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_init_.py in _token(self)
10777 else:

10778 self._hydrate()
10779 return self._lazy_token

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_init_.py in _hydrate(self)
10756 self._lazy_token = None

10757 self._refresh()
10758

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_init_.py in _refresh(self)
10699 else:

10700 raise e
10701

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_init_.py in _refresh(self)
10692 try:

10693 dictdata = self._con.post(self.url, params, token=self._lazy_token)
10694 except Exception as e:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_impl_con_connection.py in post(self, path, params, files, **kwargs)
709 try_json=try_json,
--> 710 force_bytes=kwargs.pop('force_bytes', False))
711 #----------------------------------------------------------------------

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis_impl_con_connection.py in _handle_response(self, resp, file_name, out_path, try_json, force_bytes)
496 else:
--> 497 data = resp.json()
498 #if 'error' in data:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\requests\models.py in json(self, **kwargs)
897 pass
--> 898 return complexjson.loads(self.text, **kwargs)
899

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
353 parse_constant is None and object_pairs_hook is None and not kw):
--> 354 return _default_decoder.decode(s)
355 if cls is None:

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\json\decoder.py in decode(self, s, _w)
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\json\decoder.py in raw_decode(self, s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
in
18 # get_URL = input("Paste in the URL for the city boundary layer you want from Open Street Map:")
19 dc_fl = FeatureLayer('https://nominatim.openstreetmap.org/ui/details.html?osmtype=R&osmid=1839150&class=boundary')
---> 20 dc_df = GeoAccessor.from_layer(dc_fl)
21 display(dc_df.head())
22

~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\geo_accessor.py in from_layer(layer)
2291 raise ImportError("Could not load from_layer.")
2292 except json.JSONDecodeError as je:
-> 2293 raise Exception("Malformed response from server, could not load the dataset: %s" % str(je))
2294 except Exception as e:
2295 raise Exception("Could not load the dataset: %s" % str(e))

Exception: Malformed response from server, could not load the dataset: Expecting value: line 1 column 1 (char 0)

@afhalperin
Copy link
Author

Yup, I didn't install this properly. Sorry for any trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant