diff --git a/README.md b/README.md index 44b23c8..9be8862 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Map Italy - Along Track Grid > ([Link][2]); - +---- #### PYTHON DEPENDENCIES: - [gdal: Python's GDAL binding.][] - [fiona: Fiona is GDAL’s neat and nimble vector API for Python programmers.][] diff --git a/rm_z_coord.py b/rm_z_coord.py index 9b00528..35d93d1 100644 --- a/rm_z_coord.py +++ b/rm_z_coord.py @@ -6,7 +6,8 @@ January 2024 Remove z coordinate from a GeoDataFrame. -Convert a GeoDataFrame with z coordinate to a GeoDataFrame without z coordinate. +Convert a GeoDataFrame with z coordinate to a GeoDataFrame +without z coordinate. """ diff --git a/test/test_generate_grid.py b/test/test_generate_grid.py index 766b182..b68c1a3 100644 --- a/test/test_generate_grid.py +++ b/test/test_generate_grid.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +""" Unit tests for the generate_grid function. """ import geopandas as gpd from shapely.geometry import Polygon from generate_grid import generate_grid diff --git a/test/test_rm_z_coords.py b/test/test_rm_z_coords.py new file mode 100644 index 0000000..02e9092 --- /dev/null +++ b/test/test_rm_z_coords.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +""" Unit tests for the rm_z_coord function. """ +import geopandas as gpd +from shapely.geometry import Polygon +from rm_z_coord import rm_z_coord + + +def test_rm_z_coord(): + # Create a GeoDataFrame for testing + data = {'geometry': [Polygon([(0, 0, 1), (1, 0, 2), + (1, 1, 3), (0, 1, 4)])]} + gdf = gpd.GeoDataFrame(data, crs='EPSG:4326') + + # Apply the function + result_gdf = rm_z_coord(gdf.copy()) + + # Check if the z-coordinate is removed from the geometry + assert all(result_gdf['geometry'].apply(lambda geom: + len(geom.exterior.coords[0]) == 2))