Làm việc với Dữ liệu Không gian địa lý trong Python
Joris Van den Bossche
Open source software developer and teacher, GeoPandas maintainer
Thuộc tính .crs của GeoDataFrame/GeoSeries:
import geopandas
gdf = geopandas.read_file("countries.shp")
print(gdf.crs)
{'init': 'epsg:4326'}
gdf_noCRS = geopandas.read_file("countries_noCRS.shp")
print(gdf_noCRS.crs)
{}
Thêm thông tin CRS vào crs:
# Option 1
gdf.crs = {'init': 'epsg:4326'}
# Option 2
gdf.crs = {'proj': 'longlat', 'datum': 'WGS84', 'no_defs': True}
import geopandas
gdf = geopandas.read_file("countries_web_mercator.shp")
print(gdf.crs)
{'init': 'epsg:3857', 'no_defs': True}
Phương thức to_crs():
# Option 1 gdf2 = gdf.to_crs({'proj': 'longlat', 'datum': 'WGS84', 'no_defs': True})# Option 2 gdf2 = gdf.to_crs(epsg=4326)
1) Nguồn dữ liệu có CRS khác nhau
df1 = geopandas.read_file(...)
df2 = geopandas.read_file(...)
df2 = df2.to_crs(df1.crs)
1) Nguồn dữ liệu có CRS khác nhau
2) Bản đồ (biến dạng hình dạng và khoảng cách)

1) Nguồn dữ liệu có CRS khác nhau
2) Bản đồ (biến dạng hình dạng và khoảng cách)
3) Tính toán theo khoảng cách/diện tích
Mẹo:
Trang hữu ích:
to_crs()Trang hữu ích:
Làm việc với Dữ liệu Không gian địa lý trong Python