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

643 views Asked by At

I have a dataset in a shapefile with CRS: EPSG 3035, which is the extent is xmax,xmin,ymax,ymin. I'm struggling to translate it into long and lat format. Do you know how to solve this?

Thanks

1

There are 1 answers

1
Felipe D. On BEST ANSWER

You can do this in Python using a library called GeoPandas. Here is the sample code:

# 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)

If you want to do this in R, here is the appropriate code:

# 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")