FZJ-IEK3-VSA / geokit

Geospatial toolkit for Python
MIT License
21 stars 16 forks source link

"GDAL_DATA" path error when installing/using geokit #3

Closed EdgarUbaldo closed 4 years ago

EdgarUbaldo commented 4 years ago

There have been times where there is an error associated with the "GDAL_DATA" when trying to install/use/update Ggokit such as this one:

error_image

The error is caused by a conflicting path in a system variable called "GDAL_DATA". I followed these steps to solve it:

  1. Install the latest version of Geokit following the installation instructions provided.

  2. Access where the System Variables are declared following these steps and check whether there is a "GDAL_DATA" "user" or "system" variable. The "user" variable will take precedence and the "system" variable won't be used at all, so, setting up the "GDAL_DATA" in the "user" variables should be enough.

2.1 The "GDAL_DATA" path should look like this: C:\Users\<user>\Anaconda3\envs\<name of the envoriment>\Library\share\epsg_csv or C:\Users\<user>\Anaconda3\envs\<name of the envoriment>\Library\share but it might change. Important is that it should point to a folder with several files, likecoordinate_axis.csv,gcs.csv, pcs.csv, and other files.

2.2 Open a Windows Explorer window and use the "Quick search tool" to look for a pcs.csv file (or gcs.csv or coordinate_axis.csv) somewhere within C:\Users\<user>\Anaconda3\ to help windows quickly find it.

path_image

2.3 Use Shift + right-click in the file and select "copy as path" to copy the path into the clipboard

2.4 Copy the path into a text editor, delete the " at the beginning and the \gcs.csv" at the end.

  1. Add/edit the System Variable and User Variable with name "GDAL_DATA" and value of the path

3.1 Make sure that there are not ;,"or other characters in the path value. Delete it and set it up if needed. it should look like this like this

Sytem_variables_window

  1. Restart the computer.

  2. Activate your working environment, open Jupyter Notebook, and run this script:

import pandas as pd

import os

gdal_data = os.environ['GDAL_DATA']

pd.read_csv(os.path.join(gdal_data,"gcs.csv")).head()

image

If this prints out a data frame like in the image, it means that the path is correct and that the file is readable. If it causes an error, then the path might be wrong or containing an extra character such as " or ;. Try modifying it again (step 3-5) until you can read the csv file. Restart your computer after any change in the System Variables/User Variable to make them effective.

  1. Import geokit with no errors

no_error_image

Finished!

NOTE: the implications of having a path value with C:\Users\<user>\Anaconda3\envs\<name of the envoriment>\Library\share**\epsg_csv** instead of C:\Users\<user>\Anaconda3\envs\<name of the envoriment>\Library**\share** are at this moment unknown. It has not caused problems for me so far but there is a chance that it might with other packages. This issue will be updated in such a case