brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr
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 east_baton_rouge_parish_combined_crime_incidents table in this repository, by referencing it like:

"brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr:latest"."east_baton_rouge_parish_combined_crime_incidents"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "statute_title", -- Numerical legal code the LA Revised Statute refers to concerning the crime committed
    "crime_prevention_district", -- If applicable, the name of the crime prevention district where the crime occurred
    "crime_against", -- Description of the party (Person, Property, or Society) which was a victim of the criminal incident
    "statute_description", -- Common terminology for the LA Revised Statutes (ex. theft, battery, property damage)
    "sub_zone", -- Tertiary level in the patrol area hierarchy where the crime occurred
    "district", -- Primary level in the patrol area hierarchy where the crime occurred
    "city", -- Postal city where the crime occurred
    "street", -- Specific street location where the crime occurred
    "report_date", -- Month, day, year, and time of day when the police officer filed the crime incident report
    "charge_id", -- Unique identifier of the crime incident report
    "neighborhood", -- Neighborhood where the crime occurred
    "nibrs_code", -- National Incident-Based Reporting System code for standardized crime reports used by the FBI and other federal agencies
    "state", -- State where the crime occurred
    "attempted_committed", -- Code to indicate whether the crime was attempted or committed
    "approved_date", -- Date the report was reviewed and approved by the supervisor
    "supplemental", -- Additional report used for adding information to the original police report
    "longitude", -- Geographic longitude coordinate (east-west) where the crime occurred
    "postal_code", -- Postal ZIP code where the crime occurred
    "street_2", -- If applicable, the number of the suite or apartment number where the crime occurred
    "charge_date", -- Month, day, year, and time of day when the charges for the crime incident took place
    "incident_number", -- Report number of the incident
    "statute_category", -- One of 18 general codes used for filtering the reported crime data
    "zone", -- Secondary level in the patrol area hierarchy where the crime occurred
    "agency_name", -- Name of the law enforcement agency
    "geolocation", -- Geocoded location for displaying in a map view
    "council_district", -- Metropolitan Council district where the crime occurred
    "enforcement_agency_id", -- Identification code of the law enforcement agency
    "census_block_group", -- Code for the Census block group where the crime occurred
    "offense_description", -- Description of the category of the National Incident-Based Reporting System code
    "latitude", -- Geographic latitude coordinate (north-south) where the crime occurred
    ":@computed_region_4pgc_bhg2", -- This column was automatically created in order to record in what polygon from the dataset 'Census 2010 Tracts' (4pgc-bhg2) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_ntzg_c2w3", -- This column was automatically created in order to record in what polygon from the dataset 'Council Districts_2021_from_d8sa-f3ec' (ntzg-c2w3) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_jrqt_zu77", -- This column was automatically created in order to record in what polygon from the dataset 'ZIP Codes_from_tqy7_429i' (jrqt-zu77) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_uvg4_nwq8" -- This column was automatically created in order to record in what polygon from the dataset 'Neighborhoods_from_qfmj_2fwi' (uvg4-nwq8) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
FROM
    "brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr:latest"."east_baton_rouge_parish_combined_crime_incidents"
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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr 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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr: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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr

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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr:latest

This will download all the objects for the latest tag of brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr 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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr: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 brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr: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, brla-gov/east-baton-rouge-parish-combined-crime-incidents-6zc2-imdr is just another Postgres schema.

Related Documentation:

Loading...