Skip to content

Commit

Permalink
test_rm_z_coords.py - Added - use pytest to test rm_z_coords.py
Browse files Browse the repository at this point in the history
  • Loading branch information
eciraci committed Jan 26, 2024
1 parent 0f82045 commit 89d3023
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.][]
Expand Down
3 changes: 2 additions & 1 deletion rm_z_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""


Expand Down
2 changes: 2 additions & 0 deletions test/test_generate_grid.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/test_rm_z_coords.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 89d3023

Please sign in to comment.