Giter VIP home page Giter VIP logo

Comments (8)

jwass avatar jwass commented on May 22, 2024

@fscottfoti I think rather than skipping the geometries, you'd include them with None for the geometry column.

Note that GeoPandas does not currently handle the null geometry case at the moment i.e., df.area would raise an exception, where it should probably return nan for rows with null geometries. I'll file a separate issue.

Going forward, you would use df[df['geometry'].notnull()].to_file(...) to filter out null geometries and write the result. You shouldn't have to do this if certain file types can handle features with no geometries.

from geopandas.

jwass avatar jwass commented on May 22, 2024

See #139. Slight change from above, set missing geometries as np.nan.

from geopandas.

fscottfoti avatar fscottfoti commented on May 22, 2024

Makes perfect sense. I think you should be able to write empty geometries too, just because to_file should be the inverse of from_file.

from geopandas.

jwass avatar jwass commented on May 22, 2024

I agree, but only if the output format can handle missing geometries. If Fiona handles it, we should make sure we're doing that right. I don't know enough about all the formats to know how common this is. Just read the GeoJSON spec and found out that it's acceptable for Features to have null geometry, never knew that before.

But if the output requires a geometry to be present, and you pass in null ones, then I think it should crash. It's up to the user to pass in the data properly.

from geopandas.

fscottfoti avatar fscottfoti commented on May 22, 2024

Makes sense. Yes, I hadn't thought much before about missing geometries either, then I got some degenerate data from a client today. If I get a chance I will see if I can fix things up to read/write missing data. Thx.

from geopandas.

kjordahl avatar kjordahl commented on May 22, 2024

There is a method to fill null values in a GeoSeries, fillna(), that will by default write empty polygons to null values. That doesn't do you any good if the read is failing, but it does give you a consistent geometry for shapely operations.

from geopandas.

fscottfoti avatar fscottfoti commented on May 22, 2024

Awesome - thank you the fix!

from geopandas.

martinfleis avatar martinfleis commented on May 22, 2024

Fixed by #138

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.