2

I would read a shapefile as GeoPandas DataFrame using:

import geopandas as gdp

df = gdp.read_file('file.shp')

When I read the file, the NULL values have been loaded as zero. I need to see and distinguish null values and the real zeros.

6
  • What is GeoPandas' version? Could you share your shapefile or part of it containing null values? May 24, 2021 at 11:07
  • The main issue is in the shapefile format support.esri.com/en/technical-article/000005811. Change to something better.
    – user30184
    May 24, 2021 at 11:44
  • Shapefile does not support numeric nulls. It doesn't support nulls at all, but empty strings are usually interpreted as nulls. Since it is not possible to store null vales, your problem is in the attempt to write nulls in the first place.
    – Vince
    May 24, 2021 at 12:08
  • GeoPandas 0.7.0 and GeoPandas 0.9.0. The same for gpkg files.
    – JTitti
    May 24, 2021 at 13:31
  • Do you see NULLs if you open the GeoPackage with QGIS or with some generic SQLite client? Could you share some sample data as GeoPackage?
    – user30184
    May 24, 2021 at 13:52

1 Answer 1

0

I worked around the problem. First I export the GPKG as CSV adding a column with explicit geometry, then I load with Pandas the CSV table as a DataFrame. Now the NULL cells are still NULL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.