简体   繁体   English

CRS 无效投影

[英]CRS invalid projection

When I try this function, I get an error.当我尝试这个 function 时,我得到一个错误。

gdf = gpd.GeoDataFrame(df, geometry = "Coordinates", crs=4326)

CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name =? AND code =?: no such column: area_of_use_auth_name) CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name =? AND code =?:没有这样的列:area_of_use_auth_name)

It worked fine last time, but when I tried running today, it gave me this error.上次运行良好,但是当我今天尝试运行时,它给了我这个错误。 Help would be appreciated!帮助将不胜感激!

Your installation of pyproj does not see the correct database.您安装的pyproj没有看到正确的数据库。 See https://pyproj4.github.io/pyproj/stable/gotchas.html#internal-proj-error-sqlite-error-on-select .请参阅https://pyproj4.github.io/pyproj/stable/gotchas.html#internal-proj-error-sqlite-error-on-select

This often happens if you start Jupyter in one environment and change the kernel.如果您在一个环境中启动 Jupyter 并更改 kernel,通常会发生这种情况。 The link to PROJ database remains the same which may cause troubles. PROJ 数据库的链接保持不变,这可能会导致问题。

For example, let's assume that I have started Jupyter lab in geo_env environment and then switched kernel to development environment and got the error as you did.例如,假设我在geo_env环境中启动了 Jupyter 实验室,然后将 kernel 切换到development环境并像您一样得到错误。

I can check my proj dictionary:我可以查看我的项目字典:

>>> import pyproj
>>> pyproj.datadir.get_data_dir()
'/opt/miniconda3/envs/geo_env/share/proj'

See that it still links to the env I started Jupyter with.看到它仍然链接到我启动 Jupyter 的环境。 I can fix that by specifying the correct path.我可以通过指定正确的路径来解决这个问题。

>>> pyproj.datadir.set_data_dir('/opt/miniconda3/envs/development/share/proj')

The situation is analogous in any other case when you see this error.当您看到此错误时,情况与任何其他情况类似。 You just have to specify the correct path to proj .您只需指定proj的正确路径。

Hello I had the same problem for a couple of days.你好,我这两天也遇到了同样的问题。 The problem comes from the library Pyproj.问题来自库 Pyproj。 The following points solved my problem:以下几点解决了我的问题:

  1. Create a total new conda enviroment:创建一个全新的 conda 环境:
conda config --prepend channels conda-forge
conda config --set channel_priority strict
conda create -n pyproj_env pyproj
conda activate pyproj_env
  1. Create a new project using this new enviroment使用这个新环境创建一个新项目

  2. Install geopandas using conda使用 conda 安装 geopandas

I solved my problem specifying the package's versions when creating the environment.我解决了在创建环境时指定包版本的问题。

  1. To check which version you are using in your current environment: look into this file ...anaconda3\envs\<ENV>\conda-meta\proj-<VERSION>-h1cfcee-<VERSION>.json要检查您在当前环境中使用的版本:查看此文件...anaconda3\envs\<ENV>\conda-meta\proj-<VERSION>-h1cfcee-<VERSION>.json
  2. Create the new environment, with lower versions: $ conda create --name udl_report_env python==3.9.7 pyproj==3.3.0 proj==8.2.0 These versions are selected because I had some dependencies to cover, yours could be different.使用较低版本创建新环境: $ conda create --name udl_report_env python==3.9.7 pyproj==3.3.0 proj==8.2.0选择这些版本是因为我要覆盖一些依赖项,您的可能会有所不同.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM