citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue
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 streetlight_fixtures table in this repository, by referencing it like:

"citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue:latest"."streetlight_fixtures"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "symbol_rotation", -- This field indicates the degree of rotation of the symbol in a map. 
    ":@computed_region_v3p2_n653", -- This column was automatically created in order to record in what polygon from the dataset 'Arizona Postal Code Boundaries v1.0' (v3p2-n653) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "shape", -- This field indicates the shape of this feature class in binary format: Point feature. 
    "created_date", -- This field indicates the date the feature was created.
    "created_year", -- This field indicates the year the feature was created.
    "created_month", -- This field indicates the month the feature was created.
    "conversion_month", -- If available, the month that the streetlight lamp type was converted to LED.
    "conversion_year", -- If available, the year the streetlight lamp type was converted to LED.
    "modified_date", -- This field indicates the date of the last modification to the feature.
    "modified_year", -- This field indicates the year the feature was modified.
    "modified_month", -- This field indicates the month the feature was modified.
    "latitude", -- Latitude of location where the streelight fixture is located.
    "longitude", -- Longitude of location where the streelight fixture is located.
    "geolocation", -- The geographic location of the streetlight.
    "conversion_date", -- The date the streetlight was converted to LED.
    "link_key", -- This field is a reference ID for an associated street segment. 
    "quarter_section", -- This field indicates the quarter section containing the fixture. 
    "boundary", -- The field indicates which City of Mesa Streetlights Crew is responsible for the fixture: East or West. 
    "verified", -- This field indicates whether the fixture is staff verified or not. 
    "cwwo", -- This field indicates the Cityworks Work Order number. Cityworks is our work management system. 
    ":@computed_region_b7fy_h722", -- This column was automatically created in order to record in what polygon from the dataset 'City Boundary' (b7fy-h722) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_c83p_wm8i", -- This column was automatically created in order to record in what polygon from the dataset 'Mesa Census Tracts To City Boundary v1.2' (c83p-wm8i) the point in column 'geolocation' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "objectid", -- This field is a computer-generated unique ID.
    "fixture_number", -- This field indicates the number assigned to the fixture.
    "location", -- Streetlight Location
    "fixture_usage", -- This field designates what the lighting is for: Roadway, Novelty (decorative), or Pedestrian.
    "fixture_type", -- This field indicates the type of fixture: Cobra Head, Column, Decorative, Post Top, Shoebox, Transit, Wall Pack.
    "brand", -- This field indicates the brand of the fixture: American Electric, Cooper, Cree, Firstlight, GE, Kim, Phillips, Sternberg, Sterner, Wild West.
    "model_description", -- This field describes the model of the fixture.
    "model_number", -- This field indicates the model number of the fixture.
    "lamp_type", -- This field describes the type of lamp used in the fixture: high pressure sodium (HPS), light-emitting diode (LED), or metal halide (MH).
    "wattage", -- This field indicates the wattage of the lamp, or the amount of energy it takes to produce a certain amount of light.
    "lumen", -- This field indicates the lumens of the lamp, or the amount of light a certain lamp gives off.
    "cct", -- The Correlated Color Temperature (CCT) is a specification of the color appearance of the light emitted by a lamp measured in degrees Kelvin (K).
    "distribution_type", -- This field describes the type of shape the light takes on the ground.
    "photo_cell", -- This field indicates whether a photo cell is installed on the fixture or not. A photoconductive cell turns streetlights on and off automatically according to the level of daylight. One photo cell can control multiple streetlights.
    "monitor_system", -- This field indicates the name of the monitor system company.
    "small_cell", -- This is the name of the company who has a cellular tower attached to pole, if applicable.
    "shield", -- This field indicates whether there is a shield on the fixture or not.
    "pole", -- This field describes the type of pole used for the fixture.
    "utility", -- This field indicates who provides the electrical feed for the fixture: Salt River Project (SRP) or City Of Mesa (COM).
    "county_light", -- This field indicates whether the fixture is within Maricopa County jurisdiction or not.
    "feed_method", -- This field indicates the type of power feed to the fixture: Cabinet, Individual, Metered Pedestal, or Unmetered Pedestal.
    "isactive", -- This field indicates whether a fixture is currently being maintained by the City of Mesa.
    "facilityid", -- This field is a computer-generated unique identifier used for Cityworks, which is our work management system.
    "cabinet_id", -- This number correlates to the Link ID in the Cabinet Feature Class. 
    "cabinet_number", -- This is the number of the cabinet that the fixture is assigned to.
    "project_name", -- This field indicates the name of the project that the streetlight installation corresponds to.
    "loa", -- This field indicates the name of the project that the streetlight installation corresponds to.
    "letter_of_acceptance_year", -- The Year of the Letter of Acceptance: this is the date a project passes final inspection. 
    "letter_of_acceptance_month", -- The Month of the Letter of Acceptance: this is the date a project passes final inspection. 
    "path_id", -- This field indicates the name of the Multi-use Pathway that the fixture is on, if applicable.
    "path_pole_id", -- This field indicates the unique identifier for the pole, if applicable.
    ":@computed_region_c54k_jm6w",
    "conversion_month_date", -- If available, the date representing the month that the streetlight lamp type was converted to LED.
    "symbol_type" -- This field is a concatenation of Usage, Fixture Type, Lamp Type, and Photocell. It is used to symbolize a feature on a map. 
FROM
    "citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue:latest"."streetlight_fixtures"
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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue 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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue: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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue

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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue:latest

This will download all the objects for the latest tag of citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue 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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue: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 citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue: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, citydata-mesaaz-gov/streetlight-fixtures-jrtd-htue is just another Postgres schema.

Related Documentation:

Loading...