<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 An introduction to GeoPandas
Welcome to Jupyter Notebook, this is an example of a Python notebook. A quick overview of how notebooks work can be found here.
Coming Up
Step1:  1. Create a dataframe with Pandas
Step2:  2. GeoPandas
Step3:  3 Cities?
Step4:  Let's compare some data?
Step5:  Crime?
Step6:  <br><br><hr><br><br>
Prairie Dogs?
<ASSISTANT_TASK:>
Python Code:
import json, shapely, fiona, os
import seaborn as sns
import pandas as pd
import geopandas as gpd
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
Explanation: An introduction to GeoPandas
Welcome to Jupyter Notebook, this is an example of a Python notebook. A quick overview of how notebooks work can be found here.
Coming Up: 
0.5 Where are we?
1.0 What is Pandas?
2.0 What is a GeoPanda?
End of explanation
# load the sample dataset (iris)
iris = sns.load_dataset('iris')
#look at it:
print("Rows: ",len(iris))
iris.head()
iris.species.value_counts()
#Now let's plot it: 
ax = iris[iris.species=='setosa'].plot(kind='scatter', x='sepal_length', y='petal_length', color='steelblue', figsize=(10,6))
iris[iris.species=='virginica'].plot(kind='scatter', x='sepal_length', y='petal_length', ax=ax, color='red')
iris[iris.species=='versicolor'].plot(kind='scatter', x='sepal_length', y='petal_length', ax=ax, color='orange')
ax.legend(['Setosa','Virginica','Versicolor'])
Explanation: 1. Create a dataframe with Pandas
End of explanation
# First we're going to read in the default data
path = gpd.datasets.get_path('naturalearth_lowres')
df = gpd.read_file(path)
df.head()
print("Average Population per country: {0}".format(df.pop_est.mean().round()))
print("Median Population per country:  {0}".format(df.pop_est.median().round()))
#Now let's plot it
df.plot(figsize=(10,8))
# Get fancier with other libraries
import geoplot
fig, axes = plt.subplots(1,2)
fig.set_size_inches(15,8)
geoplot.cartogram(df[df['continent'] == 'Africa'],
                  scale='pop_est', limits=(0.2, 1), figsize=(7, 8), ax=axes[0])
geoplot.cartogram(df[df['continent'] == 'South America'],
                  scale='pop_est', limits=(0.2, 1), figsize=(7, 8), ax=axes[1])
Explanation: 2. GeoPandas: Okay, Let's Go Geo!
End of explanation
df = gpd.read_file('data/HydrologyLine.shp')
df.columns = ['layer','length','geometry']
df.head()
df.plot(figsize=(15,8))
df.crs
mercator = df.head(10).to_crs({'init': 'epsg:4326'})
Explanation: 3 Cities?
End of explanation
osmp_lands = gpd.read_file('data/OSMPLands.shp')
osmp_lands.head(3)
ax = osmp_lands[osmp_lands.TYPE=='Conservation Easement'].plot(figsize=(15,8))
osmp_lands[osmp_lands.TYPE!='Conservation Easement'].plot(ax=ax,color='green')
# geoplot.choropleth(osmp_lands, hue='PropertyID', cmap='Greens', figsize=(8, 4))
Explanation: Let's compare some data?
End of explanation
crime = gpd.read_file('data/Target_Crime_Locations.shp')
crime['date'] = crime.REPORTDATE.apply(lambda x: pd.Timestamp(x).date())
crime['year'] = crime.date.apply(lambda x: x.year)
crime.head()
ax = crime.groupby('date').aggregate({"REPORTNUM":"count"}).cumsum().plot()
ax.set_title("Amount of crime reports filed over time");
# Looks like crime is not going up in Boulder?
crime.OFFENSE.value_counts()
crime[crime.OFFENSE=='Trespassing'].groupby('date').aggregate('count')['OBJECTID'].cumsum().plot(figsize=(15,8))
conservation_easement = osmp_lands[osmp_lands.TYPE=='Conservation Easement'].to_crs(crime.crs)
ax = conservation_easement.plot(figsize=(15,8))
crime[(crime.OFFENSE=='Trespassing') & (crime.year==2018)].plot(ax=ax, color='red', linewidth=0.01)
crimes_on_osmplands = gpd.sjoin(osmp_lands.to_crs(crime.crs),crime) #Spatial join Points to polygons
crimes_on_osmplands.head(2)
# What crimes happpen on OSMP lands?
crimes_on_osmplands.OFFENSE.value_counts()
Explanation: Crime?
End of explanation
prairie = gpd.read_file('data/prairies.shp')
print("Found {0} colonies".format(len(prairie)))
prairie.head()
prairie.head().buffer(0.001).plot()
Explanation: <br><br><hr><br><br>
Prairie Dogs?
End of explanation
<END_TASK>