Message posté par : Thomas Gratier (thomas.gratier(a)gmail.com)
----------------------------------------
Salut,
Pompage assumé de
https://stackoverflow.com/questions/40385782/make-a-union-of-polygons-in-ge…
-----------------
Code :
import geopandas as gpd
import matplotlib.pyplot as plt
from shapely.ops import cascaded_union
inputfile = '/home/thomasg/ne_10m_admin_0_countries.shp'
gdf = gpd.read_file(inputfile)
# Solution 1
boundary = gpd.GeoSeries(cascaded_union(gdf.geometry))
print(boundary)
boundary.plot(color = 'red')
plt.show()
# Solution 2, en trichant avec dissolve en créant un colonne "bidon"
gdf['new_column'] = 0
gdf_new = gdf.dissolve(by='new_column')
print(gdf_new.geometry)
-----------------
Cordialement
Thomas
----------------------------------------
Le message est situé
https://georezo.net/forum/viewtopic.php?pid=344129#p344129
Pour y répondre : geolibre(a)ml.georezo.net ou reply de votre messagerie
Pour vous désabonner connectez-vous sur le forum puis Profil / Abonnement
--
Association GeoRezo - le portail géomatique
https://georezo.net