Skip to content

Commit

Permalink
Merge pull request #54 from wri/fix/setup_requires
Browse files Browse the repository at this point in the history
update setup
  • Loading branch information
chrowe authored Jul 30, 2024
2 parents 2beecec + 77037d6 commit ec81280
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion city_metrix/layers/smart_surface_lulc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import psutil
from exactextract import exact_extract
import pickle
import importlib.resources as pkg_resources
import warnings
warnings.filterwarnings('ignore',category=UserWarning)

Expand All @@ -24,7 +25,7 @@ def get_data(self, bbox):
crs = get_utm_zone_epsg(bbox)

# load building roof slope classifier
with open('city_metrix/models/building_classifier/building_classifier.pkl', 'rb') as f:
with pkg_resources.files('city_metrix.models.building_classifier').joinpath('building_classifier.pkl').open('rb') as f:
clf = pickle.load(f)

# ESA world cover
Expand Down
Empty file added city_metrix/models/__init__.py
Empty file.
Empty file.
18 changes: 15 additions & 3 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `city_metrix` library allows users of geospatial data to collect and apply z
It provides two main functionalities:
1. Extracting geospatial `layers` based on specific areas of interests (defined as geodataframe)' These data layers are collected from any cloud source (Google Earth Engine, AWS S3 public buckets, Public APIs). Two formats of data layers are handled in `city_metrix`: Rasters and vectors.
- Rasters data are collected and transformed into _arrays_ using `xarray` (GEE images collections are converted also into `arrays` using `xee`).
- Vectors adata are stored as `GeoDataFrame`.
- Vectors data are stored as `GeoDataFrame`.
2. Measuring `indicators` using the extracted `layers` by implementing zonal statistics operations

The main package source code is located in the `city_metrix` directory.
Expand Down Expand Up @@ -81,9 +81,11 @@ Hopefully we already have the layers you need in `city_metrix/layers/` and you c

5. Add a test to [tests/layers.py](../tests/layers.py) to ensure the new layer is working as expected.

6. Add a section to the get layers.ipynb notebook to demonstrate how to use the new layer.
6. Add new dependencies to [setup.py](../setup.py) and [environment.yml](../environment.yml).

7. Create a PR to merge the new layer into the main branch with these in the PR description:
7. Add a section to the get layers.ipynb notebook to demonstrate how to use the new layer.

8. Create a PR to merge the new layer into the main branch with these in the PR description:
- Link to Jira ticket (if any)
- A brief description of the new layer
- A link to the Airtable record for the new layer
Expand All @@ -101,6 +103,16 @@ Once you have all the data layers you need as inputs, here is the process to cre

Define a function for new indicator with the input of the calculation zones as a `GeoDataFrame` and output of the calculated indicators as a `GeoSeries`.

3. Add a test to [tests/metrics.py](../tests/metrics.py) to ensure the new indicator is working as expected.

4. Add new dependencies to [setup.py](../setup.py) and [environment.yml](../environment.yml).

5. Create a PR to merge the new indicator into the main branch with these in the PR description:
- Link to Jira ticket (if any)
- A brief description of the new indicator
- A link to the Airtable record for the new indicator
- Explain how to test the new indicator


## Adding Cities
You can always have users just provide their own boudary files, but if you are working on a project where you want to provide access to a common set of city boundaries, the best option is to add them to the API
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ dependencies:
- boto3=1.34.124
- scikit-learn=1.5.0
- pip:
- cartoframes==1.2.5
- git+https://github.com/isciences/exactextract
- overturemaps==0.6.0
18 changes: 14 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from setuptools import setup
from setuptools import setup, find_packages

setup(
name="city_metrix",
version="0.1.0",
version="0.1.1",
description="Module to calculate various metrics on cities.",
packages=["city_metrix", "city_metrix.layers", "city_metrix.metrics"],
packages=find_packages(),
include_package_data=True,
package_data={
'city_metrix.models.building_classifier': [
'building_classifier.pkl',
],
},
author="Justin Terry",
license="MIT",
install_requires=[
Expand All @@ -16,10 +22,14 @@
"xarray-spatial",
"xee",
"rioxarray",
"cartoframes",
"utm",
"osmnx",
"geopandas",
"s3fs",
"dask>=2023.11.0",
"boto3",
"exactextract",
"overturemaps",
"scikit-learn>=1.5.0",
],
)

0 comments on commit ec81280

Please sign in to comment.