Python Geopandas Unable to Locate Shapefile

Viewed 644

Environment:

Python 3.8.6
Conda 4.8.5
Mac OS Catalina 10.15.7

Attempting to read in an ESRI shapefile of UK upper tier local authority boundaries to a python environment. Attempted in both command line and PyCharm with identical error.

Setup following document guidance:

conda create -n geo_env
conda activate geo_env
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda install python=3 geopandas

I have confirmed all dependency packages (fiona, pyproj, shapely, dumpy, pandas) are installed and imported to environment.

But when running the following:

local_auth_shape = gpd.read_file('~/Downloads/Counties_and_Unitary_Authorities__December_2017__Boundaries_GB-shp/Counties_and_Unitary_Authorities__December_2017__Boundaries_GB.shp')

I am met with the error:

fiona.errors.DriverError: ~/Downloads/Counties_and_Unitary_Authorities__December_2017__Boundaries_GB-shp/Counties_and_Unitary_Authorities__December_2017__Boundaries_GB.shp: No such file or directory

The path is correct and I have triple checked it. The geo database folder has also downloaded without error.

I have attempted using pip install also with the same error.

1 Answers

I don't think there is an issue with your path. You need to run the pyspark "locally" rather than on the cluster or Standalone.

Initially my spark was set to

sc = SparkContext("spark://panther:7077", "FirstApp")

and it was throwing the error that file doesn't exist but when I changed it to "local", the error went away

sc = SparkContext("local", "FirstApp") <- This should fix the problem for you

Related