1

I have a long list of polygons in the GeoPandas GeoDataFrame (Sample below)

Index   zone_name   value   geometry
0       A            100    POLYGON ((77.47638480859382 13.05584728590942, 77.50519132714851 13.04673679588868, 77.53331120019539 13.03294330911764, 77.51502097802745 12.98436754600364, 77.47269816308585 12.98663777798433, 77.47638480859382 13.05584728590942))
1       C            201    POLYGON ((77.47192161279304 12.98643960066976, 77.51411771875007 12.98451936478889, 77.51547471337904 12.95353196452923, 77.5343411684571 12.93743118939856, 77.52909721093761 12.90406392555974, 77.49609116845704 12.87942997600877, 77.48010313134762 12.88920142757589, 77.4673766604003 12.89796851858703, 77.46896249108886 12.9412878289885, 77.47192161279304 12.98643960066976))
2       D            111    POLYGON ((77.59028213220222 13.06797072753133, 77.58956289392097 13.04330855400157, 77.57270748620613 13.04874693493876, 77.55819381433116 13.04533078511338, 77.54338387780763 13.03927461556928, 77.53252215295402 13.03321829777183, 77.50741463952636 13.04574547711091, 77.4768047609864 13.05556623048057, 77.50593304162601 13.06672433013411, 77.5560040102539 13.08557342240114, 77.59872061639408 13.10051488229898, 77.59028213220222 13.06797072753133))
3       E            400    POLYGON ((77.59929435449226 13.09932169348356, 77.63565397363288 13.10124780755884, 77.63357774072279 13.05372024880592, 77.6273816347657 13.03896385704673, 77.61483378320304 13.03948969171691, 77.6059707460937 13.04023452334728, 77.58955460839843 13.04432401103174, 77.59099125390628 13.06981781828728, 77.59929435449226 13.09932169348356))
4       F            200    POLYGON ((77.6346565981446 13.07858870108154, 77.67549570947267 13.07486997454336, 77.75307035546882 13.05777373953371, 77.75889054589857 13.05204798886958, 77.75990421777351 13.05434903600938, 77.68599570947276 13.00577746936363, 77.68131379418946 13.00356732656461, 77.67628855615226 13.00269524680756, 77.66580367379754 12.99808413747378, 77.66355853753657 13.00116706406973, 77.66303678422537 13.00998421114968, 77.66148506265256 13.01712854882608, 77.64876858239745 13.02138197244171, 77.63277699761966 13.02938687545724, 77.62708509545894 13.03806046465725, 77.63246995263671 13.05067873716547, 77.6346565981446 13.07858870108154))
5       G           1220    POLYGON ((77.75859611230476 13.05283723578525, 77.76608402734382 13.01153573092552, 77.76183126550313 12.98298151260739, 77.76341499047862 12.98754569817084, 77.75684480004884 12.98274266996503, 77.74993128686515 12.98596869425087, 77.73631588464355 12.98843206830092, 77.72012556176753 12.99056088201502, 77.70015868859855 12.99595135539369, 77.68087846093749 13.00251253458571, 77.70016788964847 13.01379460278249, 77.71513410668945 13.02428560625645, 77.75859611230476 13.05283723578525))
6       A             66    POLYGON ((77.51229958730323 13.00368880711788, 77.52639707475282 13.00337166201698, 77.5318164272843 13.00310812883055, 77.5371499491273 13.00285504910085, 77.54118729346374 13.00283848502781, 77.54351408439265 13.00284196344523, 77.54588982563598 13.00283760155986, 77.5480313664018 12.9917606994373, 77.54832459841055 12.98954588341261, 77.54867683901773 12.98687105404877, 77.54938132023199 12.9814585811132, 77.54939146384072 12.98137941548487, 77.54920211815408 12.9812515703913, 77.54890054028988 12.9810481532845, 77.54829872566597 12.98064262540533, 77.54709643752267 12.97983352791941, 77.54608660992369 12.97936273379775, 77.53861670600759 12.97449012019768, 77.53260139756776 12.97056800978524, 77.52777296661714 12.96742311954626, 77.52574940120566 12.9726582498698, 77.52520746766909 12.97405890444639, 77.52466922216992 12.97546641215548, 77.52457212790237 12.9757074498093, 77.52451754579829 12.97586260031614, 77.52447503363479 12.9760331063101, 77.52414807575337 12.97659261146952, 77.52402248301497 12.97685815154211, 77.52388146757472 12.97715309550915, 77.52356792073832 12.97781877963432, 77.52110480832435 12.98303474219691, 77.52050462056079 12.98430400347114, 77.5199054386256 12.98557162475204, 77.51872249745702 12.98807940522174, 77.51842454096055 12.98870822489646, 77.518128931397 12.98933573619113, 77.51753637116532 12.99059010063365, 77.51738190277052 12.99091508424201, 77.51723078713695 12.99123582039588, 77.51692855586987 12.99187533129874, 77.51632409333567 12.99315565493196, 77.516166062632 12.99349125265973, 77.51601373162246 12.99381378228763, 77.5157050462899 12.99446668085412, 77.51539820497609 12.9951166374987, 77.51509136366234 12.99576757250749, 77.51479013822362 12.99640339650134, 77.514489248061 12.99704085230128, 77.51388411497452 12.99832229269489, 77.51363628225901 12.99884711909768, 77.51339012592418 12.99936900423604, 77.5132696461467 12.99962349439434, 77.51315050747372 12.9998753708262, 77.51290954791874 13.00038369647829, 77.51243165212249 13.00140067133999, 77.51202550541734 13.00225887558144, 77.5117010939357 13.00295919851358, 77.51138607018561 13.00366605303291, 77.51169814860201 13.00368125070428, 77.51189254509791 13.00368893477719, 77.51194850438219 13.00369163344001, 77.51200211673358 13.00369073864302, 77.51206636243444 13.00368977288041, 77.51229958730323 13.00368880711788)).
.

I am trying to dissolve the same based on values so that the new dissolve would only happen if the total sum of the value field is <= 500.

So far I have got:

Summary_Data = OVerall_Data.dissolve(by='zone_name', aggfunc='sum')

Is there some parameter that I can add to this, or would there be some other technique.

1

1 Answer 1

1

This might be a multi-step process:

your current code results in a GDF that has the sum of values. You can select the Zones that have a sum less than 500:

Summary_Data = Summary_Data.reset_index() # making the zone_name as a column
Summary_Data  = Summary_Data[Summary_Data['zone_name']< 500]

Now you can extract a list of zones whose sum is less than 500:

small_zones = Summary_Data['zone_name'].unique()

Then you can dissolve only these zones

Summary_Data = OVerall_Data[OVerall_Data['zone_name'].isin(small_zones )]\
    .dissolve(by='zone_name',aggfunc='sum')

and then append them with the selected rest of the data:

result = OVerall_Data[~OVerall_Data['zone_name'].isin(small_zones)]
result = result.append(Summary_Data, ignore_index=True).reset_index(drop=True)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.