<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Afood1.sql</id>
	<title>Code:food1.sql - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Afood1.sql"/>
	<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;action=history"/>
	<updated>2026-09-21T16:26:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=2667&amp;oldid=prev</id>
		<title>Elie: new domain name</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=2667&amp;oldid=prev"/>
		<updated>2024-11-10T07:57:46Z</updated>

		<summary type="html">&lt;p&gt;new domain name&lt;/p&gt;
&lt;a href=&quot;https://thechange.wiki/index.php?title=Code:food1.sql&amp;amp;diff=2667&amp;amp;oldid=648&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=648&amp;oldid=prev</id>
		<title>Elie at 13:33, 4 February 2023</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=648&amp;oldid=prev"/>
		<updated>2023-02-04T13:33:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:33, 4 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Overview==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Overview==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is ''sqlite code'' to analyze the production of [[food]] crops and nutrition. Data is mostly from [https://fao.org FAO] and [https://usda.gov USDA].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is ''sqlite code'' to analyze the production of [[food]] crops and nutrition.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Some key questions it can help to answer:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* How much food could there be (globally per capita) if nothing was wasted and everything was plant-based?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Which countries produce a surplus?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Which crops get the best yields?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Which plant-based diets are the most optimal for feeding the world and preventing deforestation?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Data is mostly from [https://fao.org FAO] and [https://usda.gov USDA].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dependencies (data files as input)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dependencies (data files as input)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l612&quot;&gt;Line 612:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 620:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Why is ranking only based on protein and calories?==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;====Take some of these results with a grain of salt====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=====Monoculture vs polyculture=====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Be careful not to interperet these results as &quot;This one crop is the best, let's just grow that and nothing else!&quot; It could be that some crops [[companion planting|depend on each other]] for their high yields. I recommend growing ''a mix of'' top crops, and especially include [[legumes]] for [[nitrogen fixing]].&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=====Local variation=====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;It's possible that a country's top-yielding crops wouldn't be top-yielding in other parts of that country, if the soil or climate is different.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=====Social, economic, and technological factors=====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Maybe the top-yielding crop just has more resources invested into it - or the people who grow it are richer for historical reasons. In which case, maybe some currently-less-productive crops could be just as good if given a chance.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=&lt;/ins&gt;==Why is ranking only based on protein and calories?&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It's true that humans need a lot more than just protein and calories. We also need vitamins, minerals, fiber, and omegas (3 and 6). But in a world where farm land is scarce {{x|which ''is'' today's world, in the sense that both hunger and deforestation are happening}} - protein and calories are of greatest concern.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It's true that humans need a lot more than just protein and calories. We also need vitamins, minerals, fiber, and omegas (3 and 6). But in a world where farm land is scarce {{x|which ''is'' today's world, in the sense that both hunger and deforestation are happening}} - protein and calories are of greatest concern.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Nearly every crop in its natural form contains ''some'' vitamins and minerals.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Nearly every crop in its natural form contains ''some'' vitamins and minerals.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l619&quot;&gt;Line 619:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 635:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* There is almost always an overabundance of fibre in crops. There are parts of plants we don't eat ''because'' they are so fiberous.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* There is almost always an overabundance of fibre in crops. There are parts of plants we don't eat ''because'' they are so fiberous.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Omegas 3 &amp;amp; 6 might be a genuine concern, and we should analyze this too. The next version of the [[nutrition calculator]] will track these.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Omegas 3 &amp;amp; 6 might be a genuine concern, and we should analyze this too. The next version of the [[nutrition calculator]] will track these.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Take these results with a grain of salt==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===Monoculture vs polyculture===&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Be careful not to interperet these results as &quot;This one crop is the best, let's just grow that and nothing else!&quot; It could be that some crops [[companion planting|depend on each other]] for their high yields. I recommend growing ''a mix of'' top crops, and especially include [[legumes]] for [[nitrogen fixing]].&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===Local variation===&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;It's possible that a country's top-yielding crops wouldn't be top-yielding in other parts of that country, if the soil or climate is different.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===Social, economic, and technological factors===&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Maybe the top-yielding crop just has more resources invested into it - or the people who grow it are richer for historical reasons. In which case, maybe some currently-less-productive crops could be just as good if given a chance.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=220&amp;oldid=prev</id>
		<title>Elie at 18:33, 26 August 2022</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=220&amp;oldid=prev"/>
		<updated>2022-08-26T18:33:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:33, 26 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is ''sqlite code'' to analyze the production of [[food]] crops and nutrition. Data is mostly from [https://fao.org FAO] and [https://usda.gov USDA].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is ''sqlite code'' to analyze the production of [[food]] crops and nutrition. Data is mostly from [https://fao.org FAO] and [https://usda.gov USDA].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dependencies&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dependencies &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(data files as input)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Code:fao_usda.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Code:fao_usda.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:sr28-collated.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:sr28-collated.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;PRIMARY-&lt;/del&gt;fao-crops-primary.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:fao-crops-primary.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;PRIMARY-&lt;/del&gt;API_SP.POP.TOTL_DS2_en_csv_v2_4150863.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:API_SP.POP.TOTL_DS2_en_csv_v2_4150863.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:global-hunger-index-2021.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:global-hunger-index-2021.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;PRIMARY-&lt;/del&gt;country-and-continent-codes-list-csv_csv.csv]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[:File:country-and-continent-codes-list-csv_csv.csv]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See more notes below the code.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See more notes below the code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.mode csv&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.mode csv&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  cross-reference: crops (FAO data) with foods (USDA nutrition data):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  cross-reference: crops (FAO data) with foods (USDA nutrition data):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import fao_usda.csv &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                                          &lt;/del&gt;fao_usda&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import fao_usda.csv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                                      &lt;/ins&gt;fao_usda&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  nutrition (USDA):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  nutrition (USDA):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/sr28-collated.csv &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                                &lt;/del&gt;usda&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/sr28-collated.csv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                            &lt;/ins&gt;usda&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  crop production (FAO):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  crop production (FAO):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/primary&lt;/del&gt;/fao&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/&lt;/del&gt;crops-primary.csv &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                    &lt;/del&gt;fao&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/fao&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-&lt;/ins&gt;crops-primary.csv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                        &lt;/ins&gt;fao&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  population of regions (World Bank):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  population of regions (World Bank):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/primary&lt;/del&gt;/API_SP.POP.TOTL_DS2_en_csv_v2_4150863.csv pop&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/API_SP.POP.TOTL_DS2_en_csv_v2_4150863.csv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;pop&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  global hunger index (.com)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  global hunger index (.com)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/global-hunger-index-2021.csv &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                     &lt;/del&gt;ghi&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/global-hunger-index-2021.csv &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;                 &lt;/ins&gt;ghi&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  region codes:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--  region codes:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/primary&lt;/del&gt;/country-and-continent-codes-list-csv_csv.csv  region&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.import data/country-and-continent-codes-list-csv_csv.csv  region&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.mode list&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.mode list&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=215&amp;oldid=prev</id>
		<title>Elie at 14:29, 25 August 2022</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=215&amp;oldid=prev"/>
		<updated>2022-08-25T14:29:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://thechange.wiki/index.php?title=Code:food1.sql&amp;amp;diff=215&amp;amp;oldid=184&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=184&amp;oldid=prev</id>
		<title>Elie at 16:28, 13 August 2022</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=184&amp;oldid=prev"/>
		<updated>2022-08-13T16:28:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://thechange.wiki/index.php?title=Code:food1.sql&amp;amp;diff=184&amp;amp;oldid=146&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=146&amp;oldid=prev</id>
		<title>Elie: Created page with &quot;&lt;syntaxhighlight lang=&quot;sql&quot;&gt; -- This is used in the methodology of various olam.wiki pages -- Copyright Elie Goldman Smith, 2022 (Creative Commons license) -- Run this in SQLite3 ----------------------   -- Load data from various sources .mode csv --  cross-reference: crops (FAO data) with foods (USDA nutrition data): .import fao_usda.csv                                           fao_usda --  nutrition (USDA): .import data/sr28-collated.csv...&quot;</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:food1.sql&amp;diff=146&amp;oldid=prev"/>
		<updated>2022-08-05T16:11:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt; -- This is used in the methodology of various olam.wiki pages -- Copyright Elie Goldman Smith, 2022 (Creative Commons license) -- Run this in SQLite3 ----------------------   -- Load data from various sources .mode csv --  cross-reference: crops (FAO data) with foods (USDA nutrition data): .import fao_usda.csv                                           fao_usda --  nutrition (USDA): .import data/sr28-collated.csv...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
-- This is used in the methodology of various olam.wiki pages&lt;br /&gt;
-- Copyright Elie Goldman Smith, 2022 (Creative Commons license)&lt;br /&gt;
-- Run this in SQLite3&lt;br /&gt;
----------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Load data from various sources&lt;br /&gt;
.mode csv&lt;br /&gt;
--  cross-reference: crops (FAO data) with foods (USDA nutrition data):&lt;br /&gt;
.import fao_usda.csv                                           fao_usda&lt;br /&gt;
--  nutrition (USDA):&lt;br /&gt;
.import data/sr28-collated.csv                                 usda&lt;br /&gt;
--  crop production (FAO):&lt;br /&gt;
.import data/primary/fao/crops-primary.csv                     fao&lt;br /&gt;
--  country codes (FAO):&lt;br /&gt;
.import data/primary/fao/FAOSTAT-country-codes.csv             region&lt;br /&gt;
--  population of regions (World Bank):&lt;br /&gt;
.import data/primary/API_SP.POP.TOTL_DS2_en_csv_v2_4150863.csv pop&lt;br /&gt;
--  global hunger index (.com)&lt;br /&gt;
.import data/global-hunger-index-2021.csv                      ghi&lt;br /&gt;
.mode list&lt;br /&gt;
&lt;br /&gt;
-- Fix some of the region codes, to match the ISO3 standard&lt;br /&gt;
UPDATE pop SET `Country Code`=&amp;quot;X01&amp;quot; WHERE `Country Code`=&amp;quot;WLD&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
-- Replace some empty strings with NULLs, so aggregate functions work&lt;br /&gt;
UPDATE fao SET `Value`=NULL WHERE `Value`='';&lt;br /&gt;
UPDATE pop SET `2021`=NULL WHERE `2021`='';&lt;br /&gt;
UPDATE pop SET `2020`=NULL WHERE `2020`='';&lt;br /&gt;
UPDATE pop SET `2019`=NULL WHERE `2019`='';&lt;br /&gt;
UPDATE pop SET `2018`=NULL WHERE `2018`='';&lt;br /&gt;
UPDATE pop SET `2017`=NULL WHERE `2017`='';&lt;br /&gt;
UPDATE pop SET `2016`=NULL WHERE `2016`='';&lt;br /&gt;
UPDATE pop SET `2015`=NULL WHERE `2015`='';&lt;br /&gt;
UPDATE pop SET `2014`=NULL WHERE `2014`='';&lt;br /&gt;
UPDATE pop SET `2013`=NULL WHERE `2013`='';&lt;br /&gt;
UPDATE pop SET `2012`=NULL WHERE `2012`='';&lt;br /&gt;
UPDATE pop SET `2011`=NULL WHERE `2011`='';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Generate a secondary table for easier querying.&lt;br /&gt;
-- It's big, and it intentionally contains some redundancy.&lt;br /&gt;
CREATE TABLE main AS&lt;br /&gt;
SELECT&lt;br /&gt;
 region_name, region_m49, region_iso3, region_population, region_ghi,&lt;br /&gt;
 crop_name, food_name, food_code,&lt;br /&gt;
 production_food_grams_per_day,&lt;br /&gt;
 production_food_grams_per_day * fat_fraction_of_food      AS production_fat_grams_per_day,&lt;br /&gt;
 production_food_grams_per_day * protein_fraction_of_food  AS production_protein_grams_per_day,&lt;br /&gt;
 production_food_grams_per_day * kalories_per_gram_of_food AS production_kalories_per_day,&lt;br /&gt;
 yield_food_grams_per_day_per_acre,&lt;br /&gt;
 yield_food_grams_per_day_per_acre * fat_fraction_of_food      AS yield_fat_grams_per_day_per_acre,&lt;br /&gt;
 yield_food_grams_per_day_per_acre * protein_fraction_of_food  AS yield_protein_grams_per_day_per_acre,&lt;br /&gt;
 yield_food_grams_per_day_per_acre * kalories_per_gram_of_food AS yield_kalories_per_day_per_acre,&lt;br /&gt;
 farmland_acres&lt;br /&gt;
FROM (&lt;br /&gt;
 SELECT&lt;br /&gt;
  region.`M49 Code`   AS region_m49,&lt;br /&gt;
  p.`Area Code (ISO3)`AS region_iso3, -- Technically this is a &amp;quot;bare column&amp;quot;, but it ALWAYS correlates with `Area`, so it's all good.&lt;br /&gt;
  p.`Area`            AS region_name,&lt;br /&gt;
  p.`Item`            AS crop_name,&lt;br /&gt;
  usda.`Long_desc`    AS food_name,&lt;br /&gt;
  usda.`NDB_No`       AS food_code,&lt;br /&gt;
&lt;br /&gt;
  -- population from most recent year available:&lt;br /&gt;
  COALESCE(pop.`2021`,pop.`2020`,pop.`2019`,pop.`2018`,pop.`2017`,pop.`2016`,pop.`2015`,pop.`2014`,pop.`2013`,pop.`2012`,pop.`2011`)&lt;br /&gt;
  AS region_population,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- global hunger index from most recent year available:&lt;br /&gt;
  ghi.`2021`          AS region_ghi,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- crop production...&lt;br /&gt;
  -- in tonnes/year:&lt;br /&gt;
  p.val&lt;br /&gt;
  -- edible fraction of crop:&lt;br /&gt;
  * fao_usda.`Multiplier` * 0.01*(100 - usda.`Refuse`)&lt;br /&gt;
  -- conversion factor: &amp;quot;tonnes/year&amp;quot; to &amp;quot;grams/day&amp;quot;:&lt;br /&gt;
  * 2737.9093&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS production_food_grams_per_day,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- crop yields...&lt;br /&gt;
  -- in hectograms/year/hectare:&lt;br /&gt;
  y.val&lt;br /&gt;
  -- edible fraction of crop:&lt;br /&gt;
  * fao_usda.`Multiplier` * 0.01*(100 - usda.`Refuse`)&lt;br /&gt;
  -- conversion factor: &amp;quot;hectograms/year/hectare&amp;quot; to &amp;quot;grams/day/acre&amp;quot;:&lt;br /&gt;
  * 0.11079926&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS yield_food_grams_per_day_per_acre,&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
  -- crop land...&lt;br /&gt;
  -- in hectares:&lt;br /&gt;
  a.val&lt;br /&gt;
  -- conversion factor: &amp;quot;hectares&amp;quot; to &amp;quot;acres&amp;quot;:&lt;br /&gt;
  * 2.4710538&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS farmland_acres,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- protein...&lt;br /&gt;
  -- grams per 100g food:&lt;br /&gt;
  usda.`Protein (g)`&lt;br /&gt;
  -- conversion factor:&lt;br /&gt;
  * 0.01&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS protein_fraction_of_food,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- fat...&lt;br /&gt;
  -- grams per 100g food:&lt;br /&gt;
  usda.`Total lipid (fat) (g)`&lt;br /&gt;
  -- conversion factor:&lt;br /&gt;
  * 0.01&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS fat_fraction_of_food,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  -- kalories...&lt;br /&gt;
  -- per 100g food:&lt;br /&gt;
  usda.`Energy (kcal)`&lt;br /&gt;
  -- conversion factor:&lt;br /&gt;
  * 0.01&lt;br /&gt;
  -- result:&lt;br /&gt;
  AS kalories_per_gram_of_food &lt;br /&gt;
 FROM usda&lt;br /&gt;
 JOIN fao_usda USING(`NDB_No`)&lt;br /&gt;
 JOIN (SELECT *, AVG(`Value`) AS val FROM fao WHERE `Element`=&amp;quot;Production&amp;quot;     GROUP BY `Area`,`Item`) p   USING(`Item Code (FAO)`)&lt;br /&gt;
 JOIN (SELECT *, AVG(`Value`) AS val FROM fao WHERE `Element`=&amp;quot;Yield&amp;quot;          GROUP BY `Area`,`Item`) y   USING(`Area`,`Item`)&lt;br /&gt;
 JOIN (SELECT *, AVG(`Value`) AS val FROM fao WHERE `Element`=&amp;quot;Area harvested&amp;quot; GROUP BY `Area`,`Item`) a   USING(`Area`,`Item`)&lt;br /&gt;
 LEFT JOIN region ON p.`Area Code (ISO3)` = region.`ISO3 Code`&lt;br /&gt;
 LEFT JOIN pop    ON p.`Area Code (ISO3)` = pop.`Country Code`&lt;br /&gt;
 LEFT JOIN ghi    ON p.`Area` = ghi.`Country`&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- end of mandatory intro code to run ---&lt;br /&gt;
------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Test out the fao_usda cross-reference table --&lt;br /&gt;
SELECT CHAR(10)||&lt;br /&gt;
       &amp;quot;Crop name: &amp;quot;||`Item`||CHAR(10)||&lt;br /&gt;
       &amp;quot;Food name: &amp;quot;||`Long_Desc`||CHAR(10)||&lt;br /&gt;
       &amp;quot;Harvest (as defined) is &amp;quot;||((100-`Refuse`)*`Multiplier`)||&amp;quot;% food.&amp;quot;||CHAR(10)&lt;br /&gt;
FROM fao&lt;br /&gt;
JOIN fao_usda USING(`Item Code (FAO)`)&lt;br /&gt;
JOIN usda     USING(`NDB_No`)&lt;br /&gt;
WHERE `Area`=&amp;quot;World&amp;quot; AND `Element`=&amp;quot;Production&amp;quot; AND `Year`=&amp;quot;2018&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Test out the fao_usda cross-reference table --&lt;br /&gt;
SELECT CHAR(10)||&lt;br /&gt;
       'FAO  &amp;quot;'||`Item`||'&amp;quot;'||CHAR(10)||&lt;br /&gt;
       '  -'   ||(100-100*`Multiplier`)||'% ='||CHAR(10)||&lt;br /&gt;
       'USDA &amp;quot;'||`Long_Desc`||'&amp;quot;'||CHAR(10)||&lt;br /&gt;
       '  -'   ||`Refuse`||'% &amp;quot;'||`Ref_desc`||'&amp;quot; ='||CHAR(10)||&lt;br /&gt;
       'Edible portion.'||CHAR(10)&lt;br /&gt;
FROM fao&lt;br /&gt;
JOIN fao_usda USING(`Item Code (FAO)`)&lt;br /&gt;
JOIN usda     USING(`NDB_No`)&lt;br /&gt;
WHERE `Area`=&amp;quot;World&amp;quot; AND `Element`=&amp;quot;Production&amp;quot; AND `Year`=&amp;quot;2018&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Test that &amp;quot;World&amp;quot; is the only aggregate --&lt;br /&gt;
--  All the other rows should add up to &amp;quot;World&amp;quot;&lt;br /&gt;
--   Numbers don't have to match perfectly but should be pretty close&lt;br /&gt;
SELECT SUM(production_food_grams_per_day) FROM main WHERE region_name = &amp;quot;World&amp;quot;;&lt;br /&gt;
SELECT SUM(production_food_grams_per_day) FROM main WHERE region_name &amp;lt;&amp;gt; &amp;quot;World&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Global primary food production, per capita, to be shown in nutrition calculator --&lt;br /&gt;
SELECT production_food_grams_per_day / 7.9e9, food_name&lt;br /&gt;
FROM main WHERE region_name=&amp;quot;World&amp;quot;&lt;br /&gt;
ORDER BY production_food_grams_per_day DESC;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Overview, by country --&lt;br /&gt;
SELECT&lt;br /&gt;
 CHAR(10)||&lt;br /&gt;
 region_name||CHAR(10)||&lt;br /&gt;
 PRINTF(&amp;quot; %d kalories/day/person     (primary)&amp;quot;||CHAR(10)||&lt;br /&gt;
        &amp;quot; %d grams protein/day/person  (primary)&amp;quot;||CHAR(10)||&lt;br /&gt;
        &amp;quot; farmland: %.2f acres/person&amp;quot;||CHAR(10),&lt;br /&gt;
        SUM(production_kalories_per_day)      / region_population,&lt;br /&gt;
        SUM(production_protein_grams_per_day) / region_population,&lt;br /&gt;
        SUM(farmland_acres)                   / region_population)||&lt;br /&gt;
 CASE WHEN region_ghi IS NOT NULL AND region_ghi &amp;lt;&amp;gt; ''&lt;br /&gt;
      THEN &amp;quot;&amp;gt;hunger index: &amp;quot;||region_ghi||CHAR(10)&lt;br /&gt;
      ELSE &amp;quot;&amp;quot; END&lt;br /&gt;
FROM main GROUP BY region_name HAVING region_population;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- How much of wheat comes from Ukraine and Russia&lt;br /&gt;
SELECT production_food_grams_per_day / 7.9e9 -- per capita, world population&lt;br /&gt;
FROM main WHERE crop_name=&amp;quot;Wheat&amp;quot; AND region_name=&amp;quot;World&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
SELECT production_food_grams_per_day / 7.9e9 -- per capita, world population&lt;br /&gt;
FROM main WHERE crop_name=&amp;quot;Wheat&amp;quot; AND region_name=&amp;quot;Ukraine&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
SELECT production_food_grams_per_day / 7.9e9 -- per capita, world population&lt;br /&gt;
FROM main WHERE crop_name=&amp;quot;Wheat&amp;quot; AND region_name=&amp;quot;Russian Federation&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----- olam.wiki/Crop_choices -----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--==Best yielding crops for each region==&lt;br /&gt;
--   Generates a wiki table (but you still have to add the {| and |} manually).&lt;br /&gt;
--    Ranked from best (left) to worst (right).&lt;br /&gt;
--     Ranking system: 2000 kalories has the same &amp;quot;value&amp;quot; as 60 grams of protein.&lt;br /&gt;
-- .once -e&lt;br /&gt;
SELECT&lt;br /&gt;
 &amp;quot;|'''&amp;quot;||region_name||&amp;quot;'''&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;|.&amp;lt;br /&amp;gt;.&amp;lt;br /&amp;gt;&amp;amp;nbsp;kalories/day/acre&amp;amp;nbsp;&amp;lt;br /&amp;gt;&amp;amp;nbsp;g&amp;amp;nbsp;protein/day/acre&amp;amp;nbsp;&amp;quot;||CHAR(10)||&lt;br /&gt;
 PRINTF(&amp;quot;|''Status&amp;amp;nbsp;quo&amp;lt;br /&amp;gt;all&amp;amp;nbsp;crops&amp;amp;nbsp;averaged''&amp;lt;br /&amp;gt;%d&amp;lt;br /&amp;gt;%d&amp;quot;,&lt;br /&gt;
  SUM(production_kalories_per_day     )/SUM(farmland_acres),&lt;br /&gt;
  SUM(production_protein_grams_per_day)/SUM(farmland_acres)&lt;br /&gt;
 ) ||CHAR(10)||&lt;br /&gt;
 GROUP_CONCAT(&lt;br /&gt;
  PRINTF(&amp;quot;|'''%s'''&amp;lt;br /&amp;gt;%d&amp;lt;br /&amp;gt;%d&amp;quot;,&lt;br /&gt;
   crop_name, yield_kalories_per_day_per_acre, yield_protein_grams_per_day_per_acre&lt;br /&gt;
  ), CHAR(10)&lt;br /&gt;
 ) ||CHAR(10)||'|-'&lt;br /&gt;
FROM (&lt;br /&gt;
 SELECT * FROM main&lt;br /&gt;
 ORDER BY yield_kalories_per_day_per_acre/2000 + yield_protein_grams_per_day_per_acre/60 DESC&lt;br /&gt;
)&lt;br /&gt;
GROUP BY region_name;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Scenario: Every country grows mostly its best yielding crops --&lt;br /&gt;
--  Farm land is reallocated in a way that favors high-yielding crops.&lt;br /&gt;
--  Each crop's land use will be proportional to the square of its yield (as scored above).&lt;br /&gt;
--  Total farmland remains the same.&lt;br /&gt;
CREATE TEMPORARY TABLE scored AS&lt;br /&gt;
SELECT *, yield_kalories_per_day_per_acre/2000 + yield_protein_grams_per_day_per_acre/60 AS score&lt;br /&gt;
FROM main&lt;br /&gt;
WHERE region_name &amp;lt;&amp;gt; &amp;quot;World&amp;quot; -- &amp;quot;World&amp;quot; is the only aggregated region in the dataset; leave it out&lt;br /&gt;
AND crop_name &amp;lt;&amp;gt; &amp;quot;Mushrooms and truffles&amp;quot;; -- Mushrooms have exceptionally high yields, but this is because they grow without sun - they get their energy from the [[biomass waste]] of other food crops, generally. If you don't omit mushrooms, they end up being like 80% of the whole food supply. But this is not [[Term:viable|]] because there wouldn't be much biomass waste from other crops to grow the mushrooms in. And besides, who would want a diet of mostly mushrooms? Anyway, so mushrooms are removed from here, but are added back below, with the same production/yield/areaharvested as the status quo.&lt;br /&gt;
&lt;br /&gt;
CREATE TEMPORARY TABLE scenario1 AS&lt;br /&gt;
SELECT *, score*score*ratio AS new_acres&lt;br /&gt;
FROM scored JOIN (&lt;br /&gt;
 SELECT region_name, SUM(farmland_acres)/SUM(score*score) AS ratio&lt;br /&gt;
 FROM scored GROUP BY region_name&lt;br /&gt;
) USING(region_name);&lt;br /&gt;
&lt;br /&gt;
INSERT INTO scenario1 SELECT *, 0 AS score, 0 AS ratio, farmland_acres AS new_acres FROM main WHERE crop_name = &amp;quot;Mushrooms and truffles&amp;quot; AND region_name &amp;lt;&amp;gt; &amp;quot;World&amp;quot;; -- see above for explanation&lt;br /&gt;
DROP TABLE scored;&lt;br /&gt;
&lt;br /&gt;
-- Text report, by country&lt;br /&gt;
SELECT PRINTF(&lt;br /&gt;
 &amp;quot;%s&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot; farmland: %.2f acres per person&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot; crops per day per person:&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;  Status quo  : %d kalories, %d grams of protein&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;  New scenario: %d kalories, %d grams of protein&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;      Top crop: %s&amp;quot;||CHAR(10),&lt;br /&gt;
 region_name,&lt;br /&gt;
 SUM(farmland_acres)                                /region_population,&lt;br /&gt;
 SUM(production_kalories_per_day)                   /region_population,&lt;br /&gt;
 SUM(production_protein_grams_per_day)              /region_population,&lt;br /&gt;
 SUM(new_acres*yield_kalories_per_day_per_acre)     /region_population,&lt;br /&gt;
 SUM(new_acres*yield_protein_grams_per_day_per_acre)/region_population&lt;br /&gt;
 + MAX(score)*0, -- tells sqlite to use the name of the top-scoring crop&lt;br /&gt;
 crop_name)&lt;br /&gt;
FROM scenario1&lt;br /&gt;
GROUP BY region_name;&lt;br /&gt;
&lt;br /&gt;
-- Global summary&lt;br /&gt;
SELECT PRINTF(&lt;br /&gt;
 &amp;quot;World&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot; farmland: %.2f acres per person&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot; crops per day per person:&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;  Status quo  : %d kalories, %d grams of protein, %d grams of fat&amp;quot;||CHAR(10)||&lt;br /&gt;
 &amp;quot;  New scenario: %d kalories, %d grams of protein, %d grams of fat&amp;quot;||CHAR(10),&lt;br /&gt;
 SUM(farmland_acres)                                /7.9e9,&lt;br /&gt;
 SUM(production_kalories_per_day)                   /7.9e9,&lt;br /&gt;
 SUM(production_protein_grams_per_day)              /7.9e9,-- divide by&lt;br /&gt;
 SUM(production_fat_grams_per_day)                  /7.9e9,-- world population&lt;br /&gt;
 SUM(new_acres*yield_kalories_per_day_per_acre)     /7.9e9,&lt;br /&gt;
 SUM(new_acres*yield_protein_grams_per_day_per_acre)/7.9e9,&lt;br /&gt;
 SUM(new_acres*yield_fat_grams_per_day_per_acre)    /7.9e9)&lt;br /&gt;
FROM scenario1;&lt;br /&gt;
&lt;br /&gt;
-- Data for generating maps&lt;br /&gt;
--  food-production-primary1-if-crop-choices.png&lt;br /&gt;
SELECT region_m49 ||' '|| (SUM(new_acres*yield_kalories_per_day_per_acre)/SUM(farmland_acres))&lt;br /&gt;
FROM scenario1&lt;br /&gt;
GROUP BY region_m49&lt;br /&gt;
HAVING region_m49; -- use the results as input for: ./number-pairs-to-array-file crop-yields-scenario1&lt;br /&gt;
&lt;br /&gt;
-- Also make a similar map of status quo, for comparison&lt;br /&gt;
--  food-production-primary1.png&lt;br /&gt;
SELECT region_m49 ||' '|| (SUM(production_kalories_per_day)/SUM(farmland_acres))&lt;br /&gt;
FROM scenario1&lt;br /&gt;
GROUP BY region_m49&lt;br /&gt;
HAVING region_m49; -- use the results as input for: ./number-pairs-to-array-file crop-yields&lt;br /&gt;
&lt;br /&gt;
-- Data for nutrition calculator&lt;br /&gt;
SELECT SUM(new_acres*yield_food_grams_per_day_per_acre)/7.9e9 AS f,  food_name&lt;br /&gt;
FROM scenario1&lt;br /&gt;
GROUP BY food_name&lt;br /&gt;
ORDER BY f DESC; -- use the results as input for: make-nutrition0.9-url-from-sql-results.html&lt;br /&gt;
&lt;br /&gt;
-- Done&lt;br /&gt;
DROP TABLE scenario1;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- olam.wiki/Deforestation --&lt;br /&gt;
&lt;br /&gt;
-- Crop land trends --&lt;br /&gt;
SELECT PRINTF(&amp;quot;%s:&amp;quot;||CHAR(9)||&amp;quot;%s%.1f%%/year&amp;quot;,&lt;br /&gt;
              `Area`,&lt;br /&gt;
              CASE WHEN y2020 &amp;gt; y2018 THEN &amp;quot;+&amp;quot; ELSE &amp;quot;&amp;quot; END,&lt;br /&gt;
              100.0 * (y2020 - y2018) / (2020 - 2018) / y2018)&lt;br /&gt;
FROM (SELECT SUM(`Value`) AS y2018, `Area` FROM fao WHERE `Element`=&amp;quot;Area harvested&amp;quot; AND `Year`=&amp;quot;2018&amp;quot; GROUP BY `Area`)&lt;br /&gt;
JOIN (SELECT SUM(`Value`) AS y2020, `Area` FROM fao WHERE `Element`=&amp;quot;Area harvested&amp;quot; AND `Year`=&amp;quot;2020&amp;quot; GROUP BY `Area`) USING (`Area`);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- olam.wiki/Clothing --&lt;br /&gt;
-- General overview of fibre crops --&lt;br /&gt;
--  global production, in grams per day per capita&lt;br /&gt;
--  Note: some of these aren't fibre crops, it's any crops that aren't in the fao_usda cross-reference table&lt;br /&gt;
SELECT AVG(`Value`) -- tonnes/year&lt;br /&gt;
       * 2737.9093  -- convert to grams/day&lt;br /&gt;
       / 7.9e9      -- per capita (divide by world population)&lt;br /&gt;
       AS g,&lt;br /&gt;
       `Item`&lt;br /&gt;
FROM fao WHERE `Area`=&amp;quot;World&amp;quot; AND `Element`=&amp;quot;Production&amp;quot; AND (&lt;br /&gt;
               `Item Code (FAO)` NOT IN (SELECT `Item Code (FAO)` FROM fao_usda)&lt;br /&gt;
            OR `Item`=&amp;quot;Seed cotton&amp;quot;)&lt;br /&gt;
GROUP BY `Item`&lt;br /&gt;
ORDER BY g;&lt;br /&gt;
-- keep in mind that an average t-shirt weighs 142 grams.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- olam.wiki/calc - Data points generated for the calculator --&lt;br /&gt;
&lt;br /&gt;
-- cotton.production, tonnes/year (to be fair, a more accurate number might be found in crops-processed.csv)&lt;br /&gt;
SELECT AVG(`Value`*(1-`Multiplier`))&lt;br /&gt;
FROM fao JOIN fao_usda USING (`Item Code (FAO)`)&lt;br /&gt;
WHERE `Area`=&amp;quot;World&amp;quot; AND `Item`=&amp;quot;Seed cotton&amp;quot; AND `Element`=&amp;quot;Production&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
-- cotton.farmland, hectares&lt;br /&gt;
SELECT AVG(`Value`) FROM fao&lt;br /&gt;
WHERE `Area`=&amp;quot;World&amp;quot; AND `Item`=&amp;quot;Seed cotton&amp;quot; AND `Element`=&amp;quot;Area harvested&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
</feed>