|
42 | 42 | "source": [ |
43 | 43 | "world = gpd.read_file('https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip')\n", |
44 | 44 | "us = world[world.NAME.isin(['United States of America', 'Puerto Rico'])]\n", |
45 | | - "us_coast = us.boundary.intersection(world.unary_union.boundary)\n", |
46 | | - "ax = world.plot(color='k', alpha=0.1)\n", |
47 | | - "us.plot(ax=ax, color='b', alpha=0.2)\n", |
48 | | - "us_coast.plot(ax=ax, color='r')" |
| 45 | + "ax = us.plot(color='b', alpha=0.2)" |
49 | 46 | ] |
50 | 47 | }, |
51 | 48 | { |
|
57 | 54 | }, |
58 | 55 | "outputs": [], |
59 | 56 | "source": [ |
| 57 | + "import shapely\n", |
| 58 | + "\n", |
60 | 59 | "params_of_interest = ['62620', '62615']\n", |
61 | | - "region_of_interest = us_coast.unary_union.buffer(0.5) # Buffer coast lines to overlap with some stations." |
| 60 | + "\n", |
| 61 | + "# Use the Gulf Coast region as a demonstration area\n", |
| 62 | + "# For the full US coast, expand the bounding box (slower query)\n", |
| 63 | + "region_bbox = [-90, 28, -82, 31] # Gulf Coast: LA/MS/AL/FL panhandle\n", |
| 64 | + "region_of_interest = shapely.geometry.box(*region_bbox)" |
62 | 65 | ] |
63 | 66 | }, |
64 | 67 | { |
65 | 68 | "cell_type": "markdown", |
66 | 69 | "id": "4", |
67 | 70 | "metadata": {}, |
68 | 71 | "source": [ |
69 | | - "Note that currently USGS implemented all parameters of interest by CERA workflow, for further filtering one needs to fetch all and then filter. Also note that currently `stations.get_stations` API doesn't have paramter information." |
| 72 | + "Note that the modernized Water Data API separates station metadata from parameter availability. Use `include_parameter_availability=True` to get `has_water_level`, `has_temperature`, `has_salinity`, and `has_currents` columns." |
70 | 73 | ] |
71 | 74 | }, |
72 | 75 | { |
|
78 | 81 | }, |
79 | 82 | "outputs": [], |
80 | 83 | "source": [ |
81 | | - "#usgs_stations = stations.get_stations(providers='USGS', region=region_of_interest)\n", |
82 | | - "usgs_stations = usgs.get_usgs_stations(region=region_of_interest)\n", |
| 84 | + "# Query stations in the region by bounding box with parameter availability\n", |
| 85 | + "usgs_stations = usgs.get_usgs_stations(\n", |
| 86 | + " bbox=region_bbox,\n", |
| 87 | + " include_parameter_availability=True,\n", |
| 88 | + ")\n", |
83 | 89 | "usgs_stations" |
84 | 90 | ] |
85 | 91 | }, |
|
105 | 111 | }, |
106 | 112 | "outputs": [], |
107 | 113 | "source": [ |
108 | | - "usgs_stations_w_param = usgs_stations[usgs_stations.parm_cd.isin(params_of_interest)]\n", |
109 | | - "is_active = np.logical_or((datetime.now() - usgs_stations_w_param.end_date) < timedelta(days=3), usgs_stations_w_param.end_date.isnull())\n", |
110 | | - "usgs_stations_of_interest = usgs_stations_w_param[is_active]" |
| 114 | + "# Filter to stations with water level data (params 62620, 62615 are water level elevation codes)\n", |
| 115 | + "# The modernized API provides has_water_level via include_parameter_availability=True\n", |
| 116 | + "usgs_stations_of_interest = usgs_stations[usgs_stations.has_water_level == True].copy()\n", |
| 117 | + "usgs_stations_of_interest" |
111 | 118 | ] |
112 | 119 | }, |
113 | 120 | { |
|
0 commit comments