将 EPSG 3035 从 shapefile 转换为 EPSG 4326(lon lat)

Translate EPSG 3035 to EPSG 4326(lon lat) from shapefile

我在带有 CRS 的 shapefile 中有一个数据集:EPSG 3035,其范围是 xmax、xmin、ymax、ymin。我正在努力将其翻译成长和纬度格式。你知道怎么解决吗?

谢谢

您可以在 Python 中使用名为 GeoPandas 的库执行此操作。这是示例代码:

# Imports the library
import geopandas as gpd

# String that points to the location of the
# shapefile on disk
input_file = 'path\to\file.shp'

# String that contains the filename of the 
# new/transformed shapefile
output_file = 'path\to\new_file.shp'

# Creates a GeoDataFrame which you can manipulate
my_data = gpd.read_file(input_file)

# Transforms the data to the new reference system
new_data = my_data.to_crs('epsg:4326')

# Exports the newly-created file
new_data.to_file(output_file)

如果您想在 R 中执行此操作,请使用以下适当的代码:

# Install spatial data packages
install.packages("rgdal")

# Load spatial data packages
library(rgdal)

# String that points to the location of the
# input shapefile on disk
input_file = 'path/to/file/my_shapefile.shp'

# Strings that point to the filename of the 
# new/transformed shapefile that will be generated
output_folder = 'path/to/file'
output_file   = 'new_shapefile.shp'

# Creates a SpatialLinesDataFrame which you can manipulate
my_data = readOGR(input_file)

# Transforms the data to the new reference system
new_data = spTransform(my_data,CRS("+init=epsg:4326"))

# Exports the newly-created file
writeOGR(new_data, dsn=output_folder,layer=output_file, driver="ESRI Shapefile")