CartoDB / cartoframes

CARTO Python package for data scientists
BSD 3-Clause "New" or "Revised" License
251 stars 63 forks source link

Remove None from geometry_types to check validity #1691

Closed antoniocarlon closed 4 years ago

antoniocarlon commented 4 years ago

The error was:

ValueError: No valid geometry column types ({None, 'Point'}), it has to be one of the next type sets: [{'Point'}, {'MultiPoint'}, {'LineString'}, {'MultiLineString'}, {'LineString', 'MultiLineString'}, {'Polygon'}, {'MultiPolygon'}, {'MultiPolygon', 'Polygon'}].

when doing

from cartoframes.viz import Map, Layer
Map([Layer(geo_gdf)])

The workaround is pretty easy:

from cartoframes.viz import Map, Layer
Map([Layer(geo_gdf[geo_gdf.the_geom != None])])

but we can do it more straightforward by just removing the None from the set (None can be returned by the geocoder if no results are found for a given address for example).