Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review of the read_shapefile and kl_divergence notebooks #1

Closed
noahbouchier opened this issue Jul 14, 2021 · 10 comments
Closed

Review of the read_shapefile and kl_divergence notebooks #1

noahbouchier opened this issue Jul 14, 2021 · 10 comments
Assignees

Comments

@noahbouchier
Copy link
Owner

As the first evidence of code that will help to form the output of my Google Summer of Code project - I'd be appreciative of any feedback on the read_shapefile and kl_divergence notebooks.

Some of the explanatory text is quite beefy, so feel free to skim that!

@noahbouchier noahbouchier changed the title Review of the read_shapefile and kl_divergence` notebooks Review of the read_shapefile and kl_divergence notebooks Jul 14, 2021
@noahbouchier noahbouchier self-assigned this Jul 14, 2021
@ljwolf ljwolf self-assigned this Jul 14, 2021
@noahbouchier
Copy link
Owner Author

Please note - the kl_divergence notebook has just been updated to include use and explanation of the scipy.spatial.distance_matrix function

@noahbouchier
Copy link
Owner Author

Please note - today's (gitmoji-inspired) update raises an issue within read_shapefile.ipynb.

The issue is within the final code block - In[16] - where the following line is returning an error:
leicester_oa_eth_shp.to_file("../leicester/data/leicester_ethnicity.gpkg", driver = "GPKG")

The crux of the error appears to be the following:
DriverError: sqlite3_open(../leicester/data/leicester_ethnicity.gpkg) failed: unable to open database file

Any help would be greatly appreciated - my searching seems to only identify this problem within other pieces of software, which make the solution hard to translate

@ljwolf
Copy link
Collaborator

ljwolf commented Jul 19, 2021

Odd! Is there a file existing there when you open it in Finder?

If there are issues, it's OK to use a shape file for now.

@jeffcsauer
Copy link
Collaborator

jeffcsauer commented Jul 19, 2021 via email

@noahbouchier
Copy link
Owner Author

Hey!

Unfortunately adding the layer argument still returns the same issue.

There isn't a file in that location locally - I supposed that the to.file would create the file, as I've experienced previously with the shape files. But that did cross my mind when reading the error.

Is it worth creating a GeoPackage to then update? If so, how's best to do that?

@jeffcsauer
Copy link
Collaborator

jeffcsauer commented Jul 19, 2021 via email

@noahbouchier
Copy link
Owner Author

Do the above three lines work?

Yes - they create a 324KB file on my desktop that I've been able to successfully read back in under a different object name

@jeffcsauer
Copy link
Collaborator

jeffcsauer commented Jul 19, 2021

@noahbouchier worked through the notebook on my local machine. You need to specify the full path when using .to_file(...).

Remove the .. and use the full path.

I got the same error as you when trying to save with '../'. Once I put in the full path I was able to save the GPKG.

Example:

# Save the new file as a shapefile, titled 'leicester_ethnicity'
leicester_oa_eth_shp.to_file("C:/Users/USER/Desktop/leicester_ethnicity.gpkg", driver = "GPKG")

@noahbouchier
Copy link
Owner Author

@jeffcsauer thanks so much for your help! Your solution helped me to identify the problem - stemming from my oversight.

The file path to_file was attempting to write to ("../leicester/data/leicester_ethnicity.gpkg") was incorrect, and related to a previous iteration of the workbook.

Within the GitHub repository, the correct file path is:

"../Example Data - Leicester, UK/leicester_ethnicity.gpkg"

When I use this, the GeoPackage file is created exactly as it should be, like a dream.

Thanks for your help, and apologies for the error that created the problem

@ljwolf
Copy link
Collaborator

ljwolf commented Jul 20, 2021

no prob! the error raised when the path is wrong are not the most informative... glad you figured it out!

@ljwolf ljwolf closed this as completed Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants