cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd
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 parking_regulation_locations_and_signs table in this repository, by referencing it like:

"cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd:latest"."parking_regulation_locations_and_signs"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "sign_x_coord", -- The longitude of the sign location
    "sign_size", -- Dimensions of sign, height by width.
    "order_type", -- Order type, represents both regulatory category and geometry.
    "arrow_direction", -- "The direction that an arrow on a sign points.  For a block front sign, this is relative to the ""side of street"" direction.  For an intersection sign, it is relative to the street that is assumed north.  Arrow direction is generally applicable only to block front signs, with one significant exception--""One Way"" intersection signs always have an arrow direction.  Only block front signs with a single arrow will have an arrow direction, signs with no arrow or a double arrow will not."
    "from_street", -- For block front and stretch geometries, the street that intersects at the beginning of the block; for an intersection geometry, the minor intersecting street.
    "from_street_suffix", -- Used in cases where an additional field is needed to create a unique location, such as when two streets intersect twice, and/or where there is an additional roadbed.
    "to_street", -- For block front and stretch geometries, the street that intersects at the end of the block; not applicable (null) for an intersection geometry.
    "on_street_suffix", -- Used in cases where an additional field is needed to create a unique location, such as when two streets intersect twice, and/or where there is an additional roadbed.
    "facing_direction", -- "The general rule is that all intersection signs have a facing direction, with the exception of ""One Way"" signs, which only have an ""arrow points"" direction.  There are a few other minor exceptions.  The direction that a sign faces is relative to the ""Street Assumed North/South"".  Block front signs should never have a facing direction, with a few very minor exceptions."
    "order_number", -- Sign, Parking, Regulation, SIMS, STATUS, Location, Street
    "sign_description", -- Includes description of regulation and superseding/superseded sign design if any.
    "on_street", -- For block front and stretch geometries, where the street the signs are on; for an intersection geometry, the major intersecting street.
    "order_completed_on_date", -- The date the order was closed.
    "record_type", -- The totality of signs associated with "Current" sign orders represents the current asset inventory. Repair (R-) orders are always historical.
    "sheeting_type", -- The surface material used for a sign; the current standard is TIII for an intersection sign and "Painted" (PNTD) for a block front sign.
    "sign_code", -- A unique identifier for a sign design.  (Note, the sign code identifies the sign design, not an instance of a sign on the street that uses that design.)
    "sign_design_voided_on_date", -- Date the system started blocking the use of a defunct sign design.
    "borough", -- Lists which of the five administrative divisions of New York City the work order is located in, written as a word. 
    "distance_from_intersection", -- All block front signs have a distance, which is relative to the curb line; intersection signs will have a distance only if the sign is physically located outside the intersection.
    "to_street_suffix", -- Used in cases where an additional field is needed to create a unique location, such as when two streets intersect twice, and/or where there is an additional roadbed.
    "side_of_street", -- For block front and stretch geometries, the side of street, as all block front and stretch orders are written for only one side of a street.
    "sign_notes", -- Notes that provide regulatory information about a particular sign sequence, such as a Bus Stop ID, name or destination, or something unusual about the location or installation of the sign.
    "sign_y_coord", -- The latitude of the sign location
    "sign_location", -- Applicable only to intersection geometry orders and null for all others, an acronym that indicates the placement of a sign within an intersection.
    "support" -- An acronym that represents the type of structure support the signs.
FROM
    "cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd:latest"."parking_regulation_locations_and_signs"
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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd 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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd: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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd

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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd:latest

This will download all the objects for the latest tag of cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd 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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd: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 cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd: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, cityofnewyork-us/parking-regulation-locations-and-signs-nfid-uabd is just another Postgres schema.

Related Documentation:

Loading...