<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to calculate spatial GINI coefficient in Spatial Statistics Questions</title>
    <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341701#M1129</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.596375&lt;/P&gt;&lt;P&gt;and this...&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="171408" alt="image.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/171408_image.png" style="width: 620px; height: 430px;" /&gt;&lt;/P&gt;&lt;P&gt;from this&lt;/P&gt;&lt;P&gt;#&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# coding: utf-8
import numpy as np
from matplotlib import pyplot as plt
from numpy import trapz

GDP = 6532000000000
factors = np.array([0.49,0.59,0.69,0.79,1.89,2.0,5.0,10.0,18.0,60.0])
prep = factors*GDP/100
A, B, C, D, E, F, G, H, I, J = prep
q_s = prep.reshape((5,2))
Q1, Q2, Q3, Q4, Q5 = np.sum(q_s,axis=1)
Qs = np.sum(q_s,axis=1)
# Calculate the percent of total income in each quintile
Ts = ((100.*Qs)/GDP)/100.
TR = np.sum(Ts)
# Calculate the cumulative percentage of household income
y = np.cumsum(Ts)
# The y values. Cumulative percentage of incomes
# The perfect equality y values. Cumulative percentage of incomes.
y_pe = np.linspace(0.0,1.0,len(y))
# Compute the area using the composite trapezoidal rule.
area_lorenz = np.trapz(y, dx=5)
# Calculate the area below the perfect equality line.
area_perfect = np.trapz(y_pe, dx=5)
# Seems to work fine until here.
# Manually calculated Gini using the values given for the areas above
# turns out at .58 which seems reasonable?
Gini = (area_perfect - area_lorenz)/area_perfect
#
print(Gini)
plt.plot(y,label='lorenz')
plt.plot(y_pe,label='perfect_equality')
plt.legend()
plt.show()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And no guarantee it is even remotely correct. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:08:07 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-11T16:08:07Z</dc:date>
    <item>
      <title>How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341698#M1126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am interested in calculating an index of agricultural land inequality for Brazil. I'm thinking that a GINI coefficient would be a good approach given traditional uses of GINI, but I'm open to other approaches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data set for all municipalities in Brazil that consists of four columns for each municipality (rows): 1) number of family farms, 2) area occupied by small farm land use; 3) number of non-family farms; 4) area occupied by non-family farms. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's I'm really hoping to attain is a value that can represent the relations between percent area occupied by non-family farms in comparison with family farms. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can obtain the total area of the municipality from municipality shape file, but I don't think it makes sense to have a simple ratio of non-family farm area/municipality area as there will be various other forms of land use. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Any suggestions on how to calculate a spatial GINI using this data set, or a different statistic that makes more sense would be greatly appreciated&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 16:59:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341698#M1126</guid>
      <dc:creator>DavidMeek</dc:creator>
      <dc:date>2016-01-20T16:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341699#M1127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;background and formula for those on the social side of gis&lt;/P&gt;&lt;P&gt;&lt;A href="https://en.m.wikipedia.org/wiki/Gini_coefficient" title="https://en.m.wikipedia.org/wiki/Gini_coefficient"&gt;Gini coefficient - Wikipedia, the free encyclopedia&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Dr Google for country specifics and its application.&amp;nbsp; In short there are no built-in tools, for direct calculation, but given the data and existing tools, it can probably be calculated &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 22:00:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341699#M1127</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-20T22:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341700#M1128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is nothing a little Python can do, and with numpy ace Dan in this thread you're have way there. I came across this thread which has a lot of potential (using &lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;numpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #000000;"&gt;trapz)&lt;/SPAN&gt;&lt;/CODE&gt;:&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/31416664/python-gini-coefficient-calculation-using-numpy" title="http://stackoverflow.com/questions/31416664/python-gini-coefficient-calculation-using-numpy"&gt;http://stackoverflow.com/questions/31416664/python-gini-coefficient-calculation-using-numpy&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Gini coefficient was originally developed to measure inequality, using cumulative share of people from lowest to highest incomes (x-axis) vs Cumulative share of income (y-axis). How would you define the values for both axis in your case? Cumulative share of non family owned farms vs cumulative share of family owned farms, order by the fraction (family farms / non family farms)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 02:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341700#M1128</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-21T02:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341701#M1129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.596375&lt;/P&gt;&lt;P&gt;and this...&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="171408" alt="image.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/171408_image.png" style="width: 620px; height: 430px;" /&gt;&lt;/P&gt;&lt;P&gt;from this&lt;/P&gt;&lt;P&gt;#&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# coding: utf-8
import numpy as np
from matplotlib import pyplot as plt
from numpy import trapz

GDP = 6532000000000
factors = np.array([0.49,0.59,0.69,0.79,1.89,2.0,5.0,10.0,18.0,60.0])
prep = factors*GDP/100
A, B, C, D, E, F, G, H, I, J = prep
q_s = prep.reshape((5,2))
Q1, Q2, Q3, Q4, Q5 = np.sum(q_s,axis=1)
Qs = np.sum(q_s,axis=1)
# Calculate the percent of total income in each quintile
Ts = ((100.*Qs)/GDP)/100.
TR = np.sum(Ts)
# Calculate the cumulative percentage of household income
y = np.cumsum(Ts)
# The y values. Cumulative percentage of incomes
# The perfect equality y values. Cumulative percentage of incomes.
y_pe = np.linspace(0.0,1.0,len(y))
# Compute the area using the composite trapezoidal rule.
area_lorenz = np.trapz(y, dx=5)
# Calculate the area below the perfect equality line.
area_perfect = np.trapz(y_pe, dx=5)
# Seems to work fine until here.
# Manually calculated Gini using the values given for the areas above
# turns out at .58 which seems reasonable?
Gini = (area_perfect - area_lorenz)/area_perfect
#
print(Gini)
plt.plot(y,label='lorenz')
plt.plot(y_pe,label='perfect_equality')
plt.legend()
plt.show()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And no guarantee it is even remotely correct. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:08:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341701#M1129</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341702#M1130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/7647"&gt;David Meek&lt;/A&gt; , I you have some sample data you could share, this would help to see if the calculation makes sense. Maybe afterwards the relative position of the municipality can be visualized in GIS. Because the result of Gini coefficient is a single value and if you are applying it using data that is normally not used for this calculation, how will you interpret this single value? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 11:51:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341702#M1130</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-21T11:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341703#M1131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see you simplified the code. Looks better this way!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 11:52:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341703#M1131</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-21T11:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341704#M1132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are the input style the same? ie with the coefficients etc?&lt;/P&gt;&lt;P&gt;It can easily be rolled into a function or tool...but as I said, I know nothing about GINI except as an Italian soft drink&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 13:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341704#M1132</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-21T13:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341705#M1133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;​ and @Dan Patterson, many thanks for the starting points and suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached is an excel sheet that shows the data (I translated a little of it from Portuguese to help). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll note that while the GINI was developed for income inequality, it's been used to measure inequality in terms of a variety of other variables, including land through a GIS framework. See this recent article: &lt;A href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0076165" title="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0076165"&gt;PLOS ONE: The Land Gini Coefficient and Its Application for Land Use Structure Analysis in China&lt;/A&gt; (attached is the .pdf). So it seems definitely possible, but A) I'm not sure whether the data I have are appropriate, and B) I'm not a statistical whiz, so while I can follow a geostats tutorial, decoding the equations is beyond me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, to provide more background, what I'm ultimately seeing to do is to develop a GINI value for each municipality in Brazil, and then have that as an attribute field that I can include as part of a larger OLS/GWR regression analysis. Xander, I might be wrong, but I think that if I have this value for each municipality I can analyze differences in land inequality between municipalities.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, it's possible the GINI isn't the right stat for this, and I'm definitely open to suggestions of other approaches that make sense given these data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 15:40:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341705#M1133</guid>
      <dc:creator>DavidMeek</dc:creator>
      <dc:date>2016-01-21T15:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341706#M1134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok... more to the question... do you know how to use a script? &lt;/P&gt;&lt;P&gt;I just replicated Xander's link in simpler terms but I don't know whether it works for your data... so is the structure of the inputs and outputs what you want for your data?&lt;/P&gt;&lt;P&gt;I will leave interpretation of such things to you...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 15:54:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341706#M1134</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-21T15:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341707#M1135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a very basic understanding of scripts, but sadly, it's been a few years since I've done anything with python. I might have found a source for these data on the GINI directly. Will report back if I proceed with this analysis. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 16:36:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341707#M1135</guid>
      <dc:creator>DavidMeek</dc:creator>
      <dc:date>2016-01-21T16:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341708#M1136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/7647"&gt;David Meek&lt;/A&gt; , thanks for sharing the data and the additional explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is an important point that triggers me; you seek to generate a Gini coefficient value for each municipality. As far as I understand, calculating the Gini coefficient based on all municipalities in Brazil will generate a &lt;SPAN style="text-decoration: underline;"&gt;single&lt;/SPAN&gt; value for Brazil. I believe it is a method for aggregation, but you could calculate the coefficient for all municipalities in each region and visualize the result per region.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another possibility is to determine the relative position of each municipality (the area fraction) on the variation of the fraction in Brazil. This would indicate the "situation" of each single municipality, but this would no longer be a Gini coefficient.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 16:49:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341708#M1136</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-21T16:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate spatial GINI coefficient</title>
      <link>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341709#M1137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I'm getting somewhere...&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/171678_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;The data in you Excel has a mix of 4 levels of data (regions, to municipalities).I added some fields to distinguish them (find attached the adapted Excel). The graph is based on the highest level (level 4, municipalities I guess). This would yield a single Gini coefficient, which can be useful to compare the result to others countries if this coefficient would be available. However, if you want to visualize the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;inequality &lt;/SPAN&gt;distribution you would have to use the fraction (familly farm area over total farm area).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jan 2016 18:10:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/spatial-statistics-questions/how-to-calculate-spatial-gini-coefficient/m-p/341709#M1137</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-21T18:10:19Z</dc:date>
    </item>
  </channel>
</rss>

