I have a shapefile that has 2 attributes named "X" and "Y". I want to change this to "Lon" and "Lat".
My (limited) experience tells me that I should read in the original shapefile, preserve the original driver, crs, make a new schema with "Lon" and "Lat" defined, and then write a new/new named shapefile.
Is there a quicker/easier way with fewer steps?
import fiona
with fiona.open(filein, 'r') as source:
source_driver=source.driver
source_crs=source.crs
source_schema=source.schema
print(source_schema)
new_schema= {'geometry': 'Point',
'properties': { 'Lon': 'float:16.6',
'Lat': 'float:16.6',
'SP': 'float:16.6',
'X_meter': 'float:19.11',
'Y_meter': 'float:19.11',
'Depth': 'float:19.8',
'Line_Name': 'str:50',
'SurveyID': 'str:50'}}
with fiona.open(fileout, 'w',
driver=source_driver,
crs=source_crs,
schema=new_schema) as c:
print(len(c))
c.closed
No comments:
Post a Comment