No description has been provided for this image

Exercise 1¶

You will make two maps:

  1. Plot your country as the background. Use cx to plot some points (the cities, airports, etc.) below the centroid.
  2. Plot your country as the background. Select with cx all the first administrative divisions above the centroid. Then, use clip to show some lines (rivers, railroads, etc) that cross those divisions.
In [171]:
import geopandas as gpd
countries=gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/World%20Country/World_Countries.shp')
argentina = countries[countries.COUNTRY=='Argentina']
centrales_electricas=gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/Energ%C3%ADa/puntos_de_energia_AD010Point.shp')
In [172]:
argentina.crs
Out[172]:
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
In [173]:
argentina=argentina.to_crs(5343)
In [174]:
argentina.total_bounds
Out[174]:
array([1385481.70808148, 3884871.45452092, 3352642.62786363,
       7581252.17870236])
In [175]:
argentina.centroid
Out[175]:
0
10 POINT (2166252.13 6144387.961)

In [176]:
centrales_electricas=centrales_electricas.to_crs(5343)
In [177]:
base = argentina.plot(facecolor="greenyellow", edgecolor='black', linewidth=0.4, figsize=(10, 10))

centroid_lon = argentina.centroid.iloc[0].x
centroid_lat = argentina.centroid.iloc[0].y
centrales_abajo_centroid = centrales_electricas.cx[:, :centroid_lat]

centrales_abajo_centroid.plot(marker='o', color='red', markersize=15, ax=base)
Out[177]:
<Axes: >
No description has been provided for this image

Segundo apartado

In [178]:
prov = gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/provincias/provinciaPolygon.shp')
ferrovias = gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/Ferroviales/lineas_de_transporte_ferroviario_AN010Line.shp')
In [179]:
prov=prov.to_crs(5343)
ferrovias=ferrovias.to_crs(5343)
In [180]:
base2 = prov.plot(facecolor="greenyellow", edgecolor='black', linewidth=0.4, figsize=(10, 10))
divisions_above_centroid = prov.cx[:, centroid_lat:]
clipped_ferrovias = gpd.clip(gdf=ferrovias, mask=divisions_above_centroid)
clipped_ferrovias.plot(edgecolor='blue', linewidth=0.5, ax=base2)
Out[180]:
<Axes: >
No description has been provided for this image

Exercise 2¶

  1. Create some subset of polygons with your country data at the municipal (or similar level). Use Unary UNION with those polygons, and create a geoDF with the result.

Con ayuda de cx.(o.O) Solo voy a unir el norte con el sur}

  1. Dissolve your municipalities by another higher level administrative level. Plot the result.
  2. If possible, color some areas of your country by aggregating; if not, plot the "median" values in the indicators map.
In [181]:
import geopandas as gpd

provincias=gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/provincias/provinciaPolygon.shp')
In [182]:
provincias.crs
Out[182]:
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
In [183]:
provincias=provincias.to_crs(5343)
In [184]:
provincias.total_bounds
Out[184]:
array([1.38772426e+06, 5.64183001e-01, 4.12249404e+06, 7.58120702e+06])
In [185]:
provincias.plot()
Out[185]:
<Axes: >
No description has been provided for this image

Unary UNION¶

We can combine all these polygons into one:

In [186]:
!pip install shapely
Requirement already satisfied: shapely in /usr/local/lib/python3.11/dist-packages (2.0.7)
Requirement already satisfied: numpy<3,>=1.14 in /usr/local/lib/python3.11/dist-packages (from shapely) (1.26.4)
In [187]:
centroid_lat = provincias.centroid.iloc[0].y
prov_sur=provincias.cx[:,:centroid_lat]
In [188]:
prov_norte = provincias.drop(prov_sur.index)
In [189]:
prov_sur.plot()
Out[189]:
<Axes: >
No description has been provided for this image

Propuesta: Intersecar mis provincias con el border del world countries, para quitar a antartida y malvidas que fastidian

In [190]:
prov_norte.plot()
Out[190]:
<Axes: >
No description has been provided for this image
In [191]:
provincias['region'] = 'norte'
provincias.loc[provincias.cx[:,:centroid_lat].index, 'region'] = 'sur'
provincias.plot(column='region', legend=True)
Out[191]:
<Axes: >
No description has been provided for this image
In [192]:
unidos_norte=gpd.GeoDataFrame(index=[0],data={'ADM':'Norte'},
                 crs=provincias.crs,
                 geometry=[provincias[provincias.region=='norte'].union_all()])

unidos_sur=gpd.GeoDataFrame(index=[0],data={'ADM':'Sur'},
                 crs=provincias.crs,
                 geometry=[provincias[provincias.region=='sur'].union_all()])

unidos_norte_sur = gpd.pd.concat([unidos_norte, unidos_sur], ignore_index=True)
unidos_norte_sur.plot(column='ADM')
Out[192]:
<Axes: >
No description has been provided for this image

DISSOLVE¶

In [193]:
departamentos = gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/departamentos/departamentoPolygon.shp')
departamentos=departamentos.to_crs(5343)
In [194]:
departamentos.head()
Out[194]:
gid objeto fna gna nam in1 fdc sag geometry
0 38 Departamento Departamento Ojo de Agua Departamento Ojo de Agua 86126 Catastro Provinciales IGN POLYGON ((2276075.519 6782525.446, 2276264.373...
1 39 Departamento Departamento Choya Departamento Choya 86063 Catastro Provinciales IGN POLYGON ((2225816.929 6862993.756, 2233663.751...
2 65 Departamento Partido de Lezama Partido Lezama 06466 ARBA - Gerencia de Servicios Catastrales IGN POLYGON ((2784038.593 5957686.537, 2784665.484...
3 102 Departamento Departamento Pilcaniyeu Departamento Pilcaniyeu 62070 IDE Rio Negro IGN POLYGON ((1692055.687 5583574.853, 1692055.041...
4 118 Departamento Comuna 1 Comuna Comuna 1 02007 Direc. de Catastro IGN POLYGON ((2753297.347 6088702.481, 2753313.38 ...
In [195]:
prov.head()
Out[195]:
gid entidad fna gna nam in1 fdc sag geometry
0 1 0.0 Ciudad Autónoma de Buenos Aires Ciudad Autónoma Ciudad Autónoma de Buenos Aires 02 Geografía IGN POLYGON ((2747652.364 6095235.901, 2747750.867...
1 2 0.0 Provincia de San Luis Provincia San Luis 74 Geografía IGN POLYGON ((1968211.939 6465396.366, 1968723.496...
2 3 0.0 Provincia de Santa Fe Provincia Santa Fe 82 Geografía IGN POLYGON ((2581134.497 6854846.203, 2584940.824...
3 4 0.0 Provincia de La Rioja Provincia La Rioja 46 Geografía IGN POLYGON ((1842859.281 6918841.663, 1842839.746...
4 5 0.0 Provincia de Catamarca Provincia Catamarca 10 Geografía IGN POLYGON ((1852441.661 7212670.781, 1852593.364...
In [196]:
departamentos.fdc.unique()
Out[196]:
array(['Catastro Provinciales',
       'ARBA - Gerencia de Servicios Catastrales', 'IDE Rio Negro',
       'Direc. de Catastro', 'SCAR', 'IDE Salta',
       'Direc. Grl. de Inmuebles',
       'Servicio de Catastro e Información Territorial', 'IDE Mendoza',
       'IGN', 'Gerencia de Catastro Pcial.',
       'Direc. Pcial. de Catastro e Inf. Territorial',
       'Direc. de Geodesia y Catastro', 'Direc. Grl. de Catastro',
       'Ministerio de Ecología', 'IDE Tucuman',
       'Direc. Pcial. de Catastro y Cartografía',
       'ATER - Direc. de Catastro', 'IDE Chaco', 'IDE Cordoba',
       'IDE Catamarca', 'Catastro'], dtype=object)
In [197]:
departamentos[~departamentos.is_valid]
Out[197]:
gid objeto fna gna nam in1 fdc sag geometry
6 153 Departamento Departamento Antártida Argentina Departamento Antártida Argentina 94028 SCAR IGN MULTIPOLYGON (((2654168.387 1087347.883, 26349...
510 525 Departamento Departamento Islas del Atlántico Sur Departamento Islas del Atlántico Sur 94021 IGN IGN MULTIPOLYGON (((2441787.736 4227942.649, 24417...
In [198]:
departamentos["geometry"] = departamentos["geometry"].buffer(0)
In [199]:
departamentos.dissolve(by='fdc').plot(facecolor='yellow', edgecolor='black',linewidth=0.2)
Out[199]:
<Axes: >
No description has been provided for this image
In [200]:
Argentina_fdc_diss=departamentos.dissolve(by='fdc')
In [201]:
!pip install fiona
Requirement already satisfied: fiona in /usr/local/lib/python3.11/dist-packages (1.10.1)
Requirement already satisfied: attrs>=19.2.0 in /usr/local/lib/python3.11/dist-packages (from fiona) (25.1.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from fiona) (2025.1.31)
Requirement already satisfied: click~=8.0 in /usr/local/lib/python3.11/dist-packages (from fiona) (8.1.8)
Requirement already satisfied: click-plugins>=1.0 in /usr/local/lib/python3.11/dist-packages (from fiona) (1.1.1)
Requirement already satisfied: cligj>=0.5 in /usr/local/lib/python3.11/dist-packages (from fiona) (0.7.2)
In [202]:
import geopandas as gpd
from  fiona import listlayers

linkWorldMap="https://github.com/CienciaDeDatosEspacial/intro_geodataframe/raw/main/maps/worldMaps.gpkg"
indicators=gpd.read_file(linkWorldMap,layer='indicators')
In [203]:
indicators.head()
Out[203]:
COUNTRY Officialstatename InternetccTLD iso2 iso3 fragility_date fragility co2 co2_date region ForestRev_gdp ForestRev_date fragility_Qt fragility_Qt_jc5 fragility_Qt_jc5_cat geometry
0 ANTIGUA AND BARBUDA Antigua and Barbuda .ag AG ATG 2019 54.4 729000.0 2019 CENTRAL AMERICA AND THE CARIBBEAN 0.00 2018 -0.530113 1 1_Good MULTIPOLYGON (((-61.73889 17.54055, -61.75195 ...
1 AFGHANISTAN The Islamic Republic of Afghanistan .af AF AFG 2019 105.0 7893000.0 2019 SOUTH ASIA 0.20 2018 1.827146 4 4_Poor POLYGON ((61.27656 35.60725, 61.29638 35.62853...
2 ALGERIA The People's Democratic Republic of Algeria .dz DZ DZA 2019 75.4 151633000.0 2019 AFRICA 0.10 2018 0.304520 3 3_Bad POLYGON ((-5.15213 30.18047, -5.13917 30.19236...
3 AZERBAIJAN The Republic of Azerbaijan .az AZ AZE 2019 73.2 35389000.0 2019 MIDDLE EAST 0.02 2018 0.233695 2 2_Middle MULTIPOLYGON (((46.54037 38.87559, 46.49554 38...
4 ALBANIA The Republic of Albania .al AL ALB 2019 58.9 3794000.0 2019 EUROPE 0.18 2018 -0.424447 1 1_Good POLYGON ((20.79192 40.43154, 20.78722 40.39472...
In [204]:
new_indicators=indicators.dissolve(
     by="region",
     aggfunc={
         "COUNTRY": "count",
         "fragility": ["median"],
         "co2": ["median"],
         "ForestRev_gdp": ["median"]
     },as_index=False,
 )
new_indicators
Out[204]:
region geometry (COUNTRY, count) (fragility, median) (co2, median) (ForestRev_gdp, median)
0 AFRICA MULTIPOLYGON (((-2.92813 5.10022, -2.93222 5.1... 51 87.40 4444000.0 2.470
1 AUSTRALIA AND OCEANIA MULTIPOLYGON (((-176.51779 -43.90778, -176.532... 6 67.95 1023000.0 0.385
2 CENTRAL AMERICA AND THE CARIBBEAN MULTIPOLYGON (((-81.71556 7.44681, -81.71362 7... 16 61.00 7873500.0 0.115
3 CENTRAL ASIA MULTIPOLYGON (((50.03472 45.04833, 50.0425 45.... 6 75.20 106001000.0 0.005
4 EAST AND SOUTHEAST ASIA MULTIPOLYGON (((105.26361 -6.54472, 105.26138 ... 15 70.40 238983000.0 0.180
5 EUROPE MULTIPOLYGON (((-18.13223 27.77264, -18.1132 2... 39 40.50 38739000.0 0.150
6 MIDDLE EAST MULTIPOLYGON (((42.76819 14.06653, 42.7868 14.... 16 72.60 68706500.0 0.000
7 NORTH AMERICA MULTIPOLYGON (((-155.211 20.00166, -155.18335 ... 3 38.00 612084000.0 0.080
8 SOUTH AMERICA MULTIPOLYGON (((-74.93431 -51.85501, -74.93251... 11 68.20 36051000.0 0.490
9 SOUTH ASIA MULTIPOLYGON (((73.10193 -0.58431, 73.09915 -0... 8 84.35 15916000.0 0.120
In [205]:
new_indicators.plot(column=('fragility', 'median'), legend=True, cmap='viridis')
Out[205]:
<Axes: >
No description has been provided for this image
In [206]:
new_indicators.plot(column=('co2', 'median'), legend=True, cmap='viridis')
Out[206]:
<Axes: >
No description has been provided for this image
In [207]:
new_indicators.plot(column=('ForestRev_gdp', 'median'), legend=True, cmap='viridis')
Out[207]:
<Axes: >
No description has been provided for this image

Exercise 3¶

  1. Select some points from your maps.

  2. Create the convex hull for those points.

  3. Turn the hull into a GDF.

  4. Plot the hull on top of the country.

In [208]:
aeropuertos=gpd.read_file('https://github.com/LeonarddoCLS/Avance-2/raw/refs/heads/main/aeropuertos/puntos_de_transporte_aereo_GB005Point.shp')
aeropuertos=aeropuertos.to_crs(5343)
In [209]:
aeropuertos_IGN=aeropuertos[aeropuertos.fdc=='IGN/ORSNA']
aeropuertos_IGN.plot()
# ME QUEDO CON LOS AEROPUERTOS REGISTRADOS POR  IGN
Out[209]:
<Axes: >
No description has been provided for this image
In [210]:
aeropuertos_IGN.union_all().convex_hull
Out[210]:
No description has been provided for this image
In [211]:
aeropuertos_hull= gpd.GeoDataFrame(index=[0],
                                    crs=aeropuertos_IGN.crs,
                                    geometry=[aeropuertos_IGN.union_all().convex_hull])


aeropuertos_hull
Out[211]:
geometry
0 POLYGON ((1736873.028 3916366.243, 1484220.121...
In [212]:
base=prov.plot(facecolor='yellow')
aeropuertos_hull.plot(ax=base, alpha=0.4)
aeropuertos_hull.plot(ax=base,facecolor='green',
                       edgecolor='white',alpha=0.4,
                       hatch='X')
aeropuertos_IGN.plot(ax=base, marker='o', color='blue', markersize=8)
Out[212]:
<Axes: >
No description has been provided for this image

Exercise 4¶

Apply two spatial overlays to your maps. If possible. If not, try the codes below.

Spatial Overlay¶

In [213]:
departamentos=departamentos.to_crs(5343)
In [214]:
# the north
DepaN_argentina=departamentos.cx[:,centroid_lat:]
# the south
DepaS_argentina=departamentos.cx[:,:centroid_lat]
# the west
DepaW_argentina=departamentos.cx[:centroid_lon,:]
# the east
DepaE_argentina=departamentos.cx[centroid_lon:,:]
In [215]:
base=DepaN_argentina.plot(facecolor='yellow', edgecolor='black',linewidth=0.2, alpha=0.6)
DepaS_argentina.plot(facecolor='grey', edgecolor='black',linewidth=0.2,ax=base, alpha=0.4)
Out[215]:
<Axes: >
No description has been provided for this image
In [216]:
base=DepaE_argentina.plot(facecolor='yellow', edgecolor='black',linewidth=0.2, alpha=0.6)
DepaW_argentina.plot(facecolor='grey', edgecolor='black',linewidth=0.2,ax=base, alpha=0.4)
Out[216]:
<Axes: >
No description has been provided for this image

Intersection¶

In [217]:
depaNS_argentina=DepaN_argentina.overlay(DepaS_argentina, how="intersection",keep_geom_type=True, make_valid=True)
depaNS_argentina.plot()
Out[217]:
<Axes: >
No description has been provided for this image
In [218]:
depaWE_argentina=DepaW_argentina.overlay(DepaE_argentina, how="intersection",keep_geom_type=True)
depaWE_argentina.plot(edgecolor='white',linewidth=0.1)
Out[218]:
<Axes: >
No description has been provided for this image

Union¶

In [219]:
keep=['fna_1','gna_1','nam_1','geometry']
depaNS_argentina=depaNS_argentina.loc[:,keep]
depaWE_argentina=depaWE_argentina.loc[:,keep]
In [220]:
depaNS_argentina.overlay(depaWE_argentina,how="union",keep_geom_type=True)
Out[220]:
fna_1_1 gna_1_1 nam_1_1 fna_1_2 gna_1_2 nam_1_2 geometry
0 Departamento Rancul Departamento Rancul Departamento Rancul Departamento Rancul POLYGON ((2180328.024 6100644.134, 2180587.411...
1 Comuna 1 Comuna Comuna 1 NaN NaN NaN POLYGON ((2753313.38 6088699.601, 2753333.834 ...
2 Departamento Realicó Departamento Realicó NaN NaN NaN POLYGON ((2235740.179 6082213.857, 2235304.088...
3 Departamento San Rafael Departamento San Rafael NaN NaN NaN POLYGON ((1946220.069 6194841.405, 1946222.513...
4 Partido de Lincoln Partido Lincoln NaN NaN NaN POLYGON ((2489326.755 6108996.521, 2489983.652...
... ... ... ... ... ... ... ...
72 NaN NaN NaN Departamento Dr. Manuel Belgrano Departamento Dr. Manuel Belgrano POLYGON ((2152488.909 7332264.103, 2152509.629...
73 NaN NaN NaN Departamento Graneros Departamento Graneros POLYGON ((2157991.138 6938532.378, 2157993.459...
74 NaN NaN NaN Departamento Simoca Departamento Simoca POLYGON ((2155102.825 6977734.368, 2155122.305...
75 NaN NaN NaN Departamento Leales Departamento Leales POLYGON ((2166918.969 7005177.525, 2166928.861...
76 NaN NaN NaN Departamento Utracán Departamento Utracán POLYGON ((2190410.926 5801413.002, 2190087.949...

77 rows × 7 columns

In [221]:
import pandas as pd

pd.concat([depaNS_argentina,depaWE_argentina],ignore_index=True)
Out[221]:
fna_1 gna_1 nam_1 geometry
0 Comuna 1 Comuna Comuna 1 POLYGON ((2753313.38 6088699.601, 2753333.834 ...
1 Departamento Realicó Departamento Realicó POLYGON ((2235754.902 6082380.797, 2235740.34 ...
2 Departamento San Rafael Departamento San Rafael POLYGON ((1946220.069 6194841.405, 1946222.513...
3 Partido de Lincoln Partido Lincoln POLYGON ((2489326.755 6108996.521, 2489983.652...
4 Partido de Moreno Partido Moreno POLYGON ((2715092.629 6099911.817, 2715269.499...
... ... ... ... ...
73 Departamento Dr. Manuel Belgrano Departamento Dr. Manuel Belgrano POLYGON ((2152488.909 7332264.103, 2152509.629...
74 Departamento Graneros Departamento Graneros POLYGON ((2157991.138 6938532.378, 2157993.459...
75 Departamento Simoca Departamento Simoca POLYGON ((2155102.825 6977734.368, 2155122.305...
76 Departamento Leales Departamento Leales POLYGON ((2166918.969 7005177.525, 2166928.861...
77 Departamento Utracán Departamento Utracán POLYGON ((2190410.926 5801413.002, 2190087.949...

78 rows × 4 columns

In [222]:
depaNS_argentina.overlay(depaWE_argentina, how="union",keep_geom_type=True).dissolve().plot()
Out[222]:
<Axes: >
No description has been provided for this image
In [223]:
depaMidArgentina=depaNS_argentina.overlay(depaWE_argentina, how="union",keep_geom_type=True).dissolve()
depaMidArgentina
Out[223]:
geometry fna_1_1 gna_1_1 nam_1_1 fna_1_2 gna_1_2 nam_1_2
0 MULTIPOLYGON (((1465907.039 1392130.708, 14661... Departamento Rancul Departamento Rancul Departamento Rancul Departamento Rancul
In [224]:
depaMidArgentina['zone']='middles'
depaMidArgentina=depaMidArgentina.loc[:,['fna_1_1','zone','geometry']]
depaMidArgentina
Out[224]:
fna_1_1 zone geometry
0 Departamento Rancul middles MULTIPOLYGON (((1465907.039 1392130.708, 14661...

Difference¶

In [225]:
departamentos.overlay(depaMidArgentina, how='difference').plot()
Out[225]:
<Axes: >
No description has been provided for this image

Symmetric Difference¶

In [226]:
DepaN_argentina.overlay(DepaS_argentina, how="symmetric_difference",keep_geom_type=True).plot()
Out[226]:
<Axes: >
No description has been provided for this image
In [227]:
DepaW_argentina.overlay(depaMidArgentina, how="symmetric_difference",keep_geom_type=False).plot()
Out[227]:
<Axes: >
No description has been provided for this image

Validity of Geometry¶

In [228]:
DepaS_argentina[~DepaS_argentina.is_valid]
Out[228]:
gid objeto fna gna nam in1 fdc sag geometry
In [229]:
DepaS_argentina[~DepaS_argentina.is_valid].plot()
Out[229]:
<Axes: >
No description has been provided for this image
In [230]:
#from shapely.validation import explain_validity, make_valid

#explain_validity(DepaS_argentina[~DepaS_argentina.is_valid].geometry)
Out[230]:
geometry

In [231]:
#DepaS_argentina['validity']=[x.split('[')[0] for x in DepaS_argentina.geometry.apply(lambda x: explain_validity(x))]
#DepaS_argentina['validity'].value_counts()
Out[231]:
count
validity
Valid Geometry 197

In [232]:
#DepaS_argentina.drop(columns=['validity'],inplace=True)

#DepaS_argentina_valid=DepaS_argentina.copy()

#DepaS_argentina_valid['geometry'] = [make_valid(row)  if not row.is_valid else row for row in DepaS_argentina_valid['geometry'] ]
#any invalid?
#DepaS_argentina_valid[~DepaS_argentina_valid.is_valid]
Out[232]:
gid objeto fna gna nam in1 fdc sag geometry
In [233]:
pd.Series([type(x) for x in DepaS_argentina_valid.geometry]).value_counts()
Out[233]:
count
<class 'shapely.geometry.polygon.Polygon'> 184
<class 'shapely.geometry.multipolygon.MultiPolygon'> 13

In [234]:
DepaN_argentina_valid=DepaN_argentina.copy()
DepaE_argentina_valid=DepaE_argentina.copy()
DepaW_argentina_valid=DepaE_argentina.copy()

DepaN_argentina_valid['geometry'] = [make_valid(row)  if not row.is_valid else row for row in DepaN_argentina_valid['geometry'] ]
DepaE_argentina_valid['geometry'] = [make_valid(row)  if not row.is_valid else row for row in DepaE_argentina_valid['geometry'] ]
DepaW_argentina_valid['geometry'] = [make_valid(row)  if not row.is_valid else row for row in DepaW_argentina_valid['geometry'] ]
In [235]:
DepaN_argentina_cleaned = DepaN_argentina_valid.copy()
DepaS_argentina_cleaned = DepaS_argentina_valid.copy()
DepaE_argentina_cleaned = DepaE_argentina_valid.copy()
DepaW_argentina_cleaned = DepaW_argentina_valid.copy()

# Apply buffer(0) to potentially fix remaining issues
DepaN_argentina_cleaned['geometry'] = DepaN_argentina_cleaned.geometry.buffer(0)
DepaS_argentina_cleaned['geometry'] = DepaS_argentina_cleaned.geometry.buffer(0)
DepaE_argentina_cleaned['geometry'] = DepaE_argentina_cleaned.geometry.buffer(0)
DepaW_argentina_cleaned['geometry'] = DepaW_argentina_cleaned.geometry.buffer(0)
In [236]:
DepaN_argentina_cleaned.overlay(DepaS_argentina_cleaned, how="symmetric_difference", keep_geom_type=True).plot()
Out[236]:
<Axes: >
No description has been provided for this image
In [238]:
DepaE_argentina_cleaned.overlay(DepaW_argentina_cleaned, how="symmetric_difference", keep_geom_type=True).plot()
Out[238]:
<Axes: >
No description has been provided for this image