Commit 6e4b947e authored by Aurore Sallard's avatar Aurore Sallard Committed by kaghog
Browse files

Forgot to push destinations.py

parent a0d16edf
......@@ -7,6 +7,7 @@ import geopandas as gpd
def configure(context):
context.stage("data.statent.statent")
context.config("use_detailed_activities")
context.config("output_path")
def execute(context):
......@@ -33,7 +34,7 @@ def execute(context):
# 90 = arts, entertainment, leisure; 56 = gastronomy
df.loc[:, "offers_leisure"] = df["noga"].str.startswith("90") | df["noga"].str.startswith("56") | df["noga"].str.startswith("91") | df["noga"].str.startswith("55") | df["noga"].str.startswith("94") | (df["noga"] == "591400") | (df["noga"] == "920000") | (df["noga"] == "855200") | (df["noga"] == "932100") | (df["noga"] == "932900") | (df["noga"] == "855100") | df["noga"].str.startswith("931")
if det_activities:# == "true":
if det_activities:
df.loc[:, "offers_culture"] = df["noga"].str.startswith("90") | df["noga"].str.startswith("91") | (df["noga"] == "591400") | (df["noga"] == "920000") | (df["noga"] == "855200") | (df["noga"] == "932100") | (df["noga"] == "932900")
df.loc[:, "offers_religion"] = df["noga"].str.startswith("94")
......@@ -44,7 +45,7 @@ def execute(context):
# 47 = retail
df.loc[:, "offers_shop"] = df["noga"].str.startswith("47")
if det_activities:# == "true":
if det_activities:
df.loc[:, "offers_grocery"] = df["noga"].str.startswith("471") | df["noga"].str.startswith("472") | df["noga"].str.startswith("473") | (df["noga"] == "478100")
df.loc[:, "offers_other(S)"] = df["offers_shop"] & np.logical_not(df["offers_grocery"])
......@@ -58,13 +59,13 @@ def execute(context):
max_id = np.max(df["destination_id"].values.tolist())
# Services
if det_activities:# == "True":
df.loc[:, "offers_services"] = df["noga"].str.startswith("8690") | df["noga"].str.startswith("95") | df["noga"].str.startswith("33") | df["noga"].str.startswith("6419") | df["noga"].str.startswith("6512") | (df["noga"] == "750000") | (df["noga"] == "861001") | (df["noga"] == "861002") | (df["noga"] == "862100") | (df["noga"] == "862200") | (df["noga"] == "862300") | (df["noga"] == "772200") | (df["noga"] == "960101") | (df["noga"] == "960102") | (df["noga"] == "960201") | (df["noga"] == "960202") | (df["noga"] == "960401") | (df["noga"] == "960402") | (df["noga"] == "855300") | (df["noga"] == "531000") | (df["noga"] == "532000") | (df["noga"] == "452001") | (df["noga"] == "452002") | (df["noga"] == "649201") | (df["noga"] == "651100") | (df["noga"] == "681000") | (df["noga"] == "682001") | (df["noga"] == "682002") | (df["noga"] == "682002") | (df["noga"] == "683100") | (df["noga"] == "683200") | (df["noga"] == "691001") | (df["noga"] == "692000") | (df["noga"] == "771100") | (df["noga"] == "772100") | (df["noga"] == "772900") | (df["noga"] == "791100") | (df["noga"] == "791200") | (df["noga"] == "841100") | (df["noga"] == "842400") | (df["noga"] == "842301") | (df["noga"] == "843000")
if det_activities:
df.loc[:, "offers_services"] = df["noga"].str.startswith("8690") | df["noga"].str.startswith("95") | df["noga"].str.startswith("33") | df["noga"].str.startswith("6419") | df["noga"].str.startswith("6512") | (df["noga"] == "750000") | (df["noga"] == "861001") | (df["noga"] == "861002") | (df["noga"] == "862100") | (df["noga"] == "862200") | (df["noga"] == "862300") | (df["noga"] == "772200") | (df["noga"] == "960101") | (df["noga"] == "960102") | (df["noga"] == "960201") | (df["noga"] == "960202") | (df["noga"] == "960401") | (df["noga"] == "960402") | (df["noga"] == "855300") | (df["noga"] == "531000") | (df["noga"] == "532000") | (df["noga"] == "452001") | (df["noga"] == "452002") | (df["noga"] == "649201") | (df["noga"] == "651100") | (df["noga"] == "681000") | (df["noga"] == "682001") | (df["noga"] == "682002") | (df["noga"] == "683100") | (df["noga"] == "683200") | (df["noga"] == "691001") | (df["noga"] == "692000") | (df["noga"] == "771100") | (df["noga"] == "772100") | (df["noga"] == "772900") | (df["noga"] == "791100") | (df["noga"] == "791200") | (df["noga"] == "841100") | (df["noga"] == "842400") | (df["noga"] == "842301") | (df["noga"] == "843000")
df.loc[:, "offers_outdoor"] = False
# Outdoor points
if det_activities:# == "True":
if det_activities:
outdoor_path = "/nas/asallard/Switzerland/Outdoor_points"
outdoor = gpd.read_file("%s/sample_points.shp"% outdoor_path)
initial_crs = outdoor.crs
......@@ -101,9 +102,20 @@ def execute(context):
df = pd.concat([df, outdoor])
df_gastronomy = df[df["offers_gastronomy"]][["destination_id", "destination_x", "destination_y"]]
df_grocery = df[df["offers_grocery"]][["destination_id", "destination_x", "destination_y"]]
df_shopping = df[df["offers_other(S)"]][["destination_id", "destination_x", "destination_y"]]
df_culture = df[df["offers_culture"]][["destination_id", "destination_x", "destination_y"]]
output_path = context.config("output_path")
df_gastronomy.to_csv("%s/destinations_gastronomy.csv" % output_path, index = False)
df_grocery.to_csv("%s/destinations_grocery.csv" % output_path, index = False)
df_shopping.to_csv("%s/destinations_shopping.csv" % output_path, index = False)
df_culture.to_csv("%s/destinations_culture.csv" % output_path, index = False)
return df[["destination_id", "destination_x", "destination_y",
"offers_work", "offers_education", "offers_leisure", "offers_grocery", "offers_other(S)", "offers_culture", "education_type", "offers_religion", "offers_gastronomy", "offers_sport", "offers_other(L)", "offers_other", "offers_visits", "offers_volunteer",
"offers_outdoor", "offers_services", "geometry", "number_employees"]]
"offers_outdoor", "offers_services", "offers_shop", "geometry", "number_employees", "noga"]]
else:
return df[["destination_id", "destination_x", "destination_y",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment