-
Notifications
You must be signed in to change notification settings - Fork 902
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
ENH: support multiple geometry columns in read_postgis #3138
Comments
I'd like to have a go at this one if no one else is currently working on this. |
Probably a few different ways to cut this, the changes would need to be made to Would we want to extend Or would we want a new kwarg to accept additional geometry columns that would not subsequently become the geodataframe's geometry column? |
Feel free! There are a few rough edges like this in our postgis support.
I would lean toward this option - I prefer that we're still explicit about which column is the active geometry column, rather than doing something implicit based on ordering (and also that might get confused with trying to control the order of the columns in the returned geodataframe) Another option is to accept a string or list of strings as geom col, with a new kwarg to accept the primary geometry column, but I think that's not as clean to work with. |
Would it actually be possible to infer from the postgres result schema which columns are geometry columns? (although I don't know if we have access to that through the pandas.read_sql we are using) |
The coordindate system is an interesting sidenote here, that is in |
Geopandas also defines column level crs, gdf.crs is the crs of the "active" geometry column, which is the frame column used as the basis for spatial joins and other geometry operations on the frame level. So we should be fine in this aspect |
Is your feature request related to a problem?
I'm loading the results of a PostGIS query with multiple geometry columns, and I wish geopandas would convert all of them. The problem is that now, only one of the columns is converted to a real geometry type and the other geometries I have to convert myself using
shapely.wkb
.Describe the solution you'd like
geopandas.read_postgis
should have an argument namedgeom_cols: list[str]
. When this argument is set, all these columns are parsed into a geometry type.API breaking implications
This will add an additional optional parameter. Behaviour wouldn't change if the parameter is not included, so it would be backwards compatible if I'm not mistaken.
Describe alternatives you've considered
Current solution is to use
shapely
to do the conversion after loading the data.The text was updated successfully, but these errors were encountered: