Example #1
0
def get_landcover_pixel_values(landcover_latlngs):
    """Fetches the cost per unit area at each input lat lng point
    """
    geotiff_file_path = config.CWD + LAND_COVER_GEOTIFF_FILE_PATH
    landcover_lnglats = util.swap_pairs(landcover_latlngs)
    landcover_pixel_values = geotiff.get_geotiff_pixel_vals_with_projection(geotiff_file_path, landcover_lnglats)
    return landcover_pixel_values
Example #2
0
 def build_great_circle(self, start_latlng, end_latlng, distance):
     num_points = int(distance / self.ARC_LENGTH_SPACING)
     geod = Geod(ellps='WGS84')
     start_lat, start_lon = start_latlng
     end_lat, end_lon = end_latlng
     lonlats = geod.npts(start_lon, start_lat, end_lon, end_lat, num_points)
     latlngs = util.swap_pairs(lonlats)
     return latlngs
Example #3
0
def get_partition_elevations(latlngs_partition):
    """Gets the elevation at a given lat-lng coord
    """    
    coordstring = get_coordstring(latlngs_partition[0])
    coord_zipfile = coordstring + ".zip"
    coord_folder_name = coordstring + "/"

    url = USGS_FTP_PATH + coord_zipfile
    download_directory = config.CWD + USGS_FOLDER
    zip_file_path = download_directory + coord_zipfile
    unzip_directory = download_directory + coord_folder_name
    img_file_name = get_img_file_name(coordstring)
    img_file_path = unzip_directory + img_file_name
    geotiff_file_path = unzip_directory + coordstring + ".tif"

    if file_exists(geotiff_file_path):
        pass
    else:
        if file_exists(img_file_path):
            pass
        else:
            if file_exists(zip_file_path):
                pass
            else:
                util.smart_print("Not yet downloaded.")
                util.smart_print("Now downloading " + coord_zipfile + "...")
                util.smart_print("From " + str(url))
                urllib.urlretrieve(url, zip_file_path)
            unzip_zipfile(zip_file_path, unzip_directory, img_file_name)
            remove_file(zip_file_path)
        img_to_geotiff(img_file_name, unzip_directory, coordstring)
        remove_file(img_file_path)

    lnglats = util.swap_pairs(latlngs_partition)
    partition_elevations = get_geotiff_elevations(geotiff_file_path, lnglats)
    return partition_elevations