ipeaGIT / geobr

Easy access to official spatial data sets of Brazil in R and Python
https://ipeagit.github.io/geobr/
789 stars 118 forks source link

error read_immediate_region() #221

Closed pedro-loures closed 3 years ago

pedro-loures commented 3 years ago

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 https://github.com/python/mypy/issues/1297 --> 434 fp_orbuf, , 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 commented 3 years ago

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 commented 3 years ago

Thank you Joao, I was actually working on python when I got this error message, so if this is a R Error message maybe it really pays off to open another issue.


From: Rafael H M Pereira @.> Sent: Tuesday, March 16, 2021 8:18 AM To: ipeaGIT/geobr @.> Cc: pedro-loures @.>; Mention @.> Subject: Re: [ipeaGIT/geobr] error read_immediate_region() (#221)

Hi @pedro-loureshttps://github.com/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 @JoaoCarabettahttps://github.com/JoaoCarabetta.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ipeaGIT/geobr/issues/221#issuecomment-800172991, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOZLPEOCV467RWTNFAKUOCDTD45BJANCNFSM4ZHVVYFA.

rafapereirabr commented 3 years ago

I've opened a separate issue, here.