Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geopandas v1.0.0. #162

Merged
merged 8 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- shapely
- rasterio
- fiona
- geopandas<=0.14.4
- geopandas>=1.0.0
- utm
- scipy
- numba
Expand Down
2 changes: 1 addition & 1 deletion ocsmesh/cli/remesh_by_shape_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def run(self, args):
gdf_to_refine = gpd.overlay(
gdf_to_refine, cutoff_gdf, how='intersection')

refine_polys = gdf_to_refine.unary_union
refine_polys = gdf_to_refine.union_all()

# Initial mesh for the refinement (all except refinement area)
init_jig = deepcopy(mesh.msh_t)
Expand Down
2 changes: 1 addition & 1 deletion ocsmesh/cli/subset_n_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _get_region_of_interest(self, track_file, wind_speed=34):
region_of_interest = isotach_exterior_polygon

else:
region_of_interest = gdf_roi.unary_union
region_of_interest = gdf_roi.union_all()


return region_of_interest
Expand Down
2 changes: 1 addition & 1 deletion ocsmesh/geom/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def get_multipolygon(self, **kwargs: Any) -> MultiPolygon:
[gdf, gpd.read_feather(f).to_crs(gdf.crs)]
)

mp = gdf.unary_union
mp = gdf.union_all()
if isinstance(mp, Polygon):
mp = MultiPolygon([mp])

Expand Down
2 changes: 1 addition & 1 deletion ocsmesh/hfun/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ def _get_hfun_composite_fast(self, big_hfun):
if big_hfun:
dem_gdf = gpd.GeoDataFrame(
geometry=dem_box_list, crs=epsg4326)
big_cut_shape = dem_gdf.unary_union
big_cut_shape = dem_gdf.union_all()
big_msh_t = big_hfun.msh_t()
if hasattr(big_msh_t, "crs"):
if not epsg4326.equals(big_msh_t.crs):
Expand Down
2 changes: 1 addition & 1 deletion ocsmesh/ops/combine_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def run(self):


# The assumption is this returns polygon or multipolygon
fin_mult_poly = rasters_gdf.unary_union
fin_mult_poly = rasters_gdf.union_all()
_logger.info("Done")


Expand Down
18 changes: 9 additions & 9 deletions ocsmesh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def cleanup_folded_bound_el(mesh):
# removing the erroneous elements using the triangles (clip_tri)
fixed_mesh = clip_mesh_by_shape(
mesh,
shape=clip_tri.unary_union,
shape=clip_tri.union_all(),
inverse=True,
fit_inside=True,
check_cross_edges=True,
Expand Down Expand Up @@ -1646,7 +1646,7 @@ def get_polygon_channels(polygon, width, simplify=None, join_style=3):
if p.area > width**2 * (1-np.pi/4)]))


ret_val = channels_gdf.unary_union
ret_val = channels_gdf.union_all()
if isinstance(ret_val, GeometryCollection):
return None

Expand Down Expand Up @@ -2428,7 +2428,7 @@ def triangulate_polygon(
# so no need to have for loop

if isinstance(shape, (gpd.GeoDataFrame, gpd.GeoSeries)):
shape = shape.unary_union
shape = shape.union_all()

if isinstance(shape, Polygon):
shape = MultiPolygon([shape])
Expand Down Expand Up @@ -2613,7 +2613,7 @@ def create_patch_mesh(mesh_w_problem,

patch = clip_mesh_by_shape(
mesh_for_patch.msh_t,
shape=clip_tri.unary_union,
shape=clip_tri.union_all(),
inverse=False,
fit_inside=False,
check_cross_edges=False,
Expand Down Expand Up @@ -2665,7 +2665,7 @@ def clip_mesh_by_mesh(mesh_to_be_clipped: jigsaw_msh_t,

clipped_mesh = clip_mesh_by_shape(
mesh_to_be_clipped,
shape=gdf_clipper.unary_union,
shape=gdf_clipper.union_all(),
inverse=inverse,
fit_inside=fit_inside,
check_cross_edges=check_cross_edges,
Expand Down Expand Up @@ -2736,16 +2736,16 @@ def create_mesh_from_mesh_diff(domain: Union[jigsaw_msh_t,
domain.crs = domain.estimate_utm_crs()
domain = domain.loc[domain['geometry'].area == max(domain['geometry'].area)]
domain.crs = crs
domain = gpd.GeoDataFrame(geometry=[domain.unary_union],crs=crs)
domain = gpd.GeoDataFrame(geometry=[domain.union_all()],crs=crs)

poly_buffer = domain.unary_union.difference(
poly_buffer = domain.union_all().difference(
gpd.GeoDataFrame(
geometry=[
get_mesh_polygons(mesh_1),
get_mesh_polygons(mesh_2),
],
crs = crs
).unary_union
).union_all()
)
gdf_full_buffer = gpd.GeoDataFrame(
geometry = [poly_buffer],crs=crs)
Expand Down Expand Up @@ -2986,7 +2986,7 @@ def merge_overlapping_meshes(all_msht: list,
msht
)
msht_combined = clip_mesh_by_shape(msht_combined,
domain.unary_union
domain.union_all()
)
del carved_mesh,buff_mesh,domain,msht

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ license = {file = "LICENSE"}
readme = "README.md"
requires-python = '>=3.9' # 3.8 -> scipy
dependencies = [
"colored-traceback", "fiona", "geopandas<=0.14.4",
"colored-traceback", "fiona", "geopandas>=1.0.0",
"jigsawpy", "matplotlib>=3.8", "netCDF4", "numba",
"numpy>=1.21", # introduce npt.NDArray
"pyarrow", "rtree", "pyproj>=3.0", "rasterio", "scipy",
Expand Down
8 changes: 4 additions & 4 deletions tests/api/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def test_ctor_args_4(self):

with tempfile.TemporaryDirectory() as tdir:

shape_path = tdir
shape_path = tdir + "/mysubdir"

gdf = gpd.GeoDataFrame(geometry=[self._mult_line_1], crs=self._crs_2)
gdf.to_file(shape_path)
gdf.to_file(shape_path, mode='a')

lf = LineFeature(shapefile=shape_path)
shape, crs = lf.get_multiline()
Expand Down Expand Up @@ -90,11 +90,11 @@ def test_ctor_args_6(self):

with tempfile.TemporaryDirectory() as tdir:

shape_path = tdir
shape_path = tdir + "/mysubdir"

# NOTE: This time shapefile doesn't have CRS
gdf = gpd.GeoDataFrame(geometry=[self._mult_line_1])
gdf.to_file(shape_path)
gdf.to_file(shape_path, mode='a')

lf = LineFeature(shapefile=shape_path)
with self.assertRaises(ValueError):
Expand Down
4 changes: 2 additions & 2 deletions tests/api/hfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,15 @@ def _check_applied_refinement(self, msh_t, refine_gdf, target_size):

refine_msh_t = ocsmesh.Hfun(ocsmesh.Mesh(ocsmesh.utils.clip_mesh_by_shape(
mesh=msh_t,
shape=refine_gdf.unary_union,
shape=refine_gdf.union_all(),
fit_inside=True,
inverse=False
)))
refine_msh_t.size_from_mesh()
refine_avg = np.mean(refine_msh_t.msh_t().value)
rest_msh_t = ocsmesh.Hfun(ocsmesh.Mesh(ocsmesh.utils.clip_mesh_by_shape(
mesh=msh_t,
shape=refine_gdf.unary_union,
shape=refine_gdf.union_all(),
fit_inside=False,
inverse=True
)))
Expand Down
Loading