0

I'm completely new to geopandas.

I'm trying to follow this tutorial to geopandas and am trying to import the "oceans.shp" file, which I downloaded from here (together with the .dbf, .prj, qpj, and .shx files),

When running the code - oceans = gpd.read_file('[...]\oceans.shp') - I get the error FionaValueError: No dataset found at path '[...]\oceans.shp' using drivers: *

What am I doing wrong - can someone point me into the right direction?

  • Sorry if that wasn't clear. Yes, I'm using the entire path - that's just for better readability. :) – Ivo Aug 28 '18 at 13:43
  • What other files do you have in the same directory? (there should at least be two other files with the same name but different extensions .shx and .dbf in the same directory). – joris Aug 28 '18 at 14:46
  • If I would follow that tutorial I would first try the syntax literally without changing anything else but the data_pth variable to point where ever your data are oceans = gpd.read_file(os.path.join(data_pth, "oceans.shp")). – user30184 Aug 28 '18 at 14:53
  • @user30184 Yep, that's what I'm doing/ trying to do - then I'm encountering that error. – Ivo Aug 29 '18 at 6:39
  • @joris In the directory, there are ocean.dbf, .prj, .qpj, .shp, .shx. – Ivo Aug 29 '18 at 6:42
0

Are you sure you wrote the path properly?

If the file is in the same directory than the script, do this:

import os

oceans = gpd.read_file(os.path.join(os.getcwd(), 'oceans.shp')

Using os assures you that you won't have conflicts of paths when switching from windows to linux.

  • Many thanks for the suggestion - the error persists, however. :( – Ivo Aug 28 '18 at 13:31
  • Do you use linux? Can you post the results of ls ./? (directory where the file and the script is) – ImanolUr Aug 28 '18 at 13:38
  • No, it's Windows 10... – Ivo Aug 28 '18 at 13:38
  • For that path to work the wd has to be set and the shapefile needs to be in it – BERA Aug 28 '18 at 13:38
  • 1
    No, forward slashes are valid in Windows. – user2856 Aug 30 '18 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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