Giter VIP home page Giter VIP logo

Comments (3)

paddymul avatar paddymul commented on June 11, 2024 1

FWIW I was able to get a regular pandas dataframe with the following code:

pd_df = pd.DataFrame(dict(zip(df.columns, df.to_numpy().T)))

Then I serialize via existing pandas methods.

I no longer need geopandas to change the behavior of to_json, but I figure this code could be useful for others who stumble across this problem.

from geopandas.

m-richards avatar m-richards commented on June 11, 2024

Thanks @paddymul for opening this issue. I wouldn't say this is a bug per se, but a mismatch of expectations. In the geospatial world the standard json representation of features is GeoJson - which specifies a specific layout for storing features separate to geometry alongside storing spatial metadata like a CRS (coordinate reference system).

(For instance compare the output of gdf.to_json(indent=2) and pd.DataFrame(gdf.to_wkt()).to_json(indent=2) in your example).

In principle I think we would be open to supporting other orientations, so long as that does not lead to confusion about what is a generic interoperable geojson format and what is a pandas specific format. It'd be good for other maintainers to weight in, but my initial proposal to support this would be to introduce an orient="GeoJSON" which is the default value and support the other values via pandas. Geometry would be exported as WKT and we'd probably need to emit a warning about the loss of CRS metadata (and then perhaps a second stage would be to agree on a way to embed CRSs if there was an appetite for that.

from geopandas.

m-richards avatar m-richards commented on June 11, 2024

FWIW I was able to get a regular pandas dataframe with the following code:

pd_df = pd.DataFrame(dict(zip(df.columns, df.to_numpy().T)))

I haven't compared the performance, but I think a slightly clearer way to express this would be pd.DataFrame(gdf).astype({"geometry":"object"}) (or a generalisation of it if there are multiple geometry columns), but it is more verbose.

from geopandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.