Skip to content

Commit

Permalink
Fix deprecation warnings pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
smknaake committed Jan 28, 2025
1 parent 3f9b884 commit 6fb3c22
Show file tree
Hide file tree
Showing 6 changed files with 13,997 additions and 20,706 deletions.
20 changes: 13 additions & 7 deletions geost/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ def change_horizontal_reference(self, to_epsg: str | int | CRS):
As Pyproj is very flexible, you can even use the CRS's full official name:
>>> self.change_horizontal_reference("WGS 84 / UTM zone 31N")
"""
transformer = horizontal_reference_transformer(
self.horizontal_reference, to_epsg
)
self._gdf = self.gdf.to_crs(to_epsg)
self._gdf.loc[:, "x"], self._gdf.loc[:, "y"] = transformer.transform(
self._gdf["x"], self._gdf["y"]
)
self._gdf[["x", "y"]] = self._gdf[["x", "y"]].astype(float)
self._gdf["x"] = self._gdf["geometry"].x
self._gdf["y"] = self._gdf["geometry"].y

def change_vertical_reference(self, to_epsg: str | int | CRS):
"""
Expand Down Expand Up @@ -163,6 +161,7 @@ def change_vertical_reference(self, to_epsg: str | int | CRS):
transformer = vertical_reference_transformer(
self.horizontal_reference, self.vertical_reference, to_epsg
)
self.gdf[["surface", "end"]] = self.gdf[["surface", "end"]].astype(float)
_, _, new_surface = transformer.transform(
self.gdf["x"], self.gdf["y"], self.gdf["surface"]
)
Expand Down Expand Up @@ -931,7 +930,7 @@ def get_cumulative_thickness(self, column: str, values: str | List[str]):
"""
selected_layers = self.slice_by_values(column, values)
cum_thickness = selected_layers.df.groupby(["nr", column]).apply(
cumulative_thickness
cumulative_thickness, include_groups=False
)
cum_thickness = cum_thickness.unstack(level=column)
return cum_thickness
Expand Down Expand Up @@ -1734,10 +1733,14 @@ def change_horizontal_reference(self, to_epsg: str | int | CRS):
transformer = horizontal_reference_transformer(
self.horizontal_reference, to_epsg
)
self.data.df[["x", "y"]] = self.data.df[["x", "y"]].astype(float)
self.data.df.loc[:, "x"], self.data.df.loc[:, "y"] = transformer.transform(
self.data["x"], self.data["y"]
)
if self.data.has_inclined:
self.data.df[["x_bot", "y_bot"]] = self.data.df[["x_bot", "y_bot"]].astype(
float
)
self.data.df.loc[:, "x_bot"], self.data.df.loc[:, "y_bot"] = (
transformer.transform(self.data["x_bot"], self.data["y_bot"])
)
Expand Down Expand Up @@ -1782,6 +1785,9 @@ def change_vertical_reference(self, to_epsg: str | int | CRS):
transformer = vertical_reference_transformer(
self.horizontal_reference, self.vertical_reference, to_epsg
)
self.data.df[["surface", "end"]] = self.data.df[["surface", "end"]].astype(
float
)
_, _, new_surface = transformer.transform(
self.data["x"], self.data["y"], self.data["surface"]
)
Expand Down
9 changes: 5 additions & 4 deletions geost/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,12 @@ def get_bro_objects_from_geometry(
else:
geometry = gpd.read_file(geometry_file)
api = BroApi()
xmin, ymin, xmax, ymax = geometry.total_bounds
api.search_objects_in_bbox(
xmin=geometry.bounds.minx.values[0],
xmax=geometry.bounds.maxx.values[0],
ymin=geometry.bounds.miny.values[0],
ymax=geometry.bounds.maxy.values[0],
xmin=xmin,
xmax=xmax,
ymin=ymin,
ymax=ymax,
object_type=object_type,
)
bro_objects = api.get_objects(api.object_list, object_type=object_type)
Expand Down
Loading

0 comments on commit 6fb3c22

Please sign in to comment.