Fix creation of seg_lat and seg_lon fields. Add add_latlon(). In extractor,...

Fix creation of seg_lat and seg_lon fields. Add add_latlon(). In extractor, don't overwrite trans_df before beachwidth raster.
parent 345424f9
......@@ -113,7 +113,7 @@ extra_fields = ["StartX", "StartY", "ORIG_FID", "Autogen", "ProcTime",
'lr2', 'lse', 'lci90']
extra_fields += [x.upper() for x in extra_fields]
sorted_pt_flds = ['SplitSort', 'seg_x', 'seg_y',
sorted_pt_flds = ['SplitSort', 'seg_x', 'seg_y', 'seg_lon', 'seg_lat',
'Dist_Seg', 'Dist_MHWbay', 'DistSegDH', 'DistSegDL', 'DistSegArm',
'ptZ', 'ptSlp', 'ptZmhw',
'GeoSet', 'SubType', 'VegDens', 'VegType',
......@@ -134,9 +134,9 @@ field_defs = {
'unit':'meters'},
'seg_y':{'def':'Point northing referenced to UTM Zone xxx-utm zone no-xxxN, NAD 83. NoData value of -99999.',
'unit':'meters'},
'seg_lon':{'def':'Longitude in WGS 84',
'seg_lon':{'def':'Longitude in NAD 83',
'unit':'decimal degrees'},
'seg_lat':{'def':'Latitude in WGS 84',
'seg_lat':{'def':'Latitude in NAD 83',
'unit':'decimal degrees'},
'Dist_Seg':{'def':'Along-transect distance to the mean high water (MHW) shoreline position. NoData value of -99999.',
'unit':'meters'},
......
......@@ -15,6 +15,7 @@ import collections
import pandas as pd
import numpy as np
from operator import add
import pyproj
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
......@@ -157,6 +158,26 @@ def sort_pts(df, tID_fld='sort_ID', pID_fld='SplitSort'):
pass
return(df)
def add_latlon(df, proj_code):
# Use pyproj to convert projected coordinates to geographic coordinates (lat, lon in NAD83)
utm = pyproj.Proj(init='epsg:{}'.format(proj_code))
nad = pyproj.Proj(init='epsg:4269') # NAD83
in_y = df['seg_y'].tolist()
in_x = df['seg_x'].tolist()
lon, lat = pyproj.transform(utm, nad, in_x,in_y)
lon_col = 'seg_lon'
lat_col = 'seg_lat'
df[lon_col] = lon
df[lat_col] = lat
df.replace(float('inf'), np.nan, inplace=True)
return(df)
def calc_trans_distances(df, MHW=''):
"""Calculate the transect distances: DistDH, DistDL, DistArm, and conditionally adjust to MHW."""
df2 = pd.DataFrame({'DistDH': np.hypot(df.SL_x - df.DH_x, df.SL_y - df.DH_y),
......
......@@ -1057,9 +1057,9 @@
},
"outputs": [],
"source": [
"trans_df = fwa.FCtoDF(trans_4pub)\n",
"trans_4pubdf = fwa.FCtoDF(trans_4pub)\n",
"xmlfile = os.path.join(scratch_dir, trans_df + '_eainfo.xml')\n",
"trans_df_extra_flds = fun.report_fc_values(trans_df, field_defs, xmlfile)"
"trans_df_extra_flds = fun.report_fc_values(trans_4pubdf, field_defs, xmlfile)"
]
},
{
......@@ -1203,7 +1203,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
"version": "3.5.4"
}
},
"nbformat": 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment