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

error read_immediate_region() #221

Closed
pedro-loures opened this issue Mar 16, 2021 · 3 comments
Closed

error read_immediate_region() #221

pedro-loures opened this issue Mar 16, 2021 · 3 comments

Comments

@pedro-loures
Copy link


HTTPError Traceback (most recent call last)
~/anaconda3/lib/python3.8/site-packages/geobr/utils.py in download_metadata(url)
45 try:
---> 46 return pd.read_csv(url)
47

~/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
685
--> 686 return _read(filepath_or_buffer, kwds)
687

~/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
433 # See python/mypy#1297
--> 434 fp_or_buf, _, compression, should_close = get_filepath_or_buffer(
435 filepath_or_buffer, encoding, compression

~/anaconda3/lib/python3.8/site-packages/pandas/io/common.py in get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode, storage_options)
182 # TODO: fsspec can also handle HTTP via requests, but leaving this unchanged
--> 183 req = urlopen(filepath_or_buffer)
184 content_encoding = req.headers.get("Content-Encoding", None)

~/anaconda3/lib/python3.8/site-packages/pandas/io/common.py in urlopen(*args, **kwargs)
136
--> 137 return urllib.request.urlopen(*args, **kwargs)
138

~/anaconda3/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223

~/anaconda3/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532

~/anaconda3/lib/python3.8/urllib/request.py in http_response(self, request, response)
639 if not (200 <= code < 300):
--> 640 response = self.parent.error(
641 'http', request, response, code, msg, hdrs)

~/anaconda3/lib/python3.8/urllib/request.py in error(self, proto, *args)
562 args = (dict, proto, meth_name) + args
--> 563 result = self._call_chain(*args)
564 if result:

~/anaconda3/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:

~/anaconda3/lib/python3.8/urllib/request.py in http_error_302(self, req, fp, code, msg, headers)
754
--> 755 return self.parent.open(new, timeout=req.timeout)
756

~/anaconda3/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532

~/anaconda3/lib/python3.8/urllib/request.py in http_response(self, request, response)
639 if not (200 <= code < 300):
--> 640 response = self.parent.error(
641 'http', request, response, code, msg, hdrs)

~/anaconda3/lib/python3.8/urllib/request.py in error(self, proto, *args)
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570

~/anaconda3/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:

~/anaconda3/lib/python3.8/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650

HTTPError: HTTP Error 502: Proxy Error

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
in
1 #Leitura da geometrias das regiões e merge com os indicadores
----> 2 ri_geo = geobr.read_immediate_region()
3 ri_geo = ri_geo.rename(columns={'code_immediate':'imed_reg_code'})
4 ri_geo['imed_reg_code'] = ri_geo['imed_reg_code'].astype(int)
5 ri_geo = ri_geo.merge(regimed_df, on = 'imed_reg_code')

~/anaconda3/lib/python3.8/site-packages/geobr/read_immediate_region.py in read_immediate_region(code_immediate, year, simplified, verbose)
48 test_options(code_immediate, "code_immediate", not_allowed=[None])
49
---> 50 metadata = select_metadata("immediate_regions", year=year, simplified=simplified)
51
52 gdf = download_gpkg(metadata)

~/anaconda3/lib/python3.8/site-packages/geobr/utils.py in select_metadata(geo, simplified, year)
209
210 # Get metadata with data addresses
--> 211 metadata = download_metadata()
212
213 if len(metadata.query(f'geo == "{geo}"')) == 0:

~/anaconda3/lib/python3.8/site-packages/geobr/utils.py in download_metadata(url)
47
48 except HTTPError:
---> 49 raise Exception(
50 "Metadata file not found.
51 Please report to https://github.com/ipeaGIT/geobr/issues"

Exception: Metadata file not found. Please report to https://github.com/ipeaGIT/geobr/issues

@rafapereirabr
Copy link
Member

Hi @pedro-loures . Thank you for the heads up. It seems our server was down for a couple of hours, but is now back. Please try it again and let me know if you have any further issues.

In any case, this error message is not really helpful. This is the Error message used in the R version of geobr:

Error in download_metadata() :
Internet connection problem. If this is not a connection problem in your network, please try geobr again in a few minutes.

Ideally, we should have the same error message on both R and Python versions. Perhaps we should open this as another issue. Cc @JoaoCarabetta.

@pedro-loures
Copy link
Author

pedro-loures commented Mar 23, 2021 via email

@rafapereirabr
Copy link
Member

I've opened a separate issue, here.

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

2 participants