@@ -596,6 +596,58 @@ class _Sentinel:
596596 assert isinstance (result , _Sentinel )
597597
598598
599+ def test_get_resp_data_attaches_wgs84_crs ():
600+ """A geometry-bearing Water Data page should come back tagged as
601+ EPSG:4326 (the CRS the coordinates are published in), so callers can
602+ run ``to_crs`` / spatial joins without first patching in a CRS by
603+ hand. Regression for the ``.crs is None`` reported in issue #342."""
604+ geopandas = pytest .importorskip ("geopandas" )
605+
606+ resp = _resp_ok (
607+ [
608+ {
609+ "type" : "Feature" ,
610+ "id" : "USGS-01" ,
611+ "geometry" : {"type" : "Point" , "coordinates" : [- 76.5 , 39.2 ]},
612+ "properties" : {"monitoring_location_id" : "USGS-01" },
613+ }
614+ ]
615+ )
616+ df = _get_resp_data (resp , geopd = True )
617+ assert isinstance (df , geopandas .GeoDataFrame )
618+ assert df .crs == "EPSG:4326"
619+
620+
621+ def test_handle_nesting_attaches_wgs84_crs ():
622+ """The stats path builds its GeoDataFrame the same way, so it should
623+ carry EPSG:4326 too (issue #342)."""
624+ geopandas = pytest .importorskip ("geopandas" )
625+
626+ body = {
627+ "next" : None ,
628+ "features" : [
629+ {
630+ "type" : "Feature" ,
631+ "geometry" : {"type" : "Point" , "coordinates" : [- 76.5 , 39.2 ]},
632+ "properties" : {
633+ "monitoring_location_id" : "USGS-01" ,
634+ "data" : [
635+ {
636+ "parameter_code" : "00060" ,
637+ "unit_of_measure" : "ft^3/s" ,
638+ "parent_time_series_id" : "ts-1" ,
639+ "values" : [{"statistic_id" : "mean" , "value" : 10.0 }],
640+ }
641+ ],
642+ },
643+ }
644+ ],
645+ }
646+ df = _handle_nesting (body , geopd = True )
647+ assert isinstance (df , geopandas .GeoDataFrame )
648+ assert df .crs == "EPSG:4326"
649+
650+
599651def test_handle_nesting_tolerates_missing_features_key ():
600652 """A 200 response with a body that doesn't carry ``features`` at
601653 all (rare but seen in error envelopes) must also short-circuit
0 commit comments