cityofnewyork-us/designated-and-calendared-buildings-and-sites-ncre-qhxs
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 designated_and_calendared_buildings_and_sites table in this repository, by referencing it like:

"cityofnewyork-us/designated-and-calendared-buildings-and-sites-ncre-qhxs:latest"."designated_and_calendared_buildings_and_sites"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "boundaries", -- Whether the landmark site is the entire tax lot (“Block & Lot”) or part of the lot (“Partial lot” or “See designation report” or “See public hearing record”)
    "boroughid", -- Borough expressed as a two character abbreviation (MN=Manhattan, BX=Bronx, BK=Brooklyn, QN=Queens, and SI=Staten Island)
    "bbl", -- Borough expressed as a two character abbreviation (MN=Manhattan, BX=Bronx, BK=Brooklyn, QN=Queens, and SI=Staten Island)
    "pluto_addr", -- Primary address for the tax lot as per Department of City Planning (DCP) records; Note: Can differ from LPC DESIG_ADDRESS field (see below for definition)
    "other_hear", -- Notes other relevant public hearing dates for the item (that are known at this time; not comprehensive)
    "vacant_lot", -- Binary field (0,1) indicating whether a record is a vacant lot; Note: This field is not consistently maintained, meaning items vacant at time of designation but later built upon are not consistently updated (therefore, should never become the basis of its own public-facing query; use PLUTO instead)
    "hist_distr", -- This field notes whether an item is in an historic district and is intended to identify items designated both as individual, interior, or scenic landmarks that are also in historic districts; Note: At this time, this field is not comprehensively maintained and can be derived from the database by different means (eventually this field can be removed)
    "lp_number", -- Internal LPC identifier (LP-XXXXX) used to identify a single action (ex. designation), such as an Historic District or Individual Landmark; Note: Buildings within Historic Districts share a single LP number; multiple buildings designated as part of the same Individual or Scenic landmark will also share a single LP number
    "non_bldg", -- Text field indicating whether a record is a non-building site and describing the entity; Note: This field contains text markers that are an integral part of the complex queries that comprise the official LPC count of “buildings and sites”
    "desig_addr", -- Property address at the time of designation as printed in LPC public hearing and public meeting records and on the LPC designation report for the property; Note: Can differ from Department of City Planning (DCP) records; where LPC has not determined if another property address exists, the address provided by DCP on the PLUTO Tax Lot GIS shapefile is used
    "public_hea", -- Date of public hearing(s); Note: It is possible for one item to have multiple public hearing dates; this field will be blank for items which have not yet had a public hearing
    "lm_type", -- Type of landmark: Individual, Scenic, Interior, or Historic District; Note: Properties can have multiple designations, e.g. Individual and Interior, or Historic District and Individual; each designation type will have its own entry (i.e. record) in the database
    ":@computed_region_sbqj_enih",
    "last_actio", -- Last action taken as part of the LP number (i.e. the LP action), specific to the BBL; Note: The last action on a specific BBL may differ from the greater action on the LP number if, for example, an item was left out of the boundaries of a larger historic district. [Note: See below for list of acceptable actions]
    "bin_number", -- Concatenation of the borough code (1=MN, 2=BX,3=BK,4=QN,5=SI), the five digit tax map block and four digit tax map lot numbers (ex. Manhattan Tax Map Block 123 Lot 45 would appear as 1001230045); Note: numbers in this field are no auto-updated and so some may be outdated; because this file contains both building and non-building landmarks (such as monuments or vacant lots) as well as some landmarks not located on tax map lots (such as bridges), some records display “dummy” BBLs; the following BBLs serve only as “dummy” BBLs: 1000000000, 2000000000, 3000000000, 4000000000, 5000000000
    "the_geom", -- Department of Buildings “Building Identification Number;” Note: numbers in this field are not auto-updated and so some may be outdated; BINs here are derived using building footprint GIS shapefiles from the NYC Department of Information Technology and Telecommunication (DoITT) (2007-2018); because this file contains both building and non-building landmarks (such as monuments or vacant lots), some records display “dummy” BIN numbers; the following BIN #s serve only as “dummy” BIN #s: 1000000, 2000000, 3000000, 4000000, 5000000
    ":@computed_region_92fq_4b7q",
    ":@computed_region_yeji_bk3q",
    "count_bldg", -- Binary field (0,1) indicating whether a record should be counted as a building; Note: This field is only valid for designated items; note, this field should never be used alone as the basis of public-facing queries
    "most_curre", -- Binary field (0,1) indicates whether a record in the database is presently active/current (0=Not active/current; 1=Active/current)
    ":@computed_region_efsh_h5xi",
    "lm_name", -- Official name of the Individual, Scenic, or Interior landmark or of the Historic District as it appears in the designation report
    "status", -- Present designation status of the specific BIN/building (**NOT** the status of/last action on the LP number); all items are either NOMINATED, CALENDARED, or DESIGNATED, or NOT DESIGNATED
    "desdate", -- Date of designation; Note: This field will be blank for items not designated
    "caldate", -- Date of calendaring; Note: Not all items have a date of calendaring (date of calendaring was not tracked until the 1990s)
    "secnd_bldg", -- Binary field (0,1) indicating whether a record could be considered a secondary building (ex. Garage, shed, etc.); Note: Secondary buildings are counted as part of LPC’s definition of “buildings and sites” and the field is not consistently updated (therefore, should never become the basis of its own public-facing query)
    ":@computed_region_f5dn_yrer",
    "block", -- The five digit tax map block number, without leading zeros (ex. tax lot 00123 appears as 123)
    "lot" -- The four digit tax map lot number, without leading zeros (ex. Lot 0456 appears as 456)
FROM
    "cityofnewyork-us/designated-and-calendared-buildings-and-sites-ncre-qhxs:latest"."designated_and_calendared_buildings_and_sites"
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/designated-and-calendared-buildings-and-sites-ncre-qhxs 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/designated-and-calendared-buildings-and-sites-ncre-qhxs: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/designated-and-calendared-buildings-and-sites-ncre-qhxs

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/designated-and-calendared-buildings-and-sites-ncre-qhxs:latest

This will download all the objects for the latest tag of cityofnewyork-us/designated-and-calendared-buildings-and-sites-ncre-qhxs 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/designated-and-calendared-buildings-and-sites-ncre-qhxs: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/designated-and-calendared-buildings-and-sites-ncre-qhxs: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/designated-and-calendared-buildings-and-sites-ncre-qhxs is just another Postgres schema.

Related Documentation:

Loading...