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

Add support for force_2d with use_arrow=True in read_dataframe #300

Conversation

theroggy
Copy link
Member

@theroggy theroggy commented Sep 30, 2023

reference #297

Once #304 is merged, an extra use_arrow check can be activated or the other way around.

@theroggy theroggy marked this pull request as ready for review September 30, 2023 08:02
@theroggy theroggy added this to the 0.7.0 milestone Sep 30, 2023
@theroggy theroggy changed the title Add support in read_dataframe for force_2d for use_arrow=True Add support for force_2d with use_arrow=True in read_dataframe Sep 30, 2023
Copy link
Member

@brendan-ward brendan-ward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a note to the docstring for read_dataframe stating that shapely is used to force 2D geometries after reading when use_arrow is True?

I think you could move use of shapely down to read_arrow (i.e., make shapely a requirement to use force_2d in read_arrow) and conditionally attempt to import shapely if force_2d is True and raise an ImportError if it isn't present.

pyogrio/geopandas.py Outdated Show resolved Hide resolved
@theroggy
Copy link
Member Author

theroggy commented Oct 3, 2023

Should we add a note to the docstring for read_dataframe stating that shapely is used to force 2D geometries after reading when use_arrow is True?

At first sight, I don't think it adds a lot of useful information to the user whether the conversion is done by shapely or by gdal?

I think you could move use of shapely down to read_arrow (i.e., make shapely a requirement to use force_2d in read_arrow) and conditionally attempt to import shapely if force_2d is True and raise an ImportError if it isn't present.

Yes, it indeed seems possible. Do we want to keep the interface of read_arrow stable or is it possible to change it? The geometry column returned is now a wkb, but when the force_2d logic moves there, the wkb conversion to shapely object needs to be done there as well before shapely.force_2d can be applied. Do I convert back to wkb there... to do the conversion again in geopandas.py... or do I return shapely objects in read_arrow or do I add a parameter to choose what is being returned?

@jorisvandenbossche
Copy link
Member

I think we want to keep read_arrow independent from shapely, so this function can be used in cases you don't need GEOS objects (so IMO it should certainly not return shapely objects).

Given that, I assume it is easier to keep this handling on the read_dataframe side, where we do a conversion to shapely/GEOS objects anyway.

@brendan-ward
Copy link
Member

Whoops, I forgot about the conversion from WKB and thought we were already using shapely objects in read_arrow (not sure why I thought this, poor memory plus not reading the code again). Let's leave that as is, and do this only in read_dataframe.

@jorisvandenbossche jorisvandenbossche merged commit 4fe4abe into geopandas:main Oct 13, 2023
15 checks passed
@jorisvandenbossche
Copy link
Member

Thanks!

@theroggy theroggy deleted the Add-support-in-read_dataframe-for-force_2d-for-use_arrow=True branch October 13, 2023 11:42
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

Successfully merging this pull request may close these issues.

3 participants