-- DBMS: bigquery
CREATE TABLE `bigquery-public-data.sunroof_solar.solar_potential_by_censustract`
(
  region_name STRING OPTIONS(description="Census Tract"),
  state_name STRING OPTIONS(description="Name of the state containing that region"),
  lat_max FLOAT64 OPTIONS(description="maximum latitude for that region"),
  lat_min FLOAT64 OPTIONS(description="minimum latitude for that region"),
  lng_max FLOAT64 OPTIONS(description="maximum longitude for that region"),
  lng_min FLOAT64 OPTIONS(description="minimum longitude for that region"),
  lat_avg FLOAT64 OPTIONS(description="average latitude for that region"),
  lng_avg FLOAT64 OPTIONS(description="average longitude for that region"),
  yearly_sunlight_kwh_kw_threshold_avg FLOAT64 OPTIONS(description="75% of the optimimum sunlight in the county containing that zip code"),
  count_qualified INT64 OPTIONS(description="# of buildings in Google Maps that are suitable for solar"),
  percent_covered FLOAT64 OPTIONS(description="% of buildings in Google Maps covered by Project Sunroof"),
  percent_qualified FLOAT64 OPTIONS(description="% of buildings covered by Project Sunroof that are suitable for solar"),
  number_of_panels_n INT64 OPTIONS(description="# of solar panels potential for north-facing roof space in that region, assuming 1.650m x 0.992m panels"),
  number_of_panels_s INT64 OPTIONS(description="# of solar panels potential for south-facing roof space in that region, assuming 1.650m x 0.992m panels"),
  number_of_panels_e INT64 OPTIONS(description="# of solar panels potential for east-facing roof space in that region, assuming 1.650m x 0.992m panels"),
  number_of_panels_w INT64 OPTIONS(description="# of solar panels potential for west-facing roof space in that region, assuming 1.650m x 0.992m panels"),
  number_of_panels_f INT64 OPTIONS(description="# of solar panels potential for flat roof space in that region, assuming 1.650m x 0.992m panels"),
  number_of_panels_median INT64 OPTIONS(description="# of panels that fit on the median roof"),
  number_of_panels_total INT64 OPTIONS(description="# of solar panels potential for all roof space in that region, assuming 1.650m 0.992m panels"),
  kw_median FLOAT64 OPTIONS(description="kW of solar potential for the median building in that region (assuming 250 watts per panel)"),
  kw_total FLOAT64 OPTIONS(description="# of kW of solar potential for all roof types in that region (assuming 250 watts per panel)"),
  yearly_sunlight_kwh_n FLOAT64 OPTIONS(description="total solar energy generation potential for north-facing roof space in that region"),
  yearly_sunlight_kwh_s FLOAT64 OPTIONS(description="total solar energy generation potential for south-facing roof space in that region"),
  yearly_sunlight_kwh_e FLOAT64 OPTIONS(description="total solar energy generation potential for east-facing roof space in that region"),
  yearly_sunlight_kwh_w FLOAT64 OPTIONS(description="total solar energy generation potential for west-facing roof space in that region"),
  yearly_sunlight_kwh_f FLOAT64 OPTIONS(description="total solar energy generation potential for flat roof space in that region"),
  yearly_sunlight_kwh_median FLOAT64 OPTIONS(description="kWh/kw/yr for the median roof, in DC (not AC) terms"),
  yearly_sunlight_kwh_total FLOAT64 OPTIONS(description="total solar energy generation potential for all roof space in that region"),
  install_size_kw_buckets STRING OPTIONS(description="# of buildings with potential for various installation size buckets. Format is a JSON array, where each element is a tuple containing (1) lower bound of bucket, in kW, and (2) number of buildings in that bucket."),
  carbon_offset_metric_tons FLOAT64 OPTIONS(description="The potential carbon dioxide abatement of the solar capacity that meets the technical potential criteria. The calculation uses eGRID subregion CO2 equivalent non-baseload output emission rates. https://www.epa.gov/sites/production/files/2015-10/documents/egrid2012_summarytables_0.pdf"),
  existing_installs_count INT64 OPTIONS(description="# of buildings estimated to have a solar installation, at time of data collection"),
  center_point GEOGRAPHY
)
OPTIONS(
  description="Sunroof Solar Potential By Census Tract"
);

INSERT INTO `bigquery-public-data.sunroof_solar.solar_potential_by_censustract` (region_name, state_name, lat_max, lat_min, lng_max, lng_min, lat_avg, lng_avg, yearly_sunlight_kwh_kw_threshold_avg, count_qualified, percent_covered, percent_qualified, number_of_panels_n, number_of_panels_s, number_of_panels_e, number_of_panels_w, number_of_panels_f, number_of_panels_median, number_of_panels_total, kw_median, kw_total, yearly_sunlight_kwh_n, yearly_sunlight_kwh_s, yearly_sunlight_kwh_e, yearly_sunlight_kwh_w, yearly_sunlight_kwh_f, yearly_sunlight_kwh_median, yearly_sunlight_kwh_total, install_size_kw_buckets, carbon_offset_metric_tons, existing_installs_count, center_point) VALUES ('42101004102', 'Pennsylvania', 39.9210090637207, 39.91487121582031, -75.15560150146484, -75.1645278930664, 39.91794204711914, -75.1600570678711, 997.9, 644, 89.1891891891892, 25.34435261707989, 52, 117, 338, 382, 7779, 10, 8668, 2.5, 2167.0, 13329.487603759764, 38570.17503662109, 101008.51090087891, 109147.06738891601, 2341371.372210694, 3108.128759765625, 2603426.61314087, '[[0,599],[5,38],[10,1],[15,1],[20,3],[35,1],[145,1]]', 1654.3751197648112, 0, 'POINT(-75.1600570678711 39.9179420471191)'), ('42101006200', 'Pennsylvania', 39.92396926879883, 39.91484832763672, -75.2275390625, -75.23950958251953, 39.91941452026367, -75.23352813720703, 997.9, 278, 90.20100502512562, 19.35933147632312, 14, 293, 20, 106, 8312, 10, 8745, 2.5, 2186.25, 3952.329833984375, 92937.78611450196, 5523.158471679688, 32288.050195312502, 2490861.629968262, 3095.979943847656, 2625562.95458374, '[[0,248],[5,13],[10,3],[15,2],[20,1],[25,1],[35,1],[40,1],[45,1],[65,2],[85,1],[95,1],[110,1],[185,1],[570,1]]', 1668.4418932781712, 0, 'POINT(-75.233528137207 39.9194145202637)'), ('42101007102', 'Pennsylvania', 39.9450798034668, 39.93674087524414, -75.22274780273438, -75.23362731933594, 39.940921783447266, -75.2282485961914, 997.9, 364, 85.86206896551724, 20.883534136546185, 18, 175, 429, 724, 7544, 10, 8890, 2.5, 2222.5, 4719.213696289063, 53890.31584472656, 117890.56655273438, 226233.07905883787, 2257460.014276122, 3058.600695800781, 2660193.1894287113, '[[0,337],[5,15],[10,1],[15,2],[20,2],[40,1],[45,1],[50,1],[75,1],[210,1],[340,2]]', 1690.4480441832702, 0, 'POINT(-75.2282485961914 39.9409217834473)'), ('42101017201', 'Pennsylvania', 40.00366973876953, 39.99562072753906, -75.16590118408203, -75.17234802246094, 39.99939727783203, -75.16860961914062, 997.9, 371, 89.82074263764405, 26.44333570919458, 19, 62, 126, 141, 7933, 10, 8281, 2.5, 2070.25, 5012.9978515625, 19516.750286865234, 34912.58540039062, 39838.158593750006, 2355179.4608642585, 3031.8928283691407, 2454459.9529968263, '[[0,322],[5,25],[10,1],[15,6],[20,2],[25,3],[30,1],[35,2],[40,1],[45,2],[60,1],[65,2],[100,2],[165,1]]', 1559.7126718306854, 0, 'POINT(-75.1686096191406 39.999397277832)'), ('42101017202', 'Pennsylvania', 40.001220703125, 39.996238708496094, -75.16974639892578, -75.18019104003906, 39.9986686706543, -75.17420959472656, 997.9, 337, 81.93130910900946, 20.473876063183475, 6, 214, 150, 36, 4281, 10, 4687, 2.5, 1171.75, 1501.3426940917968, 69105.48497314451, 40352.37580566406, 9328.647174072265, 1267311.53303833, 3019.245654296875, 1387599.3836853027, '[[0,309],[5,18],[10,4],[15,1],[20,2],[25,1],[40,1],[70,1]]', 881.7647806866516, 0, 'POINT(-75.1742095947266 39.9986686706543)');