May 2019
Beginner
170 pages
4h 9m
English
Here, we will use queen weights to construct the spatial similarity of this dataset with PySAL:
wq = weights.Queen.from_dataframe(final_result)wq.transform = 'r'
We then apply the weights to the crime counts variable and add the spatial similarity as a column to our final results GeoDataFrame:
y = final_result['CrimeCount']ylag = weights.lag_spatial(wq, y)final_result['ylag'] = ylag
Let's map out the choropleth of the crime data with a spatial similarity:
fig, ax = plt.subplots(figsize=(12,10))final_result.plot(column='ylag', scheme='Quantiles', k=5, cmap='YlGnBu', legend=True, ax=ax);plt.tight_layout()ax.set_axis_off()plt.savefig('choroplethmap-ylag.png')plt.title('Crimes Ylag Choropleth Map ')plt.show() ...Read now
Unlock full access