I'm trying to create a 5 - 10km buffer for a GADM country-level shape file for all of Europe and Asia. I am doing this to determine if certain weather stations from the NOAA Global Surface Summary of the Day are within a reasonable distance of standard country bounds, and not in outlying islands using GeoPandas contains().
I am predominantly having an issue creating the buffer. Below is the code I used in order to pull the shape file, filter the resulting GeoPandas DataFrame to only Europe and Asia, and create the buffer:
import numpy as np
import pandas as pd
import geopandas as gpd
import requests
import fiona.io
#pull country (level 0) shape file from GADM and save as GeoDataFrame
file_name_levels = 'https://data.biogeo.ucdavis.edu/data/gadm3.6/gadm36_levels_shp.zip'
r = requests.get(file_name_levels)
with fiona.io.ZipMemoryFile(r.content) as zip_memory_file:
with zip_memory_file.open('gadm36_0.shp') as collection:
world_map = gpd.GeoDataFrame.from_features(collection, crs=collection.crs)
#Join with Country-Continent dataset to select only countries in Europe and Asia in the shape file
country_continent_dict = pd.read_csv('https://raw.githubusercontent.com/dieghernan/Country-Codes-and-International-Organizations/master/outputs/Countrycodes.csv')
country_continent_dict = country_continent_dict[['ISO_3166_3', 'CONTINENT.EN']]
country_continent_dict.columns = ['GID_0', 'Continent']
world_map_continent = world_map.merge(country_continent_dict, how = "left")
#fix the continent of the two countries that did not join directly due to spellings
world_map_continent.loc[world_map_continent['NAME_0'] == 'Kosovo', 'Continent'] = 'Europe'
world_map_continent.loc[world_map_continent['NAME_0'] == 'North Cyprus', 'Continent'] = 'Europe'
#filter to Europe/Asia
world_map_asia_euro = world_map_continent[(world_map_continent['Continent'] == 'Asia') | (world_map_continent['Continent'] == 'Europe')].reset_index()
#Change CRS to measurement in meters
world_map_meters = world_map_asia_euro.copy().to_crs("EPSG:3395")
#Create 5km buffer
buffer = world_map_meters['geometry'].buffer(5000)
However, the buffer has never finished running (I've tried letting it run for up to 5 hours). I have tried first simplifying the geometries using GeoPandas simplify(). However, simplifying with a tolerance large enough that the computation time is reasonable creates overlapping geometries such that the map has a large rectangle extending across Northern North American, Europe, and Asia.
How can I create this buffer without significant computation time or first simplifying the geometries?