datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2
Loading...

Query the Data Delivery Network

Query the DDN

The 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 apd_average_response_time_by_day_and_hour table in this repository, by referencing it like:

"datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2:latest"."apd_average_response_time_by_day_and_hour"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "council_district", -- The council district where the incident occurred.
    "report_written_flag", -- A flag indicating that a responding unit wrote a report in the Records Management System based on this CAD incident. Note that a report being written does not necessarily mean that a criminal offense took place.
    "response_hour", -- An integer representing the hour of day of the Response Datetime.
    "initial_problem_category", -- A general category describing the problem that the CAD incident was meant to address based on the Initial Problem Description value.
    "response_day_of_week", -- The three-character day of week of the Response Datetime.
    "officer_injured_killed_count", -- A count of officers seriously injured or killed in a use of force related to this CAD incident where the subject of the use of force was a person with mental illness.
    "incident_number", -- A unique integer identifying a Computer Aided Dispatch (CAD) incident, consisting of a two-digit year number, three-digit day-of-year and four-digit incident-count number. 
    "subject_injured_killed_count", -- A count of the subjects of a use of force who were seriously injured or killed in a use of force related to this CAD incident where those subjects had a mental illness.
    "priority_level", -- The priority level assigned to the incident at the time of the first officer's arrival. Priority levels range between 0 and 4, with 0 being the highest priority and 4 being the lowest priority.
    "sector", -- The Austin Police Department patrol sector where the incident occurred.
    "mental_health_flag", -- A flag indicating whether a given incident was mental-health related or not. A given incident may be flagged as mental-health-related due to the initial problem description, the final problem description, the call disposition, because a crisis counselor was assigned to the call, because the caller asked for mental health services, because a 911 call taker assessed mental health played a role in the call or because the subject of a use of force related to the incident displayed "Emotionally Disturbed Person" conduct. Please note that multiple of the preceding conditions are often true for mental-health related calls. Problem descriptions related to mental health may indicate the call is related to an "Emotionally Disturbed Person" or an attempted suicide. Call dispositions that indicate a call is mental-health-related will contain an "MH" in the call disposition description and indicate that a responding officer assessed that mental health had a role in the incident.
    "response_datetime", -- The date and time that the 911 call-takers Emergency Call Taker (ECT) screen opened following the 911 call being answered in the case of dispatched incidents. In the case of officer-initiated incidents, this field indicates the time the incident was created and sent to the incident queue if it was created via the officer's onboard computer or the time the dispatcher opened their ECT screen and created the incident if the officer created the incident through dispatch.
    "first_unit_arrived_datetime", -- The date and time that the first APD unit arrived on scene to the incident. This is the endpoint for response time calculations. Multiple units may arrive on a single incident, while individual units may be made up of one or more officers.
    "final_problem_category", -- A general category describing the problem that the CAD incident was meant to address based on the Final Problem Description value.
    "geo_id", -- A Census Block Group identifier; a concatenation of the current state FIPS code, county FIPS code, census tract code, and block group number.
    "call_closed_datetime", -- The date and time that the incident was closed, indicating that all units have left the scene and it is no longer active.
    "census_block_group", -- Shortened Block Group Name based on the Census Bureau's Geo ID. State digits have been removed due to system limitations.
    "other_injured_killed_count", -- The number of persons seriously injured or killed in an incident related to this CAD incident where there was also a use of force against an individual with mental illness where either the subject of that use of force or the officer involved in that use of force were seriously injured or killed.
    "incident_type", -- A flag indicating whether a given incident was dispatched or officer-initiated. Dispatched incidents are received via 911 calls while officer-initiated incidents are created by officers in the field.
    "number_of_units_arrived", -- A count of the number of APD units that arrived on scene in response to the CAD incident. Please note that some units may consist of more than one APD officer, while certain units may also include civilian personnel such as crime scene technicians. Moreover, this count may include a variety of type of personnel including patrol officers, investigators, supervisors and public information officers if such personnel are required for the incident response.
    "unit_time_on_scene", -- The total amount of time spent on scene by all APD units in seconds.
    "call_disposition_description", -- A description of the outcome of the call.
    "initial_problem_description", -- A preliminary description of the problem meant to be addressed by the CAD incident based on either the information given to the 911 call taker in the case of dispatched incidents, or information collected by officers in the case of officer-initiated incidents. Initial problem descriptions may differ from final problem descriptions based on additional information that comes to light during the call-taking and response processes.
    "response_time", -- The amount of time between when the 911 call was answered when the first officer arrived on scene in seconds. Please note that this field is not applicable to officer-initiated incidents and is left blank for such incidents.
    "final_problem_description" -- A description of the ultimate issue that was meant to be addressed by the CAD incident. This may differ from the initial problem description based on additional information that comes to light during the call-taking and response processes. Certain final problem descriptions may describe specific criminal offenses from the Texas Penal Code.
FROM
    "datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2:latest"."apd_average_response_time_by_day_and_hour"
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 datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2 with SQL in under 60 seconds.

Query Your Local Engine

Install Splitgraph Locally
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; sgrcan 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 cloneand sgr checkout.

Cloning Data

Because datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2: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 datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2

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 datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2:latest

This will download all the objects for the latest tag of datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2 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 datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2: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 datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2: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, datahub-austintexas-gov/apd-average-response-time-by-day-and-hour-fsje-8gq2 is just another Postgres schema.

Related Documentation:

Loading...