Generating Markings Asset Counts based on Crew Assigned
CREW_ASSIGNED | YEARS | TOTALS | ANNUAL_TOTALS | |
---|---|---|---|---|
0 | BIKE | 4 | 9590 | 2398.0 |
1 | CBD | 4 | 2367 | 592.0 |
2 | OTHER | 6 | 13077 | 2180.0 |
3 | SIGNAL | 6 | 8326 | 1388.0 |
This post will demonstrate how to access attribute table from shapefiles in order to create a markings asset counts for each street segment. Here is the link to notebook
The purpose of this notebook is to quickly create datasets for reporting purposes
gis = GIS("https://austin.maps.arcgis.com/home/index.html")
url = r"https://services.arcgis.com/0L95CJ0VTaxqcmED/arcgis/" +
r"rest/services/TRANSPORTATION_{}/FeatureServer/0"
col = ['CREW_ASSIGNED','TOTALS']
Create Feature Layers and DataFrames
This will create feature layers and convert to dataframe. This will take a while since there are over 30000 rows
sdf = pd.DataFrame.spatial.from_layer(
FeatureLayer(url.format("markings_specialty_point")))
year = pd.DataFrame(
{'YEARS':[4,4,6,6],col[0]:['CBD','BIKE','SIGNAL','OTHER']})
Create Tables
sp_sdf = sdf.copy().rename(columns={'SHAPE':'TOTALS'})
sp_sdf = sp_sdf.groupby([col[0]]).count()[[col[1]]].reset_index().filter(
items=col)
final = pd.merge(sp_sdf,year,on=[col[0]])
final['ANNUAL_TOTALS'] = round(final.TOTALS / final.YEARS)
final =final[[final.columns[0],final.columns[2],
final.columns[1],final.columns[3]]]
final.to_csv(r'C:\Users\Govs\Projects\Files\specialty_markings_totals.csv')
This project would not have been completed without the help from: