<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def CreateWeightTableLDAS(in_ldas_nc, in_nc_lon_var, in_nc_lat_var, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, area_id=None, file_geodatabase=None):
 """ Create Weight Table for NLDAS, GLDAS grids as well as for 2D Joules, or LIS Grids Parameters in_ldas_nc: str Path to the land surface model NetCDF grid. in_nc_lon_var: str The variable name in the NetCDF file for the longitude. in_nc_lat_var: str The variable name in the NetCDF file for the latitude. in_catchment_shapefile: str Path to the Catchment shapefile. river_id: str The name of the field with the river ID (Ex. 'DrainLnID' or 'LINKNO'). in_connectivity_file: str The path to the RAPID connectivity file. out_weight_table: str The path to the output weight table file. area_id: str, optional The name of the field with the area of each catchment stored in meters squared. Default is it calculate the area. file_geodatabase: str, optional Path to the file geodatabase. If you use this option, in_drainage_line is the name of the stream network feature class. (WARNING: Not always stable with GDAL.) Example: .. code:: python from RAPIDpy.gis.weight import CreateWeightTableLDAS CreateWeightTableLDAS( in_ldas_nc='/path/to/runoff_grid.nc', in_nc_lon_var="lon_110", in_nc_lat_var="lat_110", in_catchment_shapefile='/path/to/catchment.shp', river_id='LINKNO', in_connectivity_file='/path/to/rapid_connect.csv', out_weight_table='/path/to/ldas_weight.csv', ) """

    # extract LDAS GRID
    data_ldas_nc = Dataset(in_ldas_nc)
    variables_list = data_ldas_nc.variables.keys()
    if in_nc_lon_var not in variables_list:
        raise Exception("Invalid longitude variable. Choose from: {0}"
                        .format(variables_list))
    if in_nc_lat_var not in variables_list:
        raise Exception("Invalid latitude variable. Choose from: {0}"
                        .format(variables_list))
    ldas_lon = data_ldas_nc.variables[in_nc_lon_var][:]  # assume [-180, 180]
    ldas_lat = data_ldas_nc.variables[in_nc_lat_var][:]  # assume [-90,90]
    data_ldas_nc.close()

    rtree_create_weight_table(ldas_lat, ldas_lon,
                              in_catchment_shapefile, river_id,
                              in_connectivity_file, out_weight_table,
                              file_geodatabase, area_id)