Repository navigation
Add Topology.to_polars(), with the geometries as WKB as polars-st stores them - #276
Merged
Merged
Conversation
…res them to_polars() gives a Polars DataFrame with the id and the properties as columns and the geometry as WKB in the column geometry; with a CRS that has an EPSG code (of the input, or given) it is EWKB with this code as SRID, so polars-st knows the CRS. It takes the options of to_gdf(); a feature without geometry is null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
A column id of a Polars DataFrame gives the ids of the features, as the index of a GeoDataFrame does, instead of being a property, so that the ids that go in come out of to_json, to_gdf and to_polars. Duplicate ids raise as in a FeatureCollection; with ignore_index the features are numbered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Follows #275, the other way:
Topology.to_polars()gives a Polars DataFrame, the id and the properties as columns and the geometry as WKB in the columngeometry, as polars-st stores it.crs=, the WKB is EWKB with this code as SRID, so polars-st knows the CRS. Without one it is plain WKB.to_gdf():crs,validate,winding_orderandobject_name; the geometries are the same as those ofto_gdf().idholds the ids of the features, from the index of a GeoDataFrame, the ids of GeoJSON features, or a columnidof a Polars DataFrame. That last one is new on the input side: a columnidof a Polars DataFrame now gives the ids of the features, as the index of a GeoDataFrame, instead of being a property (soto_jsonandto_gdfkeep them too). Duplicate ids raise as in a FeatureCollection; withignore_index=Truethe features are numbered.nullas geometry; a property missing on some features isnullthere.to_polars()is called; the tests build and read the WKB with shapely, so they run without polars-st.🤖 Generated with Claude Code