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

Copy spatial_partitions when copying GeoDataFrame #55

Closed
DahnJ opened this issue Jun 12, 2021 · 2 comments
Closed

Copy spatial_partitions when copying GeoDataFrame #55

DahnJ opened this issue Jun 12, 2021 · 2 comments

Comments

@DahnJ
Copy link
Contributor

DahnJ commented Jun 12, 2021

I would expect the spatial_partitions to be copied when using df.copy().

import geopandas
import dask
import dask_geopandas
dask.config.set(scheduler='single-threaded')

df = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
ddf = dask_geopandas.from_geopandas(df, npartitions=4)
ddf.calculate_spatial_partitions()
ddfc = ddf.copy()
ddfc.spatial_partitions  # is None

Is there a reason to not copy spatial partitions that I didn't think of?

I thought about how this could work and didn't think of anything better than overriding dask's copy method. Something like

def copy(self):
    self_copy = super().copy()
    self_copy.spatial_partitions = self.spatial_partitions
    return self_copy

It would be great if spatial_partitions could get copied automatically, as crs for example does. However, crs is actually a property of _meta, which does get automatically copied by dask. Not sure how spatial partitions could be attached to the _meta, or if there's another mechanism that could act similarly.

If I'm headed in the right direction, then I'm happy to unit test & PR.

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Jun 12, 2021 via email

DahnJ added a commit to DahnJ/dask-geopandas that referenced this issue Jun 15, 2021
This is possibly only a short-term solution,
see discussion at 
geopandas#55
@martinfleis
Copy link
Member

Closed by #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants