Skip to content
Snippets Groups Projects
Commit e2518f21 authored by Quentin ANDRE's avatar Quentin ANDRE
Browse files

get_countries

parent 16f38c01
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ import cartopy.crs as ccrs
import cartopy.feature as cf
from cartopy.feature import ShapelyFeature
import cartopy.io.shapereader as shpreader
from shapely.geometry import Point
proj = ccrs.PlateCarree()
......@@ -12,13 +13,11 @@ shpfilename = shpreader.natural_earth(resolution='10m',
reader = shpreader.Reader(shpfilename)
# Filter for a specific country
kenya = [country for country in reader.records() if country.attributes["NAME_LONG"] == "Kenya"][0]
# Determine bounding box
lon_min, lat_min, lon_max, lat_max = kenya.bounds
print(kenya.bounds)
countries = [country for country in reader.records()]
# Display Kenya's shape
shape_feature = ShapelyFeature([kenya.geometry], ccrs.PlateCarree(), facecolor="lime", edgecolor='black', lw=1)
print(shape_feature)
print(kenya.geometry)
\ No newline at end of file
#shape_feature = ShapelyFeature([country.geometry for country in countries], ccrs.PlateCarree(), facecolor="lime", edgecolor='black', lw=1)
boundaries = [country.geometry for country in countries]
print(boundaries[0])
print(boundaries[0].contains(Point(0,0)))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment