Geopandas:带有不同ESPG代码的GeodataFrame的数据框

发布于 2025-01-27 13:43:31 字数 1107 浏览 2 评论 0原文

我有一个dataframe(DF2):其中x,y在RD新epsg中指定:28992坐标。

            x           y      z     batch_nr  batch_description
0  117298.377  560406.392  0.612         5800   PRF Grasland (l)
1  117297.803  560411.756  1.015                                
2  117296.327  560419.840  1.580                                
3  117295.470  560425.716  2.490                                
4  117296.875  560429.976  4.529

更多CRS信息:

# def CRS, used in geopandas
from pyproj import CRS
crs_rd = CRS.from_user_input(28992)
crs_rd
<Derived Projected CRS: EPSG:28992>
Name: Amersfoort / RD New
Axis Info [cartesian]:
- X[east]: Easting (metre)
- Y[north]: Northing (metre)
Area of Use:
- name: Netherlands - onshore, including Waddenzee, Dutch Wadden Islands and 12-mile offshore coastal zone.
- bounds: (3.2, 50.75, 7.22, 53.7)
Coordinate Operation:
- name: RD New
- method: Oblique Stereographic
Datum: Amersfoort
- Ellipsoid: Bessel 1841
- Prime Meridian: Greenwich

如何将DF2转换为GeodataFame,其中将几何图形设置为CRS:EPSG 28992?

I have a dataframe (df2): wherein x,y are specified in rd new epsg:28992 coordinates.

            x           y      z     batch_nr  batch_description
0  117298.377  560406.392  0.612         5800   PRF Grasland (l)
1  117297.803  560411.756  1.015                                
2  117296.327  560419.840  1.580                                
3  117295.470  560425.716  2.490                                
4  117296.875  560429.976  4.529

more CRS info:

# def CRS, used in geopandas
from pyproj import CRS
crs_rd = CRS.from_user_input(28992)
crs_rd
<Derived Projected CRS: EPSG:28992>
Name: Amersfoort / RD New
Axis Info [cartesian]:
- X[east]: Easting (metre)
- Y[north]: Northing (metre)
Area of Use:
- name: Netherlands - onshore, including Waddenzee, Dutch Wadden Islands and 12-mile offshore coastal zone.
- bounds: (3.2, 50.75, 7.22, 53.7)
Coordinate Operation:
- name: RD New
- method: Oblique Stereographic
Datum: Amersfoort
- Ellipsoid: Bessel 1841
- Prime Meridian: Greenwich

How can I convert df2 to a geodatafame where the geometry is set as CRS: EPSG 28992?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声情话 2025-02-03 13:43:31

这是使用 geopandas crs参数和points_from_xy()

import geopandas as gpd
import pandas as pd
import io

df2 = pd.read_csv(io.StringIO("""            x           y      z     batch_nr  batch_description
0  117298.377  560406.392  0.612         5800   PRF Grasland (l)
1  117297.803  560411.756  1.015                                
2  117296.327  560419.840  1.580                                
3  117295.470  560425.716  2.490                                
4  117296.875  560429.976  4.529"""), sep="\s\s+", engine="python")

gdf = gpd.GeoDataFrame(df2, geometry=gpd.points_from_xy(df2["x"], df2["y"], df2["z"]), crs="epsg:28992")

gdf

输出

xyzbatch_nrbatch_description几何
01172985604060.6125800PRF GRASLAND GRASLAND 的简单情况。 (L)Z点(117298.377 560406.392 0.612)
5604121.015NANZ117297.803 560411.756 1.015) 26
PointZ2.49117295.47
11729812.49560425.7164.529
4117297560430NanNanPoint Z(117296.875 560429.976 4.529)

It's a simple case of using GeoPandas constructor with crs parameter and points_from_xy()

import geopandas as gpd
import pandas as pd
import io

df2 = pd.read_csv(io.StringIO("""            x           y      z     batch_nr  batch_description
0  117298.377  560406.392  0.612         5800   PRF Grasland (l)
1  117297.803  560411.756  1.015                                
2  117296.327  560419.840  1.580                                
3  117295.470  560425.716  2.490                                
4  117296.875  560429.976  4.529"""), sep="\s\s+", engine="python")

gdf = gpd.GeoDataFrame(df2, geometry=gpd.points_from_xy(df2["x"], df2["y"], df2["z"]), crs="epsg:28992")

gdf

output

xyzbatch_nrbatch_descriptiongeometry
01172985604060.6125800PRF Grasland (l)POINT Z (117298.377 560406.392 0.612)
11172985604121.015nanPOINT Z (117297.803 560411.756 1.015)
21172965604201.58nanPOINT Z (117296.327 560419.84 1.58)
31172955604262.49nanPOINT Z (117295.47 560425.716 2.49)
41172975604304.529nanPOINT Z (117296.875 560429.976 4.529)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文