pythongeopandasshapely

unable to assign free hole to a shell error when flattening polygons


I have a list of polygons and I want to group them by the road_name property and flatten the polygons.

I tried the following:

{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"compositeid": "06000_2.5_2.78_5_B3_F0_PT3_T4", "index": 520, "road_name": "Gorge Rd"}, "geometry": {"type": "MultiPolygon", "coordinates": [[[[138.6288, -34.8485], [138.6268, -34.8502], [138.6267, -34.8503], [138.6267, -34.8504], [138.6261, -34.8521], [138.6263, -34.8525], [138.6264, -34.8539], [138.6266, -34.8541], [138.6268, -34.8547], [138.6271, -34.8555], [138.6272, -34.8557], [138.6268, -34.8564], [138.6261, -34.8575], [138.6259, -34.8582], [138.6264, -34.8593], [138.6259, -34.8601], [138.6268, -34.8596], [138.6275, -34.8605], [138.6287, -34.8611], [138.6274, -34.8624], [138.629, -34.8613], [138.63, -34.8621], [138.6312, -34.8627], [138.6313, -34.8628], [138.6318, -34.8629], [138.6332, -34.8631], [138.6334, -34.8632], [138.6354, -34.863], [138.6356, -34.8632], [138.6371, -34.8629], [138.6378, -34.8624], [138.6382, -34.8625], [138.64, -34.8614], [138.6419, -34.8613], [138.6422, -34.8614], [138.6435, -34.8618], [138.6444, -34.8627], [138.6445, -34.8628], [138.6445, -34.8629], [138.6455, -34.8637], [138.6466, -34.864], [138.647, -34.8643], [138.6473, -34.8647], [138.6472, -34.866], [138.6473, -34.8665], [138.6477, -34.8673], [138.6476, -34.8683], [138.6477, -34.8691], [138.6479, -34.8701], [138.6479, -34.8708], [138.6481, -34.8719], [138.647, -34.8733], [138.6469, -34.8737], [138.6466, -34.874], [138.6447, -34.8755], [138.6445, -34.8772], [138.6445, -34.8773], [138.6444, -34.8776], [138.6435, -34.8791], [138.6433, -34.88], [138.6444, -34.8807], [138.6444, -34.8808], [138.6444, -34.8809], [138.6444, -34.881], [138.6443, -34.8809], [138.6422, -34.8814], [138.6418, -34.8812], [138.6414, -34.8809], [138.6412, -34.8798], [138.64, -34.8794], [138.6398, -34.8792], [138.6378, -34.8792], [138.6376, -34.8792], [138.6366, -34.8791], [138.6359, -34.8788], [138.6356, -34.8788], [138.6336, -34.8789], [138.6334, -34.8788], [138.6316, -34.8791], [138.6312, -34.8791], [138.6298, -34.8809], [138.629, -34.8814], [138.6275, -34.8827], [138.6268, -34.8835], [138.6265, -34.8845], [138.6264, -34.8848], [138.626, -34.8862], [138.6258, -34.8871], [138.626, -34.888], [138.6261, -34.8887], [138.6265, -34.8898], [138.6254, -34.8911], [138.6268, -34.89], [138.6285, -34.8903], [138.6286, -34.8916], [138.6274, -34.893], [138.629, -34.8924], [138.63, -34.8927], [138.6312, -34.8934], [138.6296, -34.8948], [138.6291, -34.8952], [138.631, -34.8955], [138.6312, -34.8957], [138.6315, -34.8968], [138.6314, -34.897], [138.6312, -34.8973], [138.6295, -34.8988], [138.629, -34.8993], [138.6274, -34.9006], [138.6275, -34.9019], [138.6275, -34.9024], [138.627, -34.9041], [138.6269, -34.9042], [138.6268, -34.9043], [138.6255, -34.906], [138.6246, -34.9076], [138.6245, -34.9078], [138.6245, -34.908], [138.6246, -34.9092], [138.6248, -34.9095], [138.6249, -34.9096], [138.6246, -34.9099], [138.6242, -34.91], [138.6225, -34.9114], [138.6224, -34.9114], [138.6223, -34.9115], [138.6215, -34.9132], [138.6212, -34.9142], [138.6219, -34.915], [138.6217, -34.9156], [138.6225, -34.9167], [138.6232, -34.9162], [138.6246, -34.9153], [138.6257, -34.916], [138.6261, -34.9168], [138.6266, -34.9171], [138.6268, -34.9172], [138.6284, -34.9173], [138.629, -34.9172], [138.6306, -34.9174], [138.6312, -34.9178], [138.6326, -34.9175], [138.6334, -34.9182], [138.6339, -34.9182], [138.6356, -34.9179], [138.6365, -34.9179], [138.6374, -34.9186], [138.6377, -34.9187], [138.6378, -34.9188], [138.638, -34.9186], [138.638, -34.9185], [138.6387, -34.9168], [138.64, -34.9165], [138.6408, -34.9162], [138.6422, -34.9158], [138.6439, -34.915], [138.6443, -34.9133], [138.6443, -34.9132], [138.6444, -34.9132], [138.6444, -34.9132], [138.6445, -34.9132], [138.6449, -34.9146], [138.6446, -34.915], [138.6449, -34.9164], [138.6466, -34.9165], [138.6469, -34.9166], [138.6488, -34.9167], [138.6504, -34.9155], [138.6498, -34.9168], [138.6488, -34.9175], [138.6475, -34.9179], [138.6466, -34.9181], [138.6459, -34.9186], [138.6444, -34.9191], [138.6436, -34.9193], [138.6422, -34.9197], [138.6408, -34.9198], [138.64, -34.9196], [138.6389, -34.9204], [138.6391, -34.9212], [138.6396, -34.9222], [138.6384, -34.9235], [138.64, -34.9224], [138.6417, -34.9226], [138.6422, -34.9227], [138.6438, -34.9227], [138.6444, -34.9227], [138.6454, -34.9232], [138.6466, -34.9237], [138.6469, -34.9238], [138.6488, -34.924], [138.6489, -34.9239], [138.651, -34.9236], [138.6529, -34.9222], [138.6531, -34.9222], [138.6532, -34.9222], [138.6533, -34.9222], [138.6537, -34.9236], [138.6541, -34.924], [138.6544, -34.9248], [138.6553, -34.925], [138.656, -34.9253], [138.6575, -34.9254], [138.6579, -34.9255], [138.6591, -34.9258], [138.6578, -34.9274], [138.6597, -34.926], [138.6618, -34.926], [138.6619, -34.926], [138.6626, -34.9258], [138.6641, -34.9255], [138.6644, -34.9256], [138.6648, -34.9258], [138.6651, -34.9268], [138.665, -34.9276], [138.6653, -34.9284], [138.6657, -34.9294], [138.6658, -34.9298], [138.6662, -34.9312], [138.6662, -34.9313], [138.6663, -34.933], [138.6649, -34.9342], [138.6663, -34.933], [138.6677, -34.9336], [138.668, -34.9348], [138.6678, -34.9354], [138.6676, -34.9366], [138.6663, -34.9383], [138.666, -34.9384], [138.6647, -34.9397], [138.6663, -34.9385], [138.6685, -34.9384], [138.6685, -34.9395], [138.6687, -34.9384], [138.6707, -34.937], [138.6728, -34.9366], [138.6727, -34.9349], [138.6707, -34.9351], [138.6706, -34.9349], [138.6706, -34.9348], [138.67, -34.9336], [138.6702, -34.933], [138.6707, -34.9319], [138.6708, -34.9312], [138.6708, -34.9311], [138.6707, -34.9308], [138.6702, -34.9298], [138.67, -34.9294], [138.6707, -34.9284], [138.6725, -34.9279], [138.6729, -34.9277], [138.675, -34.9277], [138.6751, -34.9277], [138.6765, -34.9282], [138.6773, -34.9284], [138.6781, -34.9276], [138.6795, -34.9264], [138.6803, -34.9258], [138.6816, -34.9251], [138.6828, -34.9249], [138.6838, -34.9246], [138.6851, -34.924], [138.6856, -34.9225], [138.6859, -34.9222], [138.686, -34.922], [138.6866, -34.9218], [138.6882, -34.9207], [138.6898, -34.9204], [138.6896, -34.9193], [138.6882, -34.9187], [138.6882, -34.9187], [138.6882, -34.9186], [138.6876, -34.9174], [138.6873, -34.9168], [138.6882, -34.9154], [138.6896, -34.9157], [138.6904, -34.9162], [138.6921, -34.9154], [138.6926, -34.9153], [138.6928, -34.915], [138.6927, -34.9149], [138.6926, -34.9147], [138.6916, -34.914], [138.6914, -34.9132], [138.6908, -34.9129], [138.6904, -34.9121], [138.69, -34.9117], [138.69, -34.9114], [138.6904, -34.911], [138.6915, -34.9096], [138.6926, -34.9085], [138.6933, -34.9078], [138.6948, -34.9063], [138.6963, -34.9066], [138.697, -34.9066], [138.6981, -34.9069], [138.6992, -34.9074], [138.7004, -34.9068], [138.7002, -34.9078], [138.701, -34.9081], [138.7014, -34.9084], [138.7024, -34.9088], [138.7036, -34.9094], [138.7054, -34.9078], [138.7058, -34.9073], [138.7064, -34.906], [138.7061, -34.9057], [138.7058, -34.9053], [138.7047, -34.9051], [138.7045, -34.9042], [138.7047, -34.9033], [138.7049, -34.9024], [138.7041, -34.902], [138.7036, -34.9011], [138.7032, -34.901], [138.7029, -34.9006], [138.7036, -34.8997], [138.7039, -34.8988], [138.7037, -34.8987], [138.7036, -34.8986], [138.7023, -34.8981], [138.7014, -34.8975], [138.7006, -34.8977], [138.7005, -34.897], [138.7014, -34.8963], [138.7021, -34.8952], [138.7036, -34.894], [138.7043, -34.8934], [138.7058, -34.8918], [138.7059, -34.8916], [138.7061, -34.8914], [138.7069, -34.8898], [138.708, -34.889], [138.7089, -34.889], [138.7102, -34.8891], [138.7114, -34.888], [138.7109, -34.8874], [138.7102, -34.8864], [138.71, -34.8864], [138.7098, -34.8862], [138.7083, -34.886], [138.708, -34.8858], [138.7069, -34.8853], [138.7063, -34.8845], [138.7077, -34.8828], [138.7079, -34.8827], [138.708, -34.8824], [138.7086, -34.8809], [138.7102, -34.8801], [138.711, -34.8791], [138.7117, -34.8778], [138.7118, -34.8773], [138.7123, -34.8768], [138.7145, -34.8755], [138.7145, -34.8755], [138.7145, -34.8755], [138.7145, -34.8754], [138.7147, -34.8737], [138.7167, -34.8726], [138.7188, -34.872], [138.7189, -34.8719], [138.719, -34.8719], [138.719, -34.8718], [138.7189, -34.8716], [138.7182, -34.8707], [138.7182, -34.8701], [138.7185, -34.8686], [138.7186, -34.8683], [138.7189, -34.8673], [138.7203, -34.8672], [138.7211, -34.8666], [138.7213, -34.8665], [138.7215, -34.8661], [138.722, -34.8647], [138.7233, -34.8638], [138.7245, -34.8637], [138.7255, -34.8637], [138.7261, -34.8629], [138.7258, -34.8626], [138.7255, -34.8624], [138.724, -34.8623], [138.7233, -34.8614], [138.7231, -34.8613], [138.723, -34.8611], [138.7221, -34.8602], [138.722, -34.8593], [138.7216, -34.8589], [138.7211, -34.8585], [138.7201, -34.8583], [138.7197, -34.8575], [138.7193, -34.8572], [138.7189, -34.8569], [138.7178, -34.8566], [138.7167, -34.8564], [138.7159, -34.8564], [138.7145, -34.8561], [138.7136, -34.8564], [138.7123, -34.8568], [138.7114, -34.8564], [138.7114, -34.8557], [138.7119, -34.8542], [138.7102, -34.8539], [138.71, -34.854], [138.7098, -34.8539], [138.7102, -34.8532], [138.7112, -34.8521], [138.7108, -34.8515], [138.7102, -34.8511], [138.7098, -34.8506], [138.7095, -34.8503], [138.7095, -34.849], [138.7094, -34.8485], [138.7092, -34.8475], [138.7087, -34.8467], [138.7086, -34.8462], [138.7083, -34.8449], [138.7102, -34.8439], [138.711, -34.8431], [138.7113, -34.8421], [138.7112, -34.8413], [138.711, -34.8406], [138.7114, -34.8395], [138.7116, -34.8383], [138.7115, -34.8377], [138.711, -34.837], [138.7102, -34.8363], [138.7099, -34.8361], [138.7098, -34.8359], [138.7095, -34.8347], [138.7091, -34.8341], [138.7102, -34.8337], [138.7106, -34.8337], [138.711, -34.8341], [138.7106, -34.8355], [138.7123, -34.8348], [138.7133, -34.8351], [138.7141, -34.8359], [138.7131, -34.8371], [138.7145, -34.8376], [138.7154, -34.8359], [138.7167, -34.8345], [138.7181, -34.8348], [138.7189, -34.8345], [138.7207, -34.8341], [138.7211, -34.834], [138.7231, -34.8323], [138.7228, -34.8309], [138.7228, -34.8305], [138.7222, -34.8296], [138.7219, -34.8287], [138.7221, -34.8279], [138.7219, -34.8269], [138.7217, -34.8264], [138.7213, -34.8251], [138.7229, -34.8236], [138.7211, -34.8247], [138.7205, -34.8238], [138.7203, -34.8233], [138.7203, -34.8222], [138.7202, -34.8215], [138.7199, -34.8207], [138.7191, -34.8197], [138.7211, -34.8179], [138.7189, -34.8186], [138.7186, -34.8197], [138.7174, -34.8209], [138.7168, -34.8215], [138.7173, -34.8228], [138.7173, -34.8233], [138.7172, -34.8247], [138.7171, -34.8251], [138.7173, -34.8264], [138.7173, -34.8269], [138.7168, -34.8286], [138.7169, -34.8287], [138.7167, -34.8288], [138.7167, -34.8288], [138.7145, -34.8291], [138.7133, -34.8305], [138.7123, -34.8309], [138.7119, -34.8308], [138.7102, -34.8309], [138.7096, -34.831], [138.708, -34.8309], [138.7073, -34.831], [138.7058, -34.831], [138.7051, -34.8311], [138.7036, -34.8315], [138.7022, -34.8316], [138.7014, -34.8317], [138.7005, -34.8312], [138.6992, -34.8305], [138.6992, -34.8305], [138.6992, -34.8305], [138.6989, -34.8289], [138.6987, -34.8287], [138.6989, -34.8271], [138.699, -34.8269], [138.6991, -34.8252], [138.6991, -34.8251], [138.6992, -34.825], [138.6993, -34.825], [138.7014, -34.8247], [138.7021, -34.8245], [138.7035, -34.8251], [138.7035, -34.8251], [138.7036, -34.8251], [138.7036, -34.8251], [138.7058, -34.8235], [138.7075, -34.8233], [138.7064, -34.8228], [138.7073, -34.8215], [138.708, -34.8207], [138.7086, -34.8197], [138.7085, -34.8193], [138.708, -34.8185], [138.7076, -34.8182], [138.7075, -34.8179], [138.7078, -34.8162], [138.7078, -34.8161], [138.7077, -34.8145], [138.7058, -34.8146], [138.7047, -34.8152], [138.7036, -34.8148], [138.703, -34.8161], [138.7031, -34.8165], [138.703, -34.8179], [138.7014, -34.8192], [138.7004, -34.8187], [138.6992, -34.8181], [138.699, -34.818], [138.699, -34.8179], [138.6989, -34.8163], [138.6989, -34.8161], [138.698, -34.8153], [138.697, -34.8148], [138.6965, -34.8147], [138.6965, -34.8143], [138.6954, -34.8138], [138.6963, -34.8125], [138.697, -34.8117], [138.6983, -34.8114], [138.6992, -34.8112], [138.701, -34.8107], [138.7, -34.8101], [138.7002, -34.8089], [138.7, -34.8082], [138.6992, -34.8079], [138.6986, -34.8076], [138.697, -34.8077], [138.6948, -34.8089], [138.6948, -34.8089], [138.6948, -34.8089], [138.6926, -34.8099], [138.6915, -34.8107], [138.6915, -34.8116], [138.6912, -34.8125], [138.6912, -34.8137], [138.6914, -34.8143], [138.6911, -34.8156], [138.6907, -34.8161], [138.6904, -34.8175], [138.69, -34.8164], [138.6898, -34.8161], [138.6894, -34.8151], [138.6882, -34.8144], [138.6881, -34.8144], [138.6881, -34.8143], [138.6882, -34.814], [138.6886, -34.8125], [138.6886, -34.8122], [138.6882, -34.8119], [138.6875, -34.8113], [138.6867, -34.8107], [138.6866, -34.8102], [138.6861, -34.8089], [138.6861, -34.8089], [138.6865, -34.8071], [138.6866, -34.8066], [138.686, -34.8069], [138.6844, -34.8071], [138.6855, -34.8075], [138.686, -34.8089], [138.686, -34.809], [138.6856, -34.8107], [138.6848, -34.8117], [138.6841, -34.8125], [138.6838, -34.8131], [138.6835, -34.8143], [138.6818, -34.816], [138.6838, -34.8152], [138.6843, -34.8158], [138.6844, -34.8161], [138.6838, -34.8165], [138.6824, -34.8179], [138.6821, -34.8193], [138.6821, -34.8197], [138.682, -34.8213], [138.6819, -34.8215], [138.6816, -34.8218], [138.6799, -34.8233], [138.6802, -34.8245], [138.6805, -34.8251], [138.6805, -34.826], [138.6813, -34.8269], [138.6795, -34.8282], [138.679, -34.8287], [138.6788, -34.8292], [138.6795, -34.8292], [138.6807, -34.8295], [138.6816, -34.8299], [138.6819, -34.8303], [138.6819, -34.8305], [138.6816, -34.8321], [138.6816, -34.8323], [138.6795, -34.8336], [138.6778, -34.8341], [138.6773, -34.8342], [138.6756, -34.8359], [138.6751, -34.8363], [138.6737, -34.837], [138.6735, -34.8359], [138.6751, -34.8347], [138.6765, -34.8341], [138.6755, -34.8338], [138.6751, -34.8337], [138.6733, -34.8337], [138.6729, -34.8337], [138.6718, -34.8341], [138.6714, -34.8353], [138.6715, -34.8359], [138.6707, -34.8361], [138.6705, -34.8361], [138.6685, -34.8364], [138.668, -34.8363], [138.6663, -34.8359], [138.6662, -34.8359], [138.6653, -34.8359], [138.6642, -34.8358], [138.6641, -34.8351], [138.6637, -34.8344], [138.6639, -34.8341], [138.6635, -34.8328], [138.6627, -34.8323], [138.6623, -34.8319], [138.662, -34.8305], [138.662, -34.8304], [138.6619, -34.8298], [138.6618, -34.8305], [138.6616, -34.8307], [138.661, -34.8323], [138.6597, -34.8329], [138.6591, -34.8328], [138.6575, -34.8333], [138.6562, -34.8334], [138.6553, -34.8334], [138.654, -34.8334], [138.6531, -34.8332], [138.651, -34.834], [138.651, -34.8327], [138.6509, -34.8341], [138.6506, -34.8343], [138.649, -34.8359], [138.6488, -34.8377], [138.6488, -34.8377], [138.6495, -34.8389], [138.6497, -34.8395], [138.6492, -34.8409], [138.6502, -34.8413], [138.6488, -34.8416], [138.6484, -34.8416], [138.6484, -34.8413], [138.6479, -34.8402], [138.6466, -34.84], [138.645, -34.8408], [138.6444, -34.841], [138.6437, -34.8413], [138.6442, -34.8415], [138.6441, -34.8431], [138.6429, -34.8443], [138.6444, -34.8441], [138.6446, -34.8447], [138.645, -34.8449], [138.646, -34.8453], [138.6466, -34.8455], [138.6478, -34.8456], [138.648, -34.8467], [138.6479, -34.8474], [138.648, -34.8485], [138.6466, -34.8498], [138.6449, -34.8498], [138.6444, -34.8496], [138.6426, -34.8503], [138.6422, -34.8505], [138.6401, -34.852], [138.64, -34.8519], [138.6398, -34.8504], [138.6398, -34.8503], [138.6395, -34.8489], [138.6378, -34.8493], [138.637, -34.8492], [138.6356, -34.8488], [138.635, -34.849], [138.6334, -34.849], [138.6326, -34.8491], [138.6312, -34.849], [138.6302, -34.8493], [138.6296, -34.8485], [138.6302, -34.8475], [138.629, -34.8471], [138.6288, -34.8485]], [[138.6575, -34.8395], [138.6575, -34.8395], [138.6568, -34.8383], [138.6566, -34.8377], [138.6575, -34.837], [138.6586, -34.8368], [138.6597, -34.8371], [138.6608, -34.8368], [138.6605, -34.8377], [138.6597, -34.8388], [138.6577, -34.8395], [138.6575, -34.8395], [138.6575, -34.8395]], [[138.6799, -34.8553], [138.6796, -34.8539], [138.6795, -34.8538], [138.6796, -34.8521], [138.6797, -34.8519], [138.6797, -34.8503], [138.6816, -34.8493], [138.6826, -34.8485], [138.6822, -34.848], [138.6816, -34.8468], [138.6816, -34.8467], [138.6816, -34.8467], [138.6816, -34.846], [138.6818, -34.8449], [138.6818, -34.8447], [138.6816, -34.8447], [138.6811, -34.8435], [138.6805, -34.8431], [138.6805, -34.8423], [138.6804, -34.8413], [138.6816, -34.8402], [138.6826, -34.8395], [138.6838, -34.8388], [138.6846, -34.8389], [138.686, -34.8392], [138.6862, -34.8394], [138.6864, -34.8395], [138.6864, -34.841], [138.6882, -34.8405], [138.6898, -34.8395], [138.6904, -34.8392], [138.6907, -34.8393], [138.6926, -34.8393], [138.693, -34.8392], [138.6948, -34.8388], [138.696, -34.8377], [138.697, -34.8371], [138.6987, -34.8363], [138.6992, -34.8363], [138.6996, -34.8359], [138.7008, -34.8346], [138.7013, -34.8341], [138.7014, -34.8339], [138.7016, -34.8339], [138.7036, -34.834], [138.7036, -34.834], [138.7036, -34.8341], [138.7043, -34.8353], [138.7041, -34.8359], [138.704, -34.8374], [138.704, -34.8377], [138.7039, -34.8392], [138.7039, -34.8395], [138.7036, -34.8397], [138.7026, -34.8403], [138.7014, -34.841], [138.7001, -34.8406], [138.6992, -34.8402], [138.698, -34.8413], [138.697, -34.842], [138.6953, -34.8431], [138.696, -34.8439], [138.6962, -34.8449], [138.6964, -34.8454], [138.697, -34.846], [138.6974, -34.8464], [138.6977, -34.8467], [138.697, -34.8472], [138.6951, -34.8485], [138.6948, -34.8485], [138.6947, -34.8485], [138.6946, -34.8485], [138.6937, -34.8476], [138.6926, -34.847], [138.6925, -34.8485], [138.6925, -34.8486], [138.6925, -34.8503], [138.6925, -34.8504], [138.6926, -34.8521], [138.6926, -34.8521], [138.6926, -34.8525], [138.6929, -34.8536], [138.6929, -34.8539], [138.6926, -34.8541], [138.6907, -34.8557], [138.6904, -34.8558], [138.6902, -34.8558], [138.6894, -34.8557], [138.6884, -34.8556], [138.6882, -34.8555], [138.6865, -34.8553], [138.686, -34.8552], [138.6845, -34.8551], [138.6838, -34.8551], [138.6822, -34.8552], [138.6816, -34.8552], [138.6799, -34.8553]], [[138.6281, -34.914], [138.6287, -34.9132], [138.629, -34.9128], [138.6307, -34.9114], [138.6312, -34.911], [138.6334, -34.9097], [138.6334, -34.9097], [138.6338, -34.9111], [138.6345, -34.9114], [138.6334, -34.9119], [138.6318, -34.9127], [138.6312, -34.9129], [138.6308, -34.9132], [138.629, -34.9139], [138.6281, -34.914]], [[138.6902, -34.908], [138.6903, -34.9078], [138.6904, -34.9077], [138.6906, -34.9077], [138.6907, -34.9078], [138.6904, -34.908], [138.6902, -34.908]], [[138.668, -34.8417], [138.6679, -34.8413], [138.6685, -34.8409], [138.6698, -34.8395], [138.6707, -34.839], [138.6719, -34.8385], [138.6729, -34.8387], [138.6732, -34.8393], [138.6731, -34.8395], [138.6729, -34.84], [138.6718, -34.8404], [138.6707, -34.8405], [138.6693, -34.8413], [138.6685, -34.8418], [138.668, -34.8417]]], [[[138.5991, -34.927], [138.6005, -34.9263], [138.6015, -34.9268], [138.6027, -34.927], [138.6031, -34.9273], [138.6042, -34.9276], [138.6047, -34.9278], [138.6049, -34.928], [138.6065, -34.9281], [138.6071, -34.9281], [138.6091, -34.9276], [138.6093, -34.9276], [138.6113, -34.9258], [138.6115, -34.9257], [138.6134, -34.924], [138.6137, -34.9236], [138.6146, -34.9233], [138.6159, -34.9228], [138.6163, -34.9222], [138.6163, -34.9219], [138.6159, -34.9204], [138.6161, -34.9202], [138.616, -34.9186], [138.616, -34.9185], [138.6159, -34.9186], [138.6157, -34.9186], [138.6137, -34.9192], [138.6136, -34.9187], [138.6131, -34.9186], [138.6122, -34.918], [138.6115, -34.9172], [138.6113, -34.917], [138.6111, -34.9168], [138.6114, -34.9151], [138.6093, -34.9159], [138.6085, -34.9157], [138.6071, -34.9152], [138.6067, -34.9154], [138.6065, -34.915], [138.6053, -34.9147], [138.6056, -34.9132], [138.6058, -34.9125], [138.6049, -34.9124], [138.6038, -34.9124], [138.6027, -34.9121], [138.6017, -34.9132], [138.601, -34.9146], [138.6013, -34.915], [138.6005, -34.9168], [138.6027, -34.9155], [138.6041, -34.9157], [138.6038, -34.9168], [138.6027, -34.9178], [138.6018, -34.9186], [138.6012, -34.9199], [138.6009, -34.9204], [138.6005, -34.9214], [138.599, -34.9222], [138.6001, -34.9226], [138.5994, -34.924], [138.5996, -34.9248], [138.6001, -34.9258], [138.5991, -34.927]]], [[[138.6432, -34.8368], [138.6444, -34.8375], [138.645, -34.8372], [138.6466, -34.8365], [138.6479, -34.8359], [138.647, -34.8355], [138.6466, -34.8354], [138.6455, -34.8349], [138.6444, -34.8348], [138.6428, -34.8359], [138.6432, -34.8368]]], [[[138.6334, -34.8683], [138.6334, -34.8695], [138.6335, -34.8683], [138.6335, -34.8682], [138.6334, -34.8665], [138.6334, -34.8664], [138.6334, -34.8665], [138.6334, -34.8665], [138.6334, -34.8665], [138.6333, -34.8683], [138.6334, -34.8683]]], [[[138.7081, -34.816], [138.7102, -34.8154], [138.7112, -34.8143], [138.7123, -34.8125], [138.7118, -34.8125], [138.7105, -34.8122], [138.7102, -34.8124], [138.71, -34.8125], [138.7095, -34.813], [138.7083, -34.8143], [138.7081, -34.816]]], [[[138.5954, -34.9228], [138.5961, -34.9226], [138.5978, -34.9222], [138.5983, -34.9218], [138.5995, -34.9204], [138.5989, -34.92], [138.5983, -34.9192], [138.5978, -34.9204], [138.5961, -34.9218], [138.5954, -34.9222], [138.5954, -34.9228]]], [[[138.6465, -34.8305], [138.6466, -34.8305], [138.6466, -34.8305], [138.6466, -34.8305], [138.6466, -34.8304], [138.6465, -34.8305], [138.6465, -34.8305]]], [[[138.7057, -34.7999], [138.7058, -34.8001], [138.7058, -34.7999], [138.7058, -34.7999], [138.7058, -34.7999], [138.7057, -34.7999], [138.7057, -34.7999]]], [[[138.7182, -34.8167], [138.7189, -34.8177], [138.7193, -34.8161], [138.7203, -34.815], [138.7189, -34.8156], [138.7178, -34.8161], [138.7182, -34.8167]]], [[[138.6023, -34.91], [138.6027, -34.9098], [138.6028, -34.9096], [138.6035, -34.909], [138.6027, -34.9096], [138.6025, -34.9096], [138.6023, -34.91]]]]}}]}

import geopandas as gpd

gdf = gpd.GeoDataFrame.from_features(polygons_list['features'])
gdf.geometry.unary_union

This gives me the following error: TopologyException: unable to assign free hole to a shell at 138.63339999999999 -34.869500000000002

Any ideas in how I can fix this or workaround?


Solution

  • I fixed a similar problem by ensuring the geometries are valid. In PostGIS I used ST_MakeValid(). In geopandas, geometry.buffer(0) might help.

    Here is an example for including buffer in Geopandas:

    gdf['geo_col'] = gdf['geo_col'] \
            .to_crs('+proj=cea') \
            .buffer(2) \
            .to_crs('epsg:4326')