[1070] Set a CRS to a GeoDataFrame from another GeoDataFrame’s CRS

alex_bn_lee / 2024-10-23 / 原文

Certainly! To set the Coordinate Reference System (CRS) of one GeoDataFrame to match another GeoDataFrame’s CRS, you can follow these steps:

  1. Assume you have two GeoDataFrames: gdf1 and gdf2.
  2. Make sure both GeoDataFrames (gdf1 and gdf2) are already loaded with valid geometries and CRS.
  3. Set gdf1’s CRS to match gdf2’s CRS using the following code:
# Set gdf1's CRS to match gdf2's CRS
gdf1.crs = gdf2.crs
  1. Now gdf1 and gdf2 will have the same CRS.

Feel free to adjust the variable names (gdf1 and gdf2) according to your specific use case. If you have any further questions or need additional assistance, feel free to ask! 😊