Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to merge small polygons with neighbor polygons using geopandas and pysal #2673

Closed
mohseniaref opened this issue Dec 11, 2022 · 1 comment
Labels

Comments

@mohseniaref
Copy link


Question about geopandas

How to merge small polygons with neighbor polygons using geopandas and pysal
I want to merge small polygons based on their area,etc. with adjacent neighbor polygons. For instance, we want to merge all countries in an iterative way to have a world map in which all small countries merge with neighbors and no countries smaller than the threshold area don't exist. I really appreciate if you can guide me how to do this using pysal and geopandas.

import geopandas, numpy
import matplotlib.pyplot as plt
from esda import topo
from libpysal import weights
earth = geopandas.read_file(
    geopandas.datasets.get_path('naturalearth_lowres'))
wm=earth.to_crs('epsg:3395')
wm["area"] = wm['geometry'].area/ 10**6
wm=wm.to_crs('epsg:4326')
wm.sort_values('area', ascending=False)
f,ax = plt.subplots(1,1,figsize=(12,6))
wm.plot('area', ax=ax,cmap=plt.cm.get_cmap("viridis"),vmin=5660,vmax=80000)

@martinfleis
Copy link
Member

Have a look at sjsrey/geoplanar#36. You should be able to use or slightly adapt that function to do what you want.

@geopandas geopandas locked and limited conversation to collaborators Jan 5, 2023
@martinfleis martinfleis converted this issue into discussion #2735 Jan 5, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants