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

Tile Historic Event

Kelvin edited this page Oct 30, 2020 · 9 revisions

Tile Historic Event Method

tile.get_historic_event(
    coordinate, 
    event_id,
    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)) from the historic event.

In addition to a zoom level and x,y coordinates based on the Mercator projection, this API requires an eventId. Max zoom is level 18.

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

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

Arguments:

  • coordinate: list of tuple of int [(z, x, y)], coordinates to retrieve environmental precipitation for.
  • event_id: int, event ids to retrieve environmental precipitation for.
  • image: bool, whether to create a image 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