dask-geopandas icon indicating copy to clipboard operation
dask-geopandas copied to clipboard

ENH: add crs keyword to from_dask_dataframe

Open jorisvandenbossche opened this issue 2 years ago • 2 comments

When creating a GeoDataFrame from a dask dataframe, we could pass through the crs keyword to the underlying geopandas.GeoDataFrame constructor:

https://github.com/geopandas/dask-geopandas/blob/5b49377352658e15c34cb38a43b18fcc8f833ccb/dask_geopandas/core.py#L770-L783

That avoids that you need to do a set_crs in an additional step to get a dataframe with a CRS set, as you now need to do:

gddf = dask_geopandas.from_dask_dataframe(
        ddf, geometry=dask_geopandas.points_from_xy(ddf, "lon", "lat"),
    )
gddf = gddf.set_crs(4326)

jorisvandenbossche avatar May 16 '22 15:05 jorisvandenbossche

Yeah, we could. However, you don't need an additional step as you can pass CRS to dask_geopandas.points_from_xy.

gddf = dask_geopandas.from_dask_dataframe(
        ddf, geometry=dask_geopandas.points_from_xy(ddf, "lon", "lat", crs=4326),
    )

martinfleis avatar May 16 '22 15:05 martinfleis

Great idea! I was actually just constructing dask_geopandas.from_dask_dataframe() and suprised that the crs keyword was not accepted. My next try was to use dask_geopandas.GeoDataFrame().set_geometry(col="geometry", crs="epsg:4326"), but this method also doesn't accept crs. Glad that gddf.set_crs(4326) is working, but adding the crs keyword to from_dask_dataframe and set_geometry would make sense to me :)

FlorisCalkoen avatar Jul 12 '22 10:07 FlorisCalkoen