Skip to content

Commit

Permalink
#228 update transects str and repr funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
2320sharon committed Feb 22, 2024
1 parent 9701a4a commit 2640d64
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/coastseg/transects.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ def __str__(self):
# Get first 5 rows as a string
first_rows = self.gdf.head().to_string()
# Get CRS information
crs_info = f"CRS: {self.gdf.crs}" if self.gdf.crs else "CRS: None"
if self.gdf.empty:
crs_info = "CRS: None"
else:
if self.gdf is not None and hasattr(self.gdf, 'crs'):
crs_info = f"CRS: {self.gdf.crs}" if self.gdf.crs else "CRS: None"
else:
crs_info = "CRS: None"
ids = ""
if "id" in self.gdf.columns:
ids = self.gdf["id"].astype(str)
Expand All @@ -273,7 +279,13 @@ def __repr__(self):
# Get first 5 rows as a string
first_rows = self.gdf.head().to_string()
# Get CRS information
crs_info = f"CRS: {self.gdf.crs}" if self.gdf.crs else "CRS: None"
if self.gdf.empty:
crs_info = "CRS: None"
else:
if self.gdf is not None and hasattr(self.gdf, 'crs'):
crs_info = f"CRS: {self.gdf.crs}" if self.gdf.crs else "CRS: None"
else:
crs_info = "CRS: None"
ids = ""
if "id" in self.gdf.columns:
ids = self.gdf["id"].astype(str)
Expand Down

0 comments on commit 2640d64

Please sign in to comment.