Skip to content

Instantly share code, notes, and snippets.

@AlexandraKapp
Created September 23, 2019 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexandraKapp/0d4d0bb2b47661fe89903200dabfa0e4 to your computer and use it in GitHub Desktop.
Save AlexandraKapp/0d4d0bb2b47661fe89903200dabfa0e4 to your computer and use it in GitHub Desktop.
Merge data with Berlin Planungsraeume
import geopandas as gpd
import pandas as pd
from shapely.geometry import Point
plr = gpd.read_file('data/lor_planungsraeume.geojson', encoding='utf-8')
df = pd.read_csv('data/DATAFILE.csv', sep=";", dtype={'PLR_CODES':str}, na_values=['OTHER_NAN_VALUES'])
df.set_index('PLR_CODES', inplace=True)
data = df.join(plr.set_index('spatial_name'), rsuffix='_r')
gpd.GeoDataFrame(data).to_file('output.geojson', driver='GeoJSON', encoding='utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment