From 1d8514da2de7f915482bc4e09cfb75375b55ceb5 Mon Sep 17 00:00:00 2001 From: nkorinek Date: Fri, 28 Feb 2020 12:15:20 -0700 Subject: [PATCH 1/4] Changing the modis hdf dataset to H4 to accurately represent the data that's contained. It's not actually h5 data. --- docs/earthpy-data-subsets.rst | 4 ++-- docs/get-started.rst | 2 +- earthpy/io.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/earthpy-data-subsets.rst b/docs/earthpy-data-subsets.rst index 26d592ef..6c6afbfd 100644 --- a/docs/earthpy-data-subsets.rst +++ b/docs/earthpy-data-subsets.rst @@ -49,13 +49,13 @@ natural earth, including global roads, political boundaries, and populated places. Finally, there are NEON Lidar data and insitu measurements for SOAP and SJER sites. -cold-springs-modis-h5 +cold-springs-modis-h4 --------------------- This dataset contains imagery from the Moderate Resolution Imaging Spectrometer `(MODIS) `_ maintained by NASA. `The satellite data `_ -are for the 2016 Cold Springs fire near Nederland, CO. and are in h5 format. +are for the 2016 Cold Springs fire near Nederland, CO. and are in h4 format. cold-springs-fire ----------------- diff --git a/docs/get-started.rst b/docs/get-started.rst index 37787efa..4b5b38fd 100644 --- a/docs/get-started.rst +++ b/docs/get-started.rst @@ -55,6 +55,6 @@ You can access these data subsets by using: >>> import earthpy as et >>> # View all available data keys >>> et.data.get_data() - Available Datasets: ['california-rim-fire', 'co-flood-extras', 'cold-springs-fire', 'cold-springs-modis-h5', 'colorado-flood', 'cs-test-landsat', 'cs-test-naip', 'ndvi-automation', 'spatial-vector-lidar', 'twitter-flood', 'vignette-elevation', 'vignette-landsat'] + Available Datasets: ['california-rim-fire', 'co-flood-extras', 'cold-springs-fire', 'cold-springs-modis-h4', 'colorado-flood', 'cs-test-landsat', 'cs-test-naip', 'ndvi-automation', 'spatial-vector-lidar', 'twitter-flood', 'vignette-elevation', 'vignette-landsat'] >>> # Download data subset to your `$HOME/earth-analytics/data` directory >>> data = et.data.get_data('cold-springs-fire', verbose=False) diff --git a/earthpy/io.py b/earthpy/io.py index fd260b6a..349e63f1 100644 --- a/earthpy/io.py +++ b/earthpy/io.py @@ -40,7 +40,7 @@ ".", "zip", ), - "cold-springs-modis-h5": ( + "cold-springs-modis-h4": ( "https://ndownloader.figshare.com/files/10960112", ".", "zip", From c1f5b1b5732b5953059650390e18d4fcdccfb7d8 Mon Sep 17 00:00:00 2001 From: nkorinek Date: Thu, 5 Mar 2020 11:36:33 -0700 Subject: [PATCH 2/4] Fixing CRS issues --- earthpy/tests/conftest.py | 12 +++++------- earthpy/tests/test_clip.py | 27 ++++++++------------------- earthpy/tests/test_io.py | 6 +++--- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/earthpy/tests/conftest.py b/earthpy/tests/conftest.py index 7ed13aa5..fc716cb8 100644 --- a/earthpy/tests/conftest.py +++ b/earthpy/tests/conftest.py @@ -52,7 +52,7 @@ def basic_image_tif(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image.tif")) kwargs = { - "crs": rio.crs.CRS({"init": "epsg:4326"}), + "crs": rio.crs.CRS("epsg:4326"), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -78,7 +78,7 @@ def basic_image_tif_2(tmpdir, basic_image_2): """ outfilename = str(tmpdir.join("basic_image_2.tif")) kwargs = { - "crs": rio.crs.CRS({"init": "epsg:4326"}), + "crs": rio.crs.CRS("epsg:4326"), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -104,7 +104,7 @@ def basic_image_tif_CRS(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image_CRS.tif")) kwargs = { - "crs": rio.crs.CRS({"init": "epsg:3857"}), + "crs": rio.crs.CRS("epsg:3857"), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -130,7 +130,7 @@ def basic_image_tif_Affine(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image_Affine.tif")) kwargs = { - "crs": rio.crs.CRS({"init": "epsg:4326"}), + "crs": rio.crs.CRS("epsg:4326"), "transform": Affine(2.0, 0.0, 0.0, 0.0, 2.0, 0.0), "count": 1, "dtype": rio.uint8, @@ -179,9 +179,7 @@ def basic_geometry_gdf(basic_geometry): ------- GeoDataFrame containing the basic_geometry polygon """ - gdf = gpd.GeoDataFrame( - geometry=[basic_geometry], crs={"init": "epsg:4326"} - ) + gdf = gpd.GeoDataFrame(geometry=[basic_geometry], crs="epsg:4326") return gdf diff --git a/earthpy/tests/test_clip.py b/earthpy/tests/test_clip.py index 8e050af6..fda95e23 100644 --- a/earthpy/tests/test_clip.py +++ b/earthpy/tests/test_clip.py @@ -13,9 +13,7 @@ def point_gdf(): """ Create a point GeoDataFrame. """ pts = np.array([[2, 2], [3, 4], [9, 8], [-12, -15]]) gdf = gpd.GeoDataFrame( - [Point(xy) for xy in pts], - columns=["geometry"], - crs={"init": "epsg:4326"}, + [Point(xy) for xy in pts], columns=["geometry"], crs="epsg:4326", ) return gdf @@ -24,9 +22,7 @@ def point_gdf(): def single_rectangle_gdf(): """Create a single rectangle for clipping. """ poly_inters = Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)]) - gdf = gpd.GeoDataFrame( - [1], geometry=[poly_inters], crs={"init": "epsg:4326"} - ) + gdf = gpd.GeoDataFrame([1], geometry=[poly_inters], crs="epsg:4326") gdf["attr2"] = "site-boundary" return gdf @@ -39,9 +35,7 @@ def larger_single_rectangle_gdf(): are returned when you clip polygons. This fixture is larger which eliminates the slivers in the clip return.""" poly_inters = Polygon([(-5, -5), (-5, 15), (15, 15), (15, -5), (-5, -5)]) - gdf = gpd.GeoDataFrame( - [1], geometry=[poly_inters], crs={"init": "epsg:4326"} - ) + gdf = gpd.GeoDataFrame([1], geometry=[poly_inters], crs="epsg:4326") gdf["attr2"] = ["study area"] return gdf @@ -69,9 +63,7 @@ def two_line_gdf(): """ Create Line Objects For Testing """ linea = LineString([(1, 1), (2, 2), (3, 2), (5, 3)]) lineb = LineString([(3, 4), (5, 7), (12, 2), (10, 5), (9, 7.5)]) - gdf = gpd.GeoDataFrame( - [1, 2], geometry=[linea, lineb], crs={"init": "epsg:4326"} - ) + gdf = gpd.GeoDataFrame([1, 2], geometry=[linea, lineb], crs="epsg:4326") return gdf @@ -80,7 +72,7 @@ def multi_poly_gdf(donut_geometry): """ Create a multi-polygon GeoDataFrame. """ multi_poly = donut_geometry.unary_union out_df = gpd.GeoDataFrame( - geometry=gpd.GeoSeries(multi_poly), crs={"init": "epsg:4326"} + geometry=gpd.GeoSeries(multi_poly), crs="epsg:4326" ) out_df = out_df.rename(columns={0: "geometry"}).set_geometry("geometry") out_df["attr"] = ["pool"] @@ -97,8 +89,7 @@ def multi_line(two_line_gdf): multiline_feat = two_line_gdf.unary_union linec = LineString([(2, 1), (3, 1), (4, 1), (5, 2)]) out_df = gpd.GeoDataFrame( - geometry=gpd.GeoSeries([multiline_feat, linec]), - crs={"init": "epsg:4326"}, + geometry=gpd.GeoSeries([multiline_feat, linec]), crs="epsg:4326", ) out_df = out_df.rename(columns={0: "geometry"}).set_geometry("geometry") out_df["attr"] = ["road", "stream"] @@ -113,7 +104,7 @@ def multi_point(point_gdf): gpd.GeoSeries( [multi_point, Point(2, 5), Point(-11, -14), Point(-10, -12)] ), - crs={"init": "epsg:4326"}, + crs="epsg:4326", ) out_df = out_df.rename(columns={0: "geometry"}).set_geometry("geometry") out_df["attr"] = ["tree", "another tree", "shrub", "berries"] @@ -137,9 +128,7 @@ def test_returns_gdf(point_gdf, single_rectangle_gdf): def test_non_overlapping_geoms(): """Test that a bounding box returns error if the extents don't overlap""" unit_box = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]) - unit_gdf = gpd.GeoDataFrame( - [1], geometry=[unit_box], crs={"init": "epsg:4326"} - ) + unit_gdf = gpd.GeoDataFrame([1], geometry=[unit_box], crs="epsg:4326") non_overlapping_gdf = unit_gdf.copy() non_overlapping_gdf = non_overlapping_gdf.geometry.apply( lambda x: shapely.affinity.translate(x, xoff=20) diff --git a/earthpy/tests/test_io.py b/earthpy/tests/test_io.py index 5a758e03..f03894dc 100644 --- a/earthpy/tests/test_io.py +++ b/earthpy/tests/test_io.py @@ -69,21 +69,21 @@ def test_colorado_counties(): """ Check assumptions about county polygons. """ counties = gpd.read_file(eio.path_to_example("colorado-counties.geojson")) assert counties.shape == (64, 13) - assert counties.crs == {"init": "epsg:4326"} + assert counties.crs == "epsg:4326" def test_colorado_glaciers(): """ Check assumptions about glacier point locations. """ glaciers = gpd.read_file(eio.path_to_example("colorado-glaciers.geojson")) assert glaciers.shape == (134, 2) - assert glaciers.crs == {"init": "epsg:4326"} + assert glaciers.crs == "epsg:4326" def test_continental_divide_trail(): """ Check assumptions about Continental Divide Trail path. """ cdt = gpd.read_file(eio.path_to_example("continental-div-trail.geojson")) assert cdt.shape == (1, 2) - assert cdt.crs == {"init": "epsg:4326"} + assert cdt.crs == "epsg:4326" """ Tests for the EarthlabData class. """ From 66ee79b4a224f26c743839218e7c18e7f289d8bc Mon Sep 17 00:00:00 2001 From: nkorinek Date: Thu, 5 Mar 2020 11:48:43 -0700 Subject: [PATCH 3/4] fixing more crs issues --- earthpy/tests/conftest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/earthpy/tests/conftest.py b/earthpy/tests/conftest.py index fc716cb8..96f12aa8 100644 --- a/earthpy/tests/conftest.py +++ b/earthpy/tests/conftest.py @@ -52,7 +52,7 @@ def basic_image_tif(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image.tif")) kwargs = { - "crs": rio.crs.CRS("epsg:4326"), + "crs": rio.crs.CRS({"init": "epsg:4326"}), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -78,7 +78,7 @@ def basic_image_tif_2(tmpdir, basic_image_2): """ outfilename = str(tmpdir.join("basic_image_2.tif")) kwargs = { - "crs": rio.crs.CRS("epsg:4326"), + "crs": rio.crs.CRS({"init": "epsg:4326"}), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -104,7 +104,7 @@ def basic_image_tif_CRS(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image_CRS.tif")) kwargs = { - "crs": rio.crs.CRS("epsg:3857"), + "crs": rio.crs.CRS({"init": "epsg:3857"}), "transform": Affine.identity(), "count": 1, "dtype": rio.uint8, @@ -130,7 +130,7 @@ def basic_image_tif_Affine(tmpdir, basic_image): """ outfilename = str(tmpdir.join("basic_image_Affine.tif")) kwargs = { - "crs": rio.crs.CRS("epsg:4326"), + "crs": rio.crs.CRS({"init": "epsg:4326"}), "transform": Affine(2.0, 0.0, 0.0, 0.0, 2.0, 0.0), "count": 1, "dtype": rio.uint8, From 1bcae4f7c54add62ecb079dfd762e40499ce7e9d Mon Sep 17 00:00:00 2001 From: nkorinek Date: Thu, 5 Mar 2020 12:12:00 -0700 Subject: [PATCH 4/4] More CI fixes --- docs/earthpy-data-subsets.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/earthpy-data-subsets.rst b/docs/earthpy-data-subsets.rst index 6c6afbfd..b80bd6f9 100644 --- a/docs/earthpy-data-subsets.rst +++ b/docs/earthpy-data-subsets.rst @@ -63,7 +63,7 @@ cold-springs-fire This dataset contains satellite and vector data for the `2016 Cold Springs fire near Nederland, CO `_. The imagery used for this dataset comes from MODIS, National Agriculture -Imagery Program `(NAIP) `_ +Imagery Program `(NAIP) `_ (provided by the US Department of Agriculture), and Land-Use Satellite `(Landsat) `_ (provided by the USGS).