Skip to content

CIF-330 [METRIC] isochrone and isodistance metrics#87

Open
tedw0ng wants to merge 122 commits intomainfrom
percent-with-access-to-amenity-metric
Open

CIF-330 [METRIC] isochrone and isodistance metrics#87
tedw0ng wants to merge 122 commits intomainfrom
percent-with-access-to-amenity-metric

Conversation

@tedw0ng
Copy link
Member

@tedw0ng tedw0ng commented Oct 24, 2024

This takes an isoline (i.e., isochrone or isodistance) geojson stored in S3 and (a) calculates percent of population (from WorldPop) that lives within the isoline and (b) calculates average number of amenity points accessible in a zone. Includes an Isoline layer and a percentpop_within_isoline metric.

https://gfw.atlassian.net/browse/CIF-330

@tedw0ng tedw0ng self-assigned this Oct 24, 2024
@tedw0ng tedw0ng changed the title create layer and metric for percentpop within isochrone CIF-330 [METRIC] isochrone and isodistance metrics Jan 10, 2025
from city_metrix.constants import GeoType, GTIFF_FILE_EXTENSION, GEOJSON_FILE_EXTENSION, NETCDF_FILE_EXTENSION, \
CSV_FILE_EXTENSION, LOCAL_CACHE_URI, DEFAULT_PRODUCTION_ENV, CIF_CACHE_S3_BUCKET_URI, CTCM_CACHE_S3_BUCKET_URI, \
CIF_TESTING_S3_BUCKET_URI
CIF_TESTING_S3_BUCKET_URI, FILE_KEY_ADMINBOUND_MARKER, FILE_KEY_URBEXTBOUND_MARKER
Copy link
Member

Choose a reason for hiding this comment

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

FILE_KEY_ADMINBOUND_MARKER and FILE_KEY_URBEXTBOUND_MARKER have not been defined in constants

Copy link
Member Author

Choose a reason for hiding this comment

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

Added:
FILE_KEY_ADMINBOUND_MARKER = False FILE_KEY_URBEXTBOUND_MARKER = True

Copy link
Member

Choose a reason for hiding this comment

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

Are we not using the CAMS GHG layer anymore? We could keep it without importing if we may need it again in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should not be missing. I'll try to put it back in.

Copy link
Member

Choose a reason for hiding this comment

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

Same question as above. We could keep it without importing if we may need it again in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll try to put this back in. Ugh.

Copy link
Member

Choose a reason for hiding this comment

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

Same question as above. We could keep it without importing if we may need it again in the future.


@pytest.mark.skipif(EXECUTE_IGNORED_TESTS == False, reason="AWS redentials needed")
def test_isoline():
layer = Isoline({'cityname': 'KEN-Nairobi', 'amenityname': 'schools', 'travelmode': 'walk', 'threshold_type': 'time', 'threshold_value': '15', 'year': 2023})
Copy link
Member

Choose a reason for hiding this comment

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

Isoline() layer is not defined

Copy link
Member Author

Choose a reason for hiding this comment

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

The layer is now called AccessibleRegion. Also there are Accessible Count and AccessibleCountPopWeighted. I'll have to add tests.

project=project, worldpop_agesex_classes=WorldPopClass.ADULT, worldpop_year=worldpop_year, informal_only=False, **kwargs)


class _CountAccessiblePopWeightedChildren(_CountAccessiblePopWeighted):
Copy link
Member

Choose a reason for hiding this comment

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

_Children and _Elderly class is not used in the Count metrics later

Copy link
Member Author

Choose a reason for hiding this comment

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

Added them. I think we're likely not to report these in the dashboard, though.



# ************************************************
class CountPotentialEmployers__TotalPopulationPopWeightedCount(_CountAccessiblePopWeightedAll):
Copy link
Member

Choose a reason for hiding this comment

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

Keep __TotalPopulationPopWeightedCount as a unit? Or __Count? Or __People?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's make it __Count. I'll change them.

assert_metric_stats(indicator, 2, 0.79, 56.29, 100, 0)

@pytest.mark.skipif(EXECUTE_IGNORED_TESTS == False, reason="Specific files required")
def test_children_access_open_space():
Copy link
Member

Choose a reason for hiding this comment

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

Need to add more tests, at least one worldpop class per amenity.

@tedw0ng tedw0ng marked this pull request as ready for review September 30, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants