This Notebook contains the complete process to apply weights to meinGrün Zielgeometrien extracted from LBSM data (geolocated Social Media Posts).
Intersection of points and coordinates is not complex. However, there're several potential pitfalls in the process.
Pitfalls:
Lets first start with importing the necessary dependencies.
First, make sure you have these packages installed. Dependency management in python can be tricky. The following instructions are based on conda package manager (e.g. miniconda). By pinning one package (holoviews), we can make sure that 1) compatible package versions are installed for all other packages and 2) the code written herein is compatible.
conda create -n jupyter_env_meingruen python=3.7 -c pyviz -c conda-forge
conda activate jupyter_env_meingruen
conda config --env --set channel_priority strict
conda config --show channel_priority # verify
conda install -c pyviz -c conda-forge geoviews "bokeh<2.0.0" seaborn shapely "holoviews=1.12.7" geopandas matplotlib jupyterlab descartes mapclassify
Optional:
conda install -c pyviz -c conda-forge jupyter_contrib_nbextensions tagmaps
Alternatively, to create an env with the latest versions of bokeh, holoviews, geoviews, use the following approach:
conda create -n jupyter_env_meingruen python=3.7 -c "pyviz/label/dev" -c conda-forge
conda activate jupyter_env_meingruen
conda config --env --set channel_priority strict
conda install -c "pyviz/label/dev" -c conda-forge geoviews bokeh seaborn shapely holoviews geopandas matplotlib jupyterlab descartes mapclassify tagmaps jupyter_contrib_nbextensions
import math
import csv
import fiona
import geoviews as gv
import geoviews.feature as gf
import mapclassify as mc
import seaborn as sns
import datetime as dt
import geopandas as gp
import pandas as pd
import holoviews as hv
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from rtree import index
from pathlib import Path
from shapely.geometry import shape
from pyproj import Transformer, CRS, Proj
from shapely.ops import transform
from shapely.geometry import Point, Polygon, MultiPolygon
from shapely.geometry.collection import GeometryCollection
from holoviews import dim
from holoviews.operation.datashader import datashade, shade, dynspread, rasterize
from geopandas.tools import sjoin
from matplotlib.patches import Patch
# enable shapely.speedups which makes some of the spatial queries running faster.
import shapely.speedups
shapely.speedups.enable()
from cartopy import crs as ccrs
from collections import defaultdict
from collections import namedtuple
from tagmaps.classes.utils import Utils
from IPython.display import clear_output, Markdown, display
hv.notebook_extension('bokeh')