Skip to content

Commit

Permalink
cmougan#10, cmougan#20 Adds information for command line app for nig…
Browse files Browse the repository at this point in the history
…ht lights to README.md
  • Loading branch information
sunayana committed May 3, 2021
1 parent bcff486 commit 1f5c71a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,18 @@ Add [this](https://github.com/cmougan/WRI_WellBeing_Data_Layer) repository as a

For further instructions for setting up, please follow the steps [here](./dssg/README.md)
### Main Components
The main modules are as follows:
- `osm_data_extraction` module, which has the following features :
The main components are as follows:
- Module `osm_data_extraction`, which has the following features :
- Extract GeoDataFrame of a district from a country GADM Level 2 shapefile.
- Plots the boundary of a given district along with the corresponding map tile from Open Street Maps.
- Retrieves and writes the map tile corresponding to the geo dataframe to a geotiff file.
- Plots a geotiff file.
- Creates the polygon and the corresponding graph for a given geo dataframe of a district. This is finally used to visualize the knots and edges model.
- A dictionary of tags, `default_tags = {amenity': True, 'building': True, 'emergency': True,
'highway': True, 'footway': True, 'landuse': True, 'water': True}` is used to extract relevant features and ammenities from the OSM API for a given district.

- Module `ntl_data_extraction` and command line app `download-nightlights.py`
- The command line app uses the methods in the module to download night time light hdf5 files for a given district and a specific time range and convert them to geotiff format. Since the hdf5 files cover a large area and may contain many districts we have added a check and it is downloaded only if it has not been downloaded earlier for another district.
### Contribution Guidelines
In general we follow the [GitHub Forking Workflow](https://guides.github.com/activities/forking/)
#### On GitHub
Expand Down
27 changes: 25 additions & 2 deletions dssg/dataio/ntl_data_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
from gdalconst import *


def download_url(url: str):
def download_url(url: str) -> str:
"""Given a url for h5 file checks if the file exists in the pre-defined NTL_HDF5_DIR
and downloads it if it does not exist.
Args:
url (str): web url of the hdf5 file
Returns:
str: url
"""
print("downloading: ", url)
# assumes that the last segment after the / represents the file name
filepath = os.environ.get("NTL_HDF5_DIR")
Expand All @@ -25,7 +34,21 @@ def download_url(url: str):
return url


def get_ntl_file_urls(district_gdf: gpd.geodataframe.GeoDataFrame, products: str, startTime: str, endTime: str, collection: int, district_json_file: str):
def get_ntl_file_urls(district_gdf: gpd.geodataframe.GeoDataFrame, products: str, startTime: str, endTime: str,
collection: int, district_json_file: str) -> list:
"""Given a district geo dataframe and a specific product
Args:
district_gdf (gpd.geodataframe.GeoDataFrame): [description]
products (str): [description]
startTime (str): [description]
endTime (str): [description]
collection (int): [description]
district_json_file (str): [description]
Returns:
list: [description]
"""
(w, s, e, n) = ode.district_extents(district_gdf)
# Create a ModapsClient object
a = modapsclient.ModapsClient()
Expand Down

0 comments on commit 1f5c71a

Please sign in to comment.