wsp-sag / Lasso

Python package of utilities for Network Wrangler
https://wsp-sag.github.io/Lasso/
Apache License 2.0
5 stars 3 forks source link

Add Test of write_roadway_as_shp #104

Open DavidOry opened 4 years ago

DavidOry commented 4 years ago

fyi @i-am-sijia, @e-lo.

I'm getting some strange results. This line gives me pause:

        links_dbf_df["geometry"] = self.shapes_metcouncil_df["geometry"]

It seems we should be joining on a key rather than just adding in the column. Any quick thoughts?

i-am-sijia commented 4 years ago

Yep, it was coded this way because it was enough for base network, but for build scenarios, I can see it be error prone. We should join them using shape_id that we generated as unique shape IDs.

DavidOry commented 4 years ago

@i-am-sijia

The geometries for new managed lanes links are missing from the shape file output, perhaps because they are getting computed and stored in links_dbf_df but not in shapes_metcouncil_df? Then this join ends up dropping them.

# network object does not store true shape in the links_df
        links_dbf_df = pd.merge(
            links_dbf_df.drop("geometry", axis = 1),
            self.shapes_metcouncil_df[["shape_id", "geometry"]],
            how = "left",
            on = "shape_id"
        )

Can we add the new shapes to shapes_metcouncil_df when they are created or modify the merge to replace geometry when it is present in shapes_metcouncil_df but not drop it from links_dbf_df?

i-am-sijia commented 4 years ago

It was because the new shapes in shapes_df has NaN in columns such as toIntersectionId, fromIntersectionId, id, and they get dropped in this line:

https://github.com/wsp-sag/Lasso/blob/6dbcbe0d2efbca8a15e513997da9214f1118dd9f/lasso/roadway.py#L1604

I added fill_na for shape_df, so that new shapes can be pass along to shapes_metcouncil_df

DavidOry commented 2 years ago

@RachelWikenMC fyi.. This test should address your issue of using the link_output_variables parameter in this method.