From e2518f21926a67842613a7a6e1e7ca41720ef42c Mon Sep 17 00:00:00 2001 From: Quentin ANDRE <q19andre@pc-df-897.priv.enst-bretagne.fr> Date: Thu, 24 Mar 2022 18:13:17 +0100 Subject: [PATCH] get_countries --- get_countries.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/get_countries.py b/get_countries.py index e137ff3..fa289a9 100644 --- a/get_countries.py +++ b/get_countries.py @@ -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 -- GitLab