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 ...@@ -2,6 +2,7 @@ import cartopy.crs as ccrs
import cartopy.feature as cf import cartopy.feature as cf
from cartopy.feature import ShapelyFeature from cartopy.feature import ShapelyFeature
import cartopy.io.shapereader as shpreader import cartopy.io.shapereader as shpreader
from shapely.geometry import Point
proj = ccrs.PlateCarree() proj = ccrs.PlateCarree()
...@@ -12,13 +13,11 @@ shpfilename = shpreader.natural_earth(resolution='10m', ...@@ -12,13 +13,11 @@ shpfilename = shpreader.natural_earth(resolution='10m',
reader = shpreader.Reader(shpfilename) reader = shpreader.Reader(shpfilename)
# Filter for a specific country # Filter for a specific country
kenya = [country for country in reader.records() if country.attributes["NAME_LONG"] == "Kenya"][0] countries = [country for country in reader.records()]
# Determine bounding box
lon_min, lat_min, lon_max, lat_max = kenya.bounds
print(kenya.bounds)
# Display Kenya's shape # Display Kenya's shape
shape_feature = ShapelyFeature([kenya.geometry], ccrs.PlateCarree(), facecolor="lime", edgecolor='black', lw=1) #shape_feature = ShapelyFeature([country.geometry for country in countries], ccrs.PlateCarree(), facecolor="lime", edgecolor='black', lw=1)
print(shape_feature)
print(kenya.geometry) boundaries = [country.geometry for country in countries]
\ No newline at end of file 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.
Please to comment