Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Tile Probability Depth

Kelvin edited this page Oct 30, 2020 · 12 revisions

Tile Probability Depth Method

tile.get_probability_depth(
    coordinate, 
    year,
    return_period,
    image=False,
    output_dir='/output'
)

Provides a 256x256 map tile that represents flood inundation with 5 depth thresholds (1-15cm (0-6in), 16-30cm (6-12in), 31-61cm (12-24in), 62- 91cm (24-36in), 92+cm (36+in)).

In addition to a zoom level and x,y coordinates based on the Mercator projection, this API requires a return period (500, 100, 20, 5, or 2 years), year of annual risk (2020, 2035, or 2050).

This method returns an array of Probability Depth Tile product for the given coordinates, and optionally creates an image file.

(More information on the Tile Probability Depth product can be found on the Tile Probability Depth Page on the First Street Foundation API Data Dictionary)

Arguments:

  • coordinate: list of tuple of int [(z, x, y)], county ids to retrieve environmental precipitation for.
  • year: int, county ids to retrieve environmental precipitation for.
  • return_period: int, county ids to retrieve environmental precipitation for.
  • image: bool, whether to create a CSV for the retrieved data.
  • output_dir: string, location to output the created CSV (if csv is True).

Example (Command Line):

# Call tile.get_probability_depth on a list with 2 coordinates
python -m firststreet -p tile.get_probability_depth -i (10,942,1715);(12,942,1715) -year 2050 -return_period 500

Example (Python File):

# Contents of sample.py
# Create a `FirstStreet` object.  
import firststreet
fs = firststreet.FirstStreet("api-key")

# Call tile.get_probability_depth on a list with 1 county FSID
tile_probability_depth = fs.tile.get_probability_depth(coordinate=[(10,942,1715), (12,942,1715)], year=2050, return_period=500)

# Call tile.get_probability_depth on a file of SearchItems
tile_probability_depth = fs.tile.get_probability_depth("sample.txt", csv=True)

Tile Probability Depth Objects

TileProbabilityDepth Object

Key Type Description Example
coordinate tuple A zoom, X, Y coordinate, with the X and Y value based on the Mercator Projection (10,942,1715)
year int Year of annual risk - 2020, 2035, 2050 2050
returnPeriod int Return period - 500, 100, 20, 5, or 2 100
image bytes The tile image in raw bytes b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\x00...

Clone this wiki locally