2

In my Python Pandas project I have a .csv file with geographic coordinates and want to transform it into lat,lon format.

the last weeks I successfully used the following code to make it work.

import pandas as pd
import numpy as np
import pyproj as pp

def key():
    df = pd.read_csv('POI_Untersuchungsgebiet.csv')

    utm2geo = pp.Proj(init='epsg:25832')
    df[['lon', 'lat']] = df.apply(lambda row: utm2geo(row['x'], row['y'], inverse=True), axis=1).apply(pd.Series)
    key_columns = ['fclass', 'lon', 'lat', 'code', 'Kategorie']
    df = df[key_columns]
    return df

Since today I get the following error message

Invalid projection: +init=epsg:25832 (Internal Proj Error: proj_create: SQLite error on SELECT name, coordinate_system_auth_name, coordinate_system_code, geodetic_crs_auth_name, geodetic_crs_code, conversion_auth_name, conversion_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM projected_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name)

Any ideas what the reason could be?

7

1 Answer 1

2

I believe your pyproj is referencing an incorrect crs data directory (see this error in the pyproj doc's).

This has happened to me when switching kernels in Jupyter notebook/lab or in VSCode and the pyproj data directory remains in the base environment or an environment different from your current environment.

You check your proj data directory:

>>> import pyproj
>>> pyproj.datadir.get_data_dir()
'.../opt/anaconda3/envs/test-env/share/proj'

But imagine if you were working in a different env, such as dev-env. You can see pyproj's data directory is referencing a different env, test-env's proj data directory, causing issues.

You can fix that by specifying the correct path. Below replace Users/User with your machine's file path to your anaconda installation and dev-env with the current env in use (or remove that part of the path if you are working in your base env):

>>> pyproj.datadir.set_data_dir('/opt/anaconda3/dev-env/share/proj')

I've also seen this manifest in a similar error: CRSError: Invalid projection: ESPG:4326: (Internal Proj Error: proj_create: crs not found).

Your Answer

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

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