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

update(nldi.py): Add CRS information to GeoDataFame objects #142

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dataretrieval/nldi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

NLDI_API_BASE_URL = 'https://labs.waterdata.usgs.gov/api/nldi/linked-data'
_AVAILABLE_DATA_SOURCES = None
_CRS = "EPSG:4326"


def _query_nldi(url, query_params, error_message):
Expand Down Expand Up @@ -101,7 +102,7 @@ def get_flowlines(
feature_collection = _query_nldi(url, query_params, err_msg)
if as_json:
return feature_collection
gdf = gpd.GeoDataFrame.from_features(feature_collection)
gdf = gpd.GeoDataFrame.from_features(feature_collection, crs=_CRS)
return gdf


Expand Down Expand Up @@ -154,7 +155,7 @@ def get_basin(
feature_collection = _query_nldi(url, query_params, err_msg)
if as_json:
return feature_collection
gdf = gpd.GeoDataFrame.from_features(feature_collection)
gdf = gpd.GeoDataFrame.from_features(feature_collection, crs=_CRS)
return gdf


Expand Down Expand Up @@ -291,7 +292,7 @@ def get_features(
feature_collection = _query_nldi(url, query_params, err_msg)
if as_json:
return feature_collection
gdf = gpd.GeoDataFrame.from_features(feature_collection)
gdf = gpd.GeoDataFrame.from_features(feature_collection, crs=_CRS)
return gdf


Expand Down Expand Up @@ -322,7 +323,7 @@ def get_features_by_data_source(data_source: str) -> gpd.GeoDataFrame:
url = f'{NLDI_API_BASE_URL}/{data_source}'
err_msg = f"Error getting features for data source '{data_source}'"
feature_collection = _query_nldi(url, {}, err_msg)
gdf = gpd.GeoDataFrame.from_features(feature_collection)
gdf = gpd.GeoDataFrame.from_features(feature_collection, crs=_CRS)
return gdf


Expand Down
Loading