1. 主页
  2. 文档
  3. GeoPandas 0.12.2中文文档
  4. Advanced Guide
  5. Re-projecting using GDAL with Rasterio and Fiona
  6. Rasterio Example

Rasterio Example

This example requires rasterio 1.2+ and GDAL 3+.

import geopandas
import rasterio.warp
from shapely.geometry import shape

# load example data
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
# Reproject to Mercator (after dropping Antartica)
world = world[(world.name != "Antarctica") & (world.name != "Fr. S. Antarctic Lands")]

destination_crs = "EPSG:3395"
geometry = rasterio.warp.transform_geom(
    src_crs=world.crs,
    dst_crs=destination_crs,
    geom=world.geometry.values,
)
mercator_world = world.set_geometry(
    [shape(geom) for geom in geometry],
    crs=destination_crs,
)
标签 , ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here