1

I want to extract Singapore country boundaries from 'naturalearth_lowres' dataset from GeoPandas.

world_filepath = gpd.datasets.get_path('naturalearth_lowres')
world = gpd.read_file(world_filepath)
world.head()

enter image description here

This is the world boundaries DataFrame from which I want to extract "Singapore" country boundary.

2

Using pandas loc should do the trick:

singapore = world.loc[world['name'] == 'Singapore'] # get Singapore row
boundaries = singapore['geometry'] # get Singapore geometry
1
  • Recently I could not find 'Singapore' in 'naturalearth_lowres' dataset... – Taras Apr 21 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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