从 shapefile 将 EPSG 3035 转换为 EPSG 4326(lon lat)
Posted
技术标签:
【中文标题】从 shapefile 将 EPSG 3035 转换为 EPSG 4326(lon lat)【英文标题】:Translate EPSG 3035 to EPSG 4326(lon lat) from shapefile 【发布时间】:2021-08-09 22:43:57 【问题描述】:我在带有 CRS 的 shapefile 中有一个数据集:EPSG 3035,其范围为 xmax、xmin、ymax、ymin。我正在努力将其翻译成 long 和 lat 格式。你知道如何解决这个问题吗?
谢谢
【问题讨论】:
【参考方案1】:您可以在 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")
【讨论】:
您好!我已经在 R 中添加了相关代码。如果这回答了您的问题,请单击左侧的复选标记并“接受”答案 =)以上是关于从 shapefile 将 EPSG 3035 转换为 EPSG 4326(lon lat)的主要内容,如果未能解决你的问题,请参考以下文章
使用 Proj4js 将坐标从 EPSG:3857 转换为 EPSG:32633