Example #1
0
def tools(request):
    os.chdir(MEDIA_ROOT + MEDIA_URL)
    shp_file_name = [each for each in glob.glob("*.shp") ]
    gtif_file_name = [each for each in glob.glob("*.tif")]
    nc_file_name = [each for each in glob.glob("*.nc")]
    text_file_name = [each for each in glob.glob("*.txt") ] + [each for each in glob.glob("*.text") ]
    shps_info = []
    tiffs_info = []
    ncs_metadata = []
    text_info = []
    for name in shp_file_name:
        if open_shp_file(name):
            shps_info.append(run_shp_info(name))
    for name in gtif_file_name:
        if open_tif_file(name):
            tiffs_info.append(run_tif_info(name))
    for name in nc_file_name:
        if open_tif_file(name):
            nc_metadata = get_nc_metadata(name)
            ncs_metadata.append(nc_metadata)
            nc_error = ""
        else:
            nc_error = "Cannot open netCDF."
            break
    for name in text_file_name:
        text_info.append(name)
    context = {'shps_info': shps_info, 'tiffs_info':tiffs_info, 'ncs_metadata':ncs_metadata, 'text_file_name':text_file_name}

    return render(request, 'tools/index.html', context)
Example #2
0
def data_information(request):
    os.chdir(MEDIA_ROOT + MEDIA_URL)
    shp_file_name = [each for each in glob.glob("*.shp") ]
    shps_info = []
    shp_error = "No Shapefile"
    tif_error = "No GeoTIFF"
    nc_error = "No netCDF"
    hdf_error = "No HDF"
    for name in shp_file_name:
        if open_shp_file(name):
            shps_info.append(run_shp_info(name))
            shp_error = ""
        else:
            shp_error = "Cannot open shapfile."
            break

    tif_file_name = [each for each in glob.glob("*.tif") ]
    tifs_info = []
    for name in tif_file_name:
        if open_tif_file(name):
            tifs_info.append(run_tif_info(name))
            tif_error = ""
        else:
            tif_error = "Cannot open tif file."
            break

    nc_file_name = [each for each in glob.glob("*.nc") ]
    ncs_metadata = []
    for name in nc_file_name:
        if get_nc_metadata(name):
            ncs_metadata.append(get_nc_metadata(name))
            nc_error = ""
        else:
            nc_error = "Cannot open netCDF file."
            break

    hdf_file_name = [each for each in glob.glob("*.he5") ]
    hdfs_metadata = []
    for name in hdf_file_name:
        if get_hdf_metadata(name):
            hdfs_metadata.append(get_hdf_metadata(name))
            hdf_error = ""
        else:
            hdf_error = "Cannot open HDF file."
            break

    context = {'shps_info': shps_info,
               'tifs_info': tifs_info,
               'ncs_metadata':ncs_metadata,
               'hdfs_metadata':hdfs_metadata,
               'shp_error':shp_error,
               'tif_error':tif_error,
               'nc_error':nc_error,
               'hdf_error':hdf_error
               }
    
    return render(request, 'data_information/index.html', context)