Skip to content

Commit dc096ef

Browse files
authored
Create ego_dp_demand_setup.sql
1 parent 53e1ed6 commit dc096ef

File tree

1 file changed

+246
-0
lines changed

1 file changed

+246
-0
lines changed
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/*
2+
This script creates and fills a table with information in the electricity demand per federalstate for the consumption sectors household, industry and tertiary sector.
3+
4+
__copyright__ = "Flensburg University of Applied Sciences"
5+
__license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)"
6+
__url__ = "https://github.com/openego/data_processing/blob/master/LICENSE"
7+
__author__ = "IlkaCu"
8+
*/
9+
10+
-- DROP TABLE demand.ego_demand_federalstate CASCADE;
11+
12+
CREATE TABLE demand.ego_demand_federalstate
13+
(
14+
eu_code character varying(7) NOT NULL,
15+
federal_states character varying,
16+
elec_consumption_households double precision,
17+
elec_consumption_industry double precision,
18+
elec_consumption_tertiary_sector double precision,
19+
population integer,
20+
elec_consumption_households_per_person double precision,
21+
CONSTRAINT ego_demand_federalstate_pkey PRIMARY KEY (eu_code)
22+
);
23+
24+
ALTER TABLE demand.ego_demand_federalstate
25+
OWNER TO oeuser;
26+
27+
28+
COMMENT ON TABLE demand.ego_demand_federalstate
29+
IS '{
30+
"title": "Electricity consumption per federal state in Germany",
31+
"description": "Electricity consumption of the sectors households, industry and tertiary sector (including others) for the German federal states in 2011",
32+
"language": [ "eng", "ger" ],
33+
"spatial": {
34+
"resolution": "Federal state",
35+
"location": "",
36+
"extend": "Germany"
37+
},
38+
"temporal": {
39+
"reference_date": "2011",
40+
"start": "",
41+
"end": "",
42+
"resolution": ""
43+
},
44+
"sources": [
45+
{
46+
"url": "https://github.com/openego/data_processing",
47+
"copyright": "© Reiner Lemoine Institut",
48+
"name": "eGo dataprocessing",
49+
"license": "GNU Affero General Public License Version 3 (AGPL-3.0)",
50+
"description": " "
51+
},
52+
{
53+
"url": "http://www.lak-energiebilanzen.de/seiten/energiebilanzenLaender.cfm",
54+
"copyright": " ",
55+
"name": "Länderarbeitskreis Energiebilanzen",
56+
"license": " ",
57+
"description": " "
58+
},
59+
{
60+
"url": "http://www.stmwi.bayern.de/fileadmin/user_upload/stmwivt/Themen/Energie_und_Rohstoffe/Dokumente_und_Cover/Energiebilanz/2014/B-03_bilanzjo_mgh_2014-03-07.pdf",
61+
"copyright": " ",
62+
"name": "Bayerisches Landesamt für Statistik und Datenverarbeitung",
63+
"license": " ",
64+
"description": " "
65+
},
66+
{
67+
"url": "http://www.statistik-hessen.de/publikationen/download/277/index.html",
68+
"copyright": " ",
69+
"name": "Hessisches Statistisches Landesamt",
70+
"license": " ",
71+
"description": " "
72+
},
73+
{
74+
"url": "https://www.destatis.de/GPStatistik/servlets/MCRFileNodeServlet/MVHeft_derivate_00000168/E453_2011_00a.pdf;jsessionid=CD300CD3A06FF85FDEA864FF4D91D880",
75+
"copyright": " ",
76+
"name": "Statistisches Amt Mecklenburg-Vorpommern",
77+
"license": " ",
78+
"description": " "
79+
},
80+
{
81+
"url": "http://www.umwelt.niedersachsen.de/energie/daten/co2bilanzen/niedersaechsische-energie--und-co2-bilanzen-2009-6900.html",
82+
"copyright": " ",
83+
"name": "Niedersächsisches Ministerium für Umwelt, Energie und Klimaschutz",
84+
"license": " ",
85+
"description": " "
86+
},
87+
{
88+
"url": "https://webshop.it.nrw.de/gratis/E449%20201100.pdf",
89+
"copyright": " ",
90+
"name": "Information und Technik Nordrhein-Westfalen",
91+
"license": " ",
92+
"description": " "
93+
},
94+
{
95+
"url": "http://www.stala.sachsen-anhalt.de/download/stat_berichte/6E402_j_2011.pdf",
96+
"copyright": " ",
97+
"name": "Statistisches Landesamt Sachsen-Anhalt",
98+
"license": " ",
99+
"description": " "
100+
},
101+
{
102+
"url": "http://www.statistik.thueringen.de/webshop/pdf/2011/05402_2011_00.pdf",
103+
"copyright": " ",
104+
"name": "Thüringer Landesamt für Statistik",
105+
"license": " ",
106+
"description": " "
107+
},
108+
{
109+
"url": "https://www.zensus2011.de/SharedDocs/Aktuelles/Ergebnisse/DemografischeGrunddaten.html?nn=3065474",
110+
"copyright": "© Statistisches Bundesamt, Wiesbaden 2014",
111+
"name": "Ergebnisse des Zensus am 9. Mai 2011",
112+
"license": " ",
113+
"description": "Als Download bieten wir Ihnen auf dieser Seite zusätzlich zur Zensusdatenbank CSV- und teilweise Excel-Tabellen mit umfassenden Personen-, Haushalts- und Familien- sowie Gebäude- und Wohnungs­merkmalen. Die Ergebnisse liegen auf Bundes-, Länder-, Kreis- und Gemeinde­ebene vor. Außerdem sind einzelne Ergebnisse für Gitterzellen verfügbar."
114+
}
115+
],
116+
"license": {
117+
"name": "Open Data Commons Open Database License 1.0",
118+
"copyright": "© Flensburg University of Applied Sciences",
119+
"url": "https://opendatacommons.org/licenses/odbl/1.0/",
120+
"instruction": "You are free: To Share, To Create, To Adapt; As long as you: Attribute, Share-Alike, Keep open!",
121+
"version": "1.0",
122+
"id": "ODbL-1.0"
123+
},
124+
"contributors": [
125+
{
126+
"Date": "2016-10-24",
127+
"Comment": "Add json-string",
128+
"Name": "Ilka Cussmann",
129+
"email": "[email protected]"
130+
},
131+
{
132+
"Date": "2016-03-13",
133+
"Comment": "Rectify incorrect entries",
134+
"Name": "Ilka Cussmann",
135+
"email": "[email protected]"
136+
},
137+
{
138+
"date": "2017-03-30",
139+
"comment": "Update metadata",
140+
"name": "Ludee",
141+
"email": " "
142+
},
143+
{
144+
"date": "2017-09-12",
145+
"comment": "Update metadata to v1.3",
146+
"name": "KilianZimmerer",
147+
"email": ""
148+
},
149+
{
150+
"date": "2018-03-28",
151+
"comment": "Correct wrong entries, update sources",
152+
"name": "IlkaCu",
153+
"email": "[email protected]"
154+
}
155+
],
156+
"resources": [
157+
{
158+
"fields": [
159+
{
160+
"Name": "eu_code",
161+
"unit": "",
162+
"description": "Nuts code for federal state"
163+
},
164+
{
165+
"Name": "federal_states",
166+
"unit": "",
167+
"description": "Name of federal state in Germany"
168+
},
169+
{
170+
"Name": "elec_consumption_housholds",
171+
"unit": "GWh",
172+
"description": "Annual electricity consumption in the household sector"
173+
},
174+
{
175+
"Name": "elec_consumption_industry",
176+
"unit": "GWh",
177+
"description": "Annual electricity consumption in the industrial sector"
178+
},
179+
{
180+
"Name": "elec_consumption_tertiary_sector",
181+
"unit": "GWh",
182+
"description": "Annual electricity consumption in the tertiary sector including public sector"
183+
},
184+
{
185+
"Name": "population",
186+
"unit": "",
187+
"description": "Inhabitants per federal state"
188+
},
189+
{
190+
"Name": "elec_consumption_households_per_person",
191+
"unit": "GWh",
192+
"description": "Electricity consumption of household sector per inhabitant"
193+
}
194+
],
195+
"name": "demand.ego_demand_federalstate",
196+
"format": "PostgreSQL"
197+
}
198+
],
199+
"metadata_version": "1.3"
200+
}';
201+
202+
203+
INSERT INTO demand.ego_demand_federalstate (eu_code, federal_states, elec_consumption_households, elec_consumption_industry, elec_consumption_tertiary_sector, population) VALUES
204+
('DE000', 'Deutschland', NULL, NULL, NULL, NULL),
205+
('DE100', 'Baden-Württemberg', 17142, 28742, 20952, 10486660),
206+
('DE200', 'Bayern', 21408, 34521, 26166, 12397614),
207+
('DE300', 'Berlin', 4238, 1988, 4654, 3292365),
208+
('DE400', 'Brandenburg', 3210, 7118, 4191, 2455780),
209+
('DE500', 'Bremen', 993, 2370, 1213, 650863),
210+
('DE600', 'Hamburg', 3821, 4678, 3994, 1706696),
211+
('DE700', 'Hessen', 10540, 11694, 12882, 5971816),
212+
('DE800', 'Mecklenburg-Vorpommern', 1955, 1797, 2472, 1609981),
213+
('DE900', 'Niedersachsen', 12142, 24093, 13665, 7777992),
214+
('DEA00', 'Nordrhein-Westfalen', 30203, 63682, 26360, 17538252),
215+
('DEB00', 'Rheinland-Pfalz', 6707, 15419, 5542, 3989808),
216+
('DEC00', 'Saarland', 1667, 4339, 2037, 999623),
217+
('DED00', 'Sachsen', 5260, 9535, 5643, 4056799),
218+
('DEE00', 'Sachsen-Anhalt', 3146, 9771, 1995, 2287040),
219+
('DEF00', 'Schleswig-Holstein', 5716, 3767, 4481, 2800119),
220+
('DEG00', 'Thüringen', 2847, 6180, 3669, 2188589);
221+
222+
223+
UPDATE demand.ego_demand_federalstate
224+
SET elec_consumption_households =
225+
(SELECT sum(a.elec_consumption_households) FROM demand.ego_demand_federalstate a WHERE eu_code != 'DE000')
226+
WHERE eu_code = 'DE000';
227+
228+
UPDATE demand.ego_demand_federalstate
229+
SET elec_consumption_industry =
230+
(SELECT sum(a.elec_consumption_industry) FROM demand.ego_demand_federalstate a WHERE eu_code != 'DE000')
231+
WHERE eu_code = 'DE000';
232+
233+
UPDATE demand.ego_demand_federalstate
234+
SET elec_consumption_tertiary_sector =
235+
(SELECT sum(a.elec_consumption_tertiary_sector) FROM demand.ego_demand_federalstate a WHERE eu_code != 'DE000')
236+
WHERE eu_code = 'DE000';
237+
238+
UPDATE demand.ego_demand_federalstate
239+
SET population =
240+
(SELECT sum(a.population) FROM demand.ego_demand_federalstate a WHERE eu_code != 'DE000')
241+
WHERE eu_code = 'DE000';
242+
243+
244+
UPDATE demand.ego_demand_federalstate a
245+
SET elec_consumption_households_per_person = a.elec_consumption_households/a.population;
246+

0 commit comments

Comments
 (0)