Skip to content
Snippets Groups Projects
geojson_format.py 414 B
Newer Older
  • Learn to ignore specific revisions
  • Jesper Zedlitz's avatar
    Jesper Zedlitz committed
    import geopandas
    from pyogrio.errors import DataSourceError
    from shapely.errors import GEOSException
    
    
    def is_valid(resource, file):
        """Check if the content is a readable GeoJSON file."""
    
        with open(file.name, "rb") as f:
            try:
                geopandas.read_file(f)
                return True
            except DataSourceError:
                return False
            except GEOSException:
                return False