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 Jan 21, 2021 · 9 revisions

Tile Historic Event Method

tile.get_historic_event(
    search_items, 
    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 function requires an event_id. Max zoom is level 18. The map provided here can be used to find the coordinates at a specified zoom level.

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:

  • search_items: list of tuple of int [(z, x, y)], coordinates to retrieve tile historic event. The coordinates used in this product can be converted using Google Map's Coordinate Tile tool.
  • event_id: int, the event ID to retrieve the tile for.
  • image: bool, whether to create an image for the retrieved data.
  • output_dir: string, location to output the created image (if image is True).

Example (Command Line):

Call tile.get_historic_event on a list with 2 coordinates

python -m firststreet -p tile.get_historic_event -s (12,932,1715);(12,942,1715) -eid 10
python -m firststreet -p tile.get_historic_event -s (12,932,1715);(12,942,1715) -eid 14

Call tile.get_historic_event on a list with 2 coordinates

python -m firststreet -p tile.get_historic_event -s sample_coordinate.txt -eid 10
python -m firststreet -p tile.get_historic_event -s sample_coordinate.txt -eid 14

Example (Python File):

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

# Call tile.get_historic_event on a list with 1 county FSID
tile_probability_depth = fs.tile.get_historic_event(search_items=[(12,932,1715), (12,942,1715)], event_id=10)

# Call tile.get_historic_event on a file of SearchItems
tile_probability_depth = fs.tile.get_historic_event(search_items="sample_coordinates.txt", csv=True)

Tile Historic Event Objects

TileHistoricEvent 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)
valid_id bool Whether the input FSID returned valid data from the server. True
event_id int The provided event ID 10
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