Query the Data Delivery Network
Query the DDNThe easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432
and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.
For example, you can query the flood_hazard_areas_dfirm_statewide
table in this repository, by referencing it like:
"highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest"."flood_hazard_areas_dfirm_statewide"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"ar_revert", -- Flood Control Restoration Zones – Zone AR Classification. If this area is Zone AR in FLD_Zone field, this field would hold the zone that the area would revert to if the AR zone were removed. This field is only populated if the corresponding area is Zone AR.
"ar_subtrv", -- Flood Control Restoration Zones – Zone AR Classification. If this area is Zone AR in FLD_Zone field, this field would hold the zone that the area would revert to if the AR zone were removed. This field is only populated if the corresponding area is Zone AR.
"bfe_revert", -- Flood Control Restoration Zones – BFE Revert. If zone is Zone AR in FLD_Zone field, this field would hold the static base flood elevation for the reverted zone. This field is populated when Zone equals AR and the reverted zone has a static BFE.
"dep_revert", -- Flood Control Restoration Zones – Depth Revert. If zone is Zone AR in FLD_Zone field, this field would hold the flood depth for the reverted zone. This field is populated when Zone equals AR and the reverted zone has a depth assigned.
"depth", -- Depth. This is the depth for Zone AO areas. This field is only populated if a depth is shown on the FIRM.
"dfirm_id", -- Study Identifier. For a single jurisdiction flood risk project, the value is composed of the two-digit State FIPS code and the four-digit FEMA CID code. For a countywide flood risk project, the value is composed of the two-digit State FIPS code, the three-digit county FIPS code, and the letter “C.”
"dual_zone", -- Flood Control Restoration Zones – Dual Zone Classification. If the flood hazard areas shown on the effective FIRM shall be designated as “dual” flood insurance rate zones, (i.e. Zone AR/AE, Zone AR/AH, Zone AR/AO, Zone AR/A), this field will be coded as true. If should be false for any AR Zones that revert to Shaded X.
"fld_ar_id", -- Primary key for table lookup. Assigned by table creator.
"fld_zone", -- Flood Zone. This is a flood zone designation. These zones are used by FEMA to designate the SFHAs and for insurance rating purposes. A - Zone A is the flood insurance rate zone that corresponds to the 1-percent annual chance floodplains that are determined in the Flood Insurance Study by approximate methods of analysis. Because detailed hydraulic analyses are not performed for such areas, no Base Flood Elevations or depths are shown within this zone. Mandatory flood insurance purchase requirements apply. AE and A1-A30 - Zones AE and A1-A30 are the flood insurance rate zones that correspond to the 1percent annual chance floodplains that are determined in the Flood Insurance Study by detailed methods of analysis. In most instances, Base Flood Elevations derived from the detailed hydraulic analyses are shown at selected intervals within this zone. Mandatory flood insurance purchase requirements apply. AH - Zone AH is the flood insurance rate zone that corresponds to the areas of 1-percent annual chance shallow flooding with a constant water-surface elevation (usually areas of ponding) where average depths are between 1 and 3 feet. The Base Flood Elevations derived from the detailed hydraulic analyses are shown at selected intervals within this zone. Mandatory flood insurance purchase requirements apply. AO - Zone AO is the flood insurance rate zone that corresponds to the areas of 1-percent shallow flooding (usually sheet flow on sloping terrain) where average depths are between 1 and 3 feet. Average flood depths derived from the detailed hydraulic analyses are shown within this zone. In addition, alluvial fan flood hazards are shown as Zone AO on the Flood Insurance Rate Map. Mandatory flood insurance purchase requirements apply. AR - Zone AR is the flood insurance rate zone used to depict areas protected from flood hazards by flood control structures, such as a levee, that are being restored. FEMA will consider using the Zone AR designation for a community if the flood protection system has been deemed restorable by a Federal agency in consultation with a local project sponsor; a minimum level of flood protection is still provided to the community by the system; and restoration of the flood protection system is scheduled to begin within a designated time period and in accordance with a progress plan negotiated between the community and FEMA. Mandatory purchase requirements for flood insurance will apply in Zone AR, but the rate will not exceed the rate for an unnumbered Zone A if the structure is built in compliance with Zone AR floodplain management regulations. A99 - Zone A99 is the flood insurance rate zone that corresponds to areas within the 1-percent annual chance floodplain that will be protected by a Federal flood protection system where construction has reached specified statutory milestones. No Base Flood Elevations or depths are shown within this zone. Mandatory flood insurance purchase requirements apply. D - Zone D designation is used for areas where there are possible but undetermined flood hazards. In areas designated as Zone D, no analysis of flood hazards has been conducted. Mandatory flood insurance purchase requirements do not apply, but coverage is available. The flood insurance rates for properties in Zone D are commensurate with the uncertainty of the flood risk. V - Zone V is the flood insurance rate zone that corresponds to areas within the 1-percent annual chance coastal floodplains that have additional hazards associated with storm waves. Because approximate hydraulic analyses are performed for such areas, no Base Flood Elevations are shown within this zone. Mandatory flood insurance purchase requirements apply. VE - Zone VE is the flood insurance rate zone that corresponds to areas within the 1-percent annual chance coastal floodplain that have additional hazards associated with storm waves. Base Flood Elevations derived from the detailed hydraulic analyses are shown at selected intervals within this zone. Mandatory flood insurance purchase requirements apply. X - Zone X is the flood insurance rate zones that correspond to areas outside the 1-percent annual chance floodplain and areas protected from the 1-percent annual chance flood by levees. No Base Flood Elevations or depths are shown within this zone. Insurance purchase is not required in these zones. OW – Zone X is an area of open water (e.g., Ocean)
"len_unit", -- Length Units. This unit indicates the measurement system used for the BFEs and/or depths. Normally this would be feet. This field is only populated if the STATIC_BFE or DEPTH field is populated.
"objectid", -- ObjectID for each segment/polygon
"polygon", -- Spatial polygon data
"sfha_tf", -- Special Flood Hazard Area. T=True, F=False. True for any area coded as an A or V flood zone area. False for any X or D flood areas.
"source_cit", -- Source Citation. Abbreviation used in the metadata file when describing the source information for the feature.
"st_areashape", -- String areashape
"st_perimetershape", -- String perimeter shape
"static_bfe", -- Static Base Flood Elevation. This field will be populated for areas that have been determined to have a constant Base Flood Elevation (BFE) over a flood zone.
"study_typ", -- Study Type. This describes the type of flood risk project performed for flood hazard identification.
"v_datum", -- Vertical Datum. The vertical datum indicates the reference surface from which the flood elevations are measured.
"vel_unit", -- Velocity Unit. This field is only populated when the VELOCITY field is populated.
"velocity", -- Velocity. This is the velocity measurement of the flood flow in the area.
"version_id", -- Version Identifier. Identifies the product version and relates the feature to standards according to how it was created.
"zone_subty" -- Flood Zone Subtype. This field captures additional information about the flood zones not related to insurance rating purposes. Types of floodways are also stored in this field. Floodways are designated by FEMA and adopted by communities to provide an area that will remain free of development to moderate increases in flood heights due to encroachment on the floodplain. Normal floodways are specified as ‘FLOODWAY.’
FROM
"highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest"."flood_hazard_areas_dfirm_statewide"
LIMIT 100;
Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp
with SQL in under 60 seconds.
Query Your Local Engine
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
Read the installation docs.
Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.
It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr
, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgr
can manage the image, container and volume for you.
There are a few ways to ingest data into the local engine.
For external repositories, the Splitgraph Engine can "mount" upstream data sources by using sgr mount
. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.
For hosted datasets (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr clone
and sgr checkout
.
Cloning Data
Because highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest
is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.
First, install Splitgraph if you haven't already.
Clone the metadata with sgr clone
This will be quick, and does not download the actual data.
sgr clone highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp
Checkout the data
Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest
tag:
sgr checkout highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest
This will download all the objects for the latest
tag of highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp
and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.
Alternatively, use "layered checkout" to avoid downloading all the data
The data in highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest
is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:
sgr checkout --layered highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp:latest
This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.
Read the layered querying documentation to learn about when and why you might want to use layered queries.
Query the data with your existing tools
Once you've loaded the data into your local Splitgraph Engine, you can query it with any of your existing tools. As far as they're concerned, highways-hidot-hawaii-gov/flood-hazard-areas-dfirm-statewide-jnr8-3wbp
is just another Postgres schema.