'Geopandas' "to_crs" function won't work with Orthographic projection
I am trying to use Geopandas to plot a map of the world in the Orthographic Projection, as shown in TowardsDataScience and tried to use the "to_crs" function with the crs of "EPSG: 9840" which is the EPSG of the Orthographic Projection, but it gives the error message "Invalid projection: EPSG: 9840: (Internal Proj Error: proj_create: crs not found)". Geopandas claims that it supports EPSG codes, but this one doesn't work. Is this just because Geopandas specifically doesn't support this code, or is there something wrong with my code?
I have searched through the websites included in the tutorial and none of the results there worked either.
Solution 1:[1]
- geopandas depends on pyproj for CRS projections. (It is installed when you install geopandas)
- pyproj installs a database of CRS when installed
- below works on my system. Have included geopandas and pyproj versions
- my environment is not at all custom and includes >6500 epsg CRS codes
# EPSG: 9840
import geopandas as gpd
import pyproj
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
world = world.loc[world["continent"].eq("Europe")]
world = world.to_crs("epsg:9840")
codes = [crs.code for crs in pyproj.database.query_crs_info(auth_name="EPSG")]
print(f"{pyproj.__version__}, {gpd.__version__} number of epsg CRS defined:{len(codes)}")
[crs for crs in pyproj.database.query_crs_info(auth_name="EPSG") if crs.code=="9840"]
output
3.3.0, 0.10.2 number of epsg CRS defined:6525
[CRSInfo(auth_name='EPSG', code='9840', name='UCS-2000 / LCS-35 Kirovohrad', type=<PJType.PROJECTED_CRS: 'PROJECTED_CRS'>, deprecated=False, area_of_use=AreaOfUse(west=29.74, south=47.74, east=33.9, north=49.25, name='Ukraine - Kirovohrad region (oblast).'), projection_method_name='Transverse Mercator')]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
