AmericanRedCross / street-view-green-view

BSD 3-Clause "New" or "Revised" License
15 stars 15 forks source link

Implement createPoints.py with geopandas #2

Closed jayqi closed 8 months ago

jayqi commented 8 months ago

This is a rewrite of createPoints.py from mittrees/Treepedia_Public using geopandas, a modern popular geospatial Python library.

A few key points:

You can see the Jupyter notebook notebooks/0.0-jyq-create-points-demo.ipynb for a demo. Note that the folium maps do not directly load in GitHub, but you can see the rendered notebook here via nbviewer.

The script can also be called as a command-line program with python src/create_points.py or python -m src.create_points. Use the --help flag for documentation.

danbjoseph commented 8 months ago

thanks for working on this! 😄

some of the roads that are in the shapefile, aren't showing up in the nbviewer visualization. (QGIS on the left showing source shapefile, your nbviewer on the right)

Screenshot 2024-01-29 at 9 54 23 AM Screenshot 2024-01-29 at 9 53 55 AM

(also, i need to look at why some of the roads don't seem to be in the source shapefile, e.g. North Main Street / BUS US 131)

the final output should be a points (here's the Cambridge20m.shp from https://github.com/mittrees/Treepedia_Public/tree/master/sample-spatialdata

Screenshot 2024-01-29 at 9 57 38 AM
jayqi commented 8 months ago

@danbjoseph It looks like that road has the property highway=tertiary. It's one of the road types that gets filtered out:

https://github.com/jayqi/street-view-green-view/blob/c2228ab5c4b217db9f0f8b189669541ed477cece/src/create_points.py#L33

This is logic from the Treepedia version:

https://github.com/mittrees/Treepedia_Public/blob/34d925c1f85e44c061a3ecae5ce93e6bd4d94c2a/Treepedia/createPoints.py#L35

https://github.com/mittrees/Treepedia_Public/blob/34d925c1f85e44c061a3ecae5ce93e6bd4d94c2a/Treepedia/createPoints.py#L49-L61

jayqi commented 8 months ago

@ayoakin did you mean to merge or was that a mistake? I didn't think @danbjoseph had finished reviewing.

danbjoseph commented 8 months ago

i'm not terribly concerned about what's in a given PR at this point (no one outside those working on the project is using the code). i asked @ayoakin to review as he had been building familiarity with the code while working in a Google Colab.

@jayqi please note my comment about the final output from this step being a points file (not lines). the other items can come later (e.g. figuring out the best method for cleaning/filtering the different roads features... should the user do it in a GIS software before starting the scripted process? should we have configurable filters in the code? something else?) as they aren't blocking moving onto the Mapillary API calls and other steps

ayoakin commented 8 months ago

@jayqi I merged so I can pull and check as we don't have a job for that atm on here. Like @danbjoseph mentioned I don't think what's in main should matter at this point.

I am mainly checking for functionality and reproducibility. Might make some suggestions once I am able to make it run locally on my end. Thanks so much!

jayqi commented 8 months ago

@jayqi please note my comment about the final output from this step being a points file (not lines). the other items can come later (e.g. figuring out the best method for cleaning/filtering the different roads features... should the user do it in a GIS software before starting the scripted process? should we have configurable filters in the code? something else?) as they aren't blocking moving onto the Mapillary API calls and other steps

The output is indeed a file of points, and sorry that this wasn't clear. In the notebook, I've subsetted the map to only show a single road for as a demonstration, but the actual workflow of using the script produces a output file that contains the interpolated points for all roads (with the same filtering in the Treepedia script).