From 0b8034225d1acf0f130740e683722c193cbfcdf1 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 8 Feb 2020 21:47:13 -0500 Subject: [PATCH 1/3] Hard-code list of example datasets. Signed-off-by: Elliott Sales de Andrade --- libpysal/examples/datasets.html | 1 + libpysal/examples/remotes.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 libpysal/examples/datasets.html diff --git a/libpysal/examples/datasets.html b/libpysal/examples/datasets.html new file mode 100644 index 00000000..dbed3fe6 --- /dev/null +++ b/libpysal/examples/datasets.html @@ -0,0 +1 @@ +GeoDa Data and Lab

    View List of Sample Data (More Info):

    These sample data are referenced in the tutorials for GeoDa, GeoDaSpace, and CAST. Alternative download links for users in China(中国):https://gitee.com/geoda/data-and-lab/tree/gh-pages/data
    NameDescription#Obs#VarsDownload
    AirBnBAirbnb rentals, socioeconomics, and crime in Chicago7720airbnb.zip
    AtlantaAtlanta, GA region homicide counts and rates9023atlanta_hom.zip
    BaltimoreBaltimore house sales prices and hedonics21117baltimore.zip
    BostonhsgBoston housing and neighborhood data50623boston.zip
    Buenosaires Electoral Data for 1999 Argentinean Elections 209 21 buenosaires.zip
    Cars2011 abandoned vehicles in Chicago (311 complaints).137,86721cars.zip
    Charleston1 2000 Census Tract Data for Charleston, SC MSA and counties 117 30 CharlestonMSA.zip
    Charleston2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Charleston, SC MSA 44 97 CharlestonMSA2.zip
    Chicago Health Chicago Health + Socio-Economics 77 86 comarea.zip
    Chicago commpop Chicago Community Area Population Percent Change for 2000 and 2010 77 8 chicago_commpop.zip
    Chicago parcels Tax parcel polygons of Cook county 592,521 5 chicago_parcels.zip
    Chile LaborLabor Markets in Chile (1982-2002)14162FLMA_updated.zip
    Chile Migration Internal Migration in Chile (1977-2002) 304 10 CHIM.zip
    Cincinnati 2008 Cincinnati Crime + Socio-Demographics 457 89 walnuthills_updated.zip
    Cleveland 2015 sales prices of homes in Cleveland, OH. 205 9 cleveland.zip
    Columbus Columbus neighborhood crime 49 20 columbus.zip
    Denver Demographics and housing in Denver neighborhoods. 75 55 denver.zip
    Elections 2012 and 2016 Presidential Elections 3,108 74 election.zip
    Grid100 Grid with simulated variables 100 34 grid100.zip
    Groceries 2015 Chicago supermarkets 148 7 grocery.zip
    Guerry Moral statistics of France (Guerry, 1833) 85 23 guerry.zip
    Health+ 2000 Health, Income + Diversity 3,984 64 income_diversity.zip
    Health Indicators Chicago Health Indicators (2005-11) 77 31 healthIndicators.zip
    Hickory1 2000 Census Tract Data for Hickory, NC MSA and counties 68 30 HickoryMSA.zip
    Hickory2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Hickory, NC MSA 29 55 HickoryMSA2.zip
    Home Sales 2014-15 Home Sales in King County, WA 21,613 21 kingcounty.zip
    Houston Houston, TX region homicide counts and rates 52 23 houston_hom.zip
    Juvenile Cardiff juvenile delinquent residences 168 3 juvenile.zip
    Lansing1 2000 Census Tract Data for Lansing, MI MSA and counties 117 30 LansingMSA.zip
    Lansing2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Lansing, MI MSA 46 55 LansingMSA2.zip
    Laozone Ozone measures at monitoring stations in Los Angeles basin 32 8 laozone.zip
    LasRosas Corn yield, fertilizer and field data for precision agriculture, Argentina, 1999 1,738 34 lasrosas.zip
    Liquor Stores 2015 Chicago Liquor Stores 571 2 liquor.zip
    Malaria Malaria incidence and population (1973, 95, 93 censuses and projections until 2005)       1,068 50 Malaria-Colombia.zip
    Milwaukee1 2000 Census Tract Data for Milwaukee, WI MSA 417 31 MilwaukeeMSA.zip
    Milwaukee2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Milwaukee, WI MSA 83 55 MilwaukeeMSA2.zip
    NCOVR US county homicides 1960-19903,085 69 ncovr.zip
    Natregimes NCOVR with regimes (book/PySAL) 3,085 73 natregimes.zip
    NDVI Normalized Difference Vegetation Index grid 49 5 ndvi.zip
    Nepal Health, poverty and education indicators for Nepal districts 75 61 nepal.zip
    NYC Demographic and housing data for New York City subboroughs, 2002-09 55 34 nyc.zip
    NYC Earnings Block-level Earnings in NYC (2002-14) 108,487 70 lehd.zip
    NYC Education NYC Education (2000) 2,216 56 nyc_2000Census.zip
    NYC Neighborhoods Demographics for New York City neighborhoods 195 98 nycnhood_acs.zip
    NYC Socio-Demographics NYC Education + Socio-Demographics 2,166 113 nyctract_acs.zip
    Ohiolung Ohio lung cancer data, 1968, 1978, 1988 88 42 ohiolung.zip
    Orlando1 2000 Census Tract Data for Orlando, FL MSA and counties 328 30 OrlandoMSA.zip
    Orlando2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Orlando, FL MSA 94 59 OrlandoMSA2.zip
    Oz9799 Monthly ozone data, 1997-99 30 78 oz9799.zip
    Phoenix ACS Phoenix American Community Survey Data (2010, 5-year averages) 685 17 phx.zip
    Pittsburgh Pittsburgh homicide locations 143 8 pittsburgh.zip
    Police Police expenditures Mississippi counties 82 21 police.zip
    Sacramento1 2000 Census Tract Data for Sacramento MSA 403 30 sacramento.zip
    Sacramento2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Sacramento MSA 125 53 SacramentoMSA2.zip
    SanFran Crime       July-Dec 2012 crime incidents in San Francisco (points + area) - for CAST 3,384 13 SFCrime_July_Dec2012.zip
    Savannah1 2000 Census Tract Data for Savannah, GA MSA and counties 77 30 SavannahMSA.zip
    Savannah2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Savannah, GA MSA 24 55 SavannahMSA2.zip
    Scotlip Male lip cancer in Scotland, 1975-80 56 11 scotlip.zip
    Seattle1 2000 Census Tract Data for Seattle, WA MSA and counties 664 30 SeattleMSA.zip
    Seattle2 1998 and 2001 Zip Code Business Patterns (Census Bureau) for Seattle, WA MSA 145 59 SeattleMSA2.zip
    SIDS North Carolina county SIDS death counts 100 13 sids.zip
    SIDS2 North Carolina county SIDS death counts and rates 100 17 sids2.zip
    Snow John Snow & the 19th Century Cholera Epidemic NA NA snow.zip
    South US Southern county homicides 1960-1990 1,412 69 south.zip
    Spirals Synthetic spiral points 301 2 spirals.csv
    StLouis St Louis region county homicide counts and rates 78 23 stlouis.zip
    Tampa1 2000 Census Tract Data for Tampa, FL MSA and counties 547 30 TampaMSA.zip
    US SDOH 2014 US Social Determinants of Health Data 71,901 25 us-sdoh-2014.zip
    \ No newline at end of file diff --git a/libpysal/examples/remotes.py b/libpysal/examples/remotes.py index 79aa0fcd..93cc4f99 100644 --- a/libpysal/examples/remotes.py +++ b/libpysal/examples/remotes.py @@ -1,9 +1,10 @@ """Handle remote datasets. """ +import os + from bs4 import BeautifulSoup import requests -import warnings from .base import PYSALDATA, Example, get_list_of_files, get_data_home @@ -21,11 +22,12 @@ def poll_remotes(): url = "https://geodacenter.github.io/data-and-lab//" try: - page = requests.get(url) - except: - warnings.warn("Remote data sets not available. Check connection.") - return {} - soup = BeautifulSoup(page.text, "html.parser") + page = requests.get(url).text + except Exception: + with open(os.path.join(os.path.dirname(__file__), + 'datasets.html')) as f: + page = f.read() + soup = BeautifulSoup(page, "html.parser") samples = soup.find(class_="samples") rows = samples.find_all("tr") datasets = {} -- 2.31.1