Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate the NCN layer #47

Merged
merged 2 commits into from
Jan 23, 2024
Merged

Generate the NCN layer #47

merged 2 commits into from
Jan 23, 2024

Conversation

Pete-Y-CS
Copy link
Contributor

No description provided.

def makeNationalCycleNetwork():
tmp = "tmp_ncn"
ensureEmptyTempDirectoryExists(tmp)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, a comment linking to https://data-sustrans-uk.opendata.arcgis.com/ useful. The arcgis URL isn't discoverable or could change with another version

run(
[
"wget",
"https://services5.arcgis.com/1ZHcUS1lwPTg4ms0/arcgis/rest/services/National_Cycle_Network_Public/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How'd you get this link? I got https://opendata.arcgis.com/api/v3/datasets/5defd254e78745bfb12d0456abc1bcf1_0/downloads/data?format=geojson&spatialRefId=4326&where=1%3D1 by going to https://data-sustrans-uk.opendata.arcgis.com/datasets/5defd254e78745bfb12d0456abc1bcf1_0/explore, clicking download, going down to geojson, choosing the file that's already there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it from Robin's comment 👀 good point that I should check they match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the same link as you, will use it instead and rerun

tmp = "tmp_ncn"
ensureEmptyTempDirectoryExists(tmp)

# Get the shapefile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment, this isn't a shapefile

]
)

reprojectToWgs84(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file I downloaded is already in WGS84

f"{tmp}/national_cycle_network_download.geojson", f"{tmp}/national_cycle_network.geojson"
)

# def fixProps(inputProps):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The props in there look fine. We could be lazy and just plumb everything through, then only display some fields later. Or do work here to strip out unused stuff like segment ID, global ID, shape_length, etc. If it's not hassle, just listing the fields to keep or to delete could be nice, to keep things clean

Copy link
Contributor

@dabreegster dabreegster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good here! I re-ran locally and copied to S3. Looking at the frontend PR now

def fixProps(inputProps):
propsToRemove = ["LinkNo", "Lighting", "RoadClass", "SHAPE_Length", "GlobalID", "SegmentID"]
for prop in propsToRemove:
inputProps.pop(prop)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen pop on a dictionary, only ever to remove the last thing from a list. But it works! TIL more python

@Pete-Y-CS Pete-Y-CS changed the title WIP- Generate the NCN layer Generate the NCN layer Jan 23, 2024
@Pete-Y-CS Pete-Y-CS merged commit e91feb7 into main Jan 23, 2024
@dabreegster dabreegster deleted the national-cycle-network branch August 13, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants