developmentseed / road-planning-datapipeline

Data pipeline for the Road Planning tool
MIT License
0 stars 1 forks source link

Criticality processor #33

Closed danielfdsilva closed 3 years ago

danielfdsilva commented 3 years ago

This PR adds the base code for the criticality calculation. It uses the same methodology as Mozambique:

Some pairs may become unroutable when ways are ignored, therefore the calculations use the formula:

Global variables:
  avgMaxTime       - Maximum time impact the removal a way causes, considering all pairs
  maxUnroutable    - Maximum number of unroutable pairs found across all removed segment

Variables of the way for which score is being calculated:
  unroutablePairs  - Total number of unroutable pairs removing this way causes.
  impactedPairs    - Total number of pairs that had the duration affected by removing this way.
  avgTimeNonZero   - Average time impact the removal of this way causes, considering only the impacted pairs

timeScore = (unroutablePairs + impactedPairs) * avgTimeNonZero / avgMaxTime
unroutableScore = unroutablePairs / maxUnroutable

// Time is 40%, unroutable is 60%.
// Then normalize to 0 - 100 scale.
score = ((timeScore || 0) * 0.4 + (unroutableScore || 0) * 0.6) * 100

This seems to be running ok, but with 42627 different ways in the network, this is going to take roughly 12h to run.

Would it make sense to remove the uninvestible roads from the equation?

Next steps:

@olafveerman

olafveerman commented 3 years ago

@danielfdsilva This is the GeoJSON with populated places: places.zip

olafveerman commented 3 years ago

The GeoJSON with places I shared above contains too many settlements, and running criticality for all-to-all would take too long. Instead, we can use a file with main settlements, which only contains ~200 locations

How this was generated

Source shapefiles:

Merge them into a single GeoJSON:

ogrmerge.py \
  -f "GeoJSON" \
  -o populated-places.geojson \
  *.shp \
  -single \
  -t_srs EPSG:4326
olafveerman commented 3 years ago

This looks good!