cityofnewyork-us/suitability-of-cityowned-and-leased-property-for-4e2n-s75z
Icon for Socrata external plugin

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

"cityofnewyork-us/suitability-of-cityowned-and-leased-property-for-4e2n-s75z:latest"."suitability_of_cityowned_and_leased_property_for"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "census_block", -- The 2010 census block that the tax lot is located in.
    "factory_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for factory, warehouse or loft use.
    "other_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for other than Residential, Office, Retail, Garage, Storage, Loft or Factory use.
    "census_tract", -- The 2010 census tract that the tax lot is located in.
    "street_name",
    "street_number",
    "e_designation_number", -- The e-designation number associated with the property, where applicable;
    "overlay_1", -- The primary commercial overlay assigned to the property, where applicable; 
    "his_dist", -- The name of the Historic District as designated by the New York City Landmarks Preservation Commission.
    "total_gross_area_structures", -- Total gross area of all structures expressed in square feet rounded to the nearest integer, where applicable;  
    "allowable_building_to_floor_area", -- Allowable ratio of building floor area to the area of the property, where applicable; 
    "land_use_category", -- A code for the tax lot's land use category, modified for display of parks, New York City Department of Parks and Recreation properties and New York State Office of Parks, Recreation and Historic Preservation properties in the appropriate category on land 
    "community_district", -- The community district (CD) or joint interest area (JIA) that the tax lot is located in, or partially located in.
    "council_district", -- The city council district that the tax lot is located in.
    "fire_comp", -- The fire company that services the property; 
    "sp_dist_1", -- The special purpose district assigned to the tax lot.
    "bldg_depth", -- The depth of the structure or structures, which is the effective perpendicular distance, measured in feet, where applicable; 
    "residential_and_non_residential_units", -- The sum of residential and non-residential units in all structures, where applicable; 
    "num_floors", -- In the primary building on the tax lot, the number of full and partial stories starting from the ground floor.
    "assess_land", -- The actual assessed land value for Fiscal Year 2013.
    "garage_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for garage use.
    "number_of_easements", -- The number of easements, where applicable; 
    "major_use", -- The major use of the structure or structures, where applicable; 
    "health_area", -- The health area; 
    "health_ctr", -- The health center district; 
    "police_prct", -- The police precinct; 
    "commercial_floor_area", -- The exterior dimensions of the portion of the structure or structures allocated for commercial use, where applicable; 
    "residential_floor_area", -- The exterior dimensions of the portion of the structure or structures allocated for residential use, where applicable; 
    "retail_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for retail use.
    "date_created",
    "parcel_name", -- General Property name
    "ratio_building_to_floor_area", -- Ratio of building floor area to the area of the property, where applicable; 
    "map_atlas", -- The map on which the property appears in the most recent atlas of the city property
    "bin",
    "latitude",
    "coordinates", -- The coordinate of the XY coordinate pair that depicts the property’s approximate location as expressed in the New York-Long Island State Plane coordination system; 
    "storage_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for storage or loft purposes.
    "landmark", -- The name of an individual landmark, landmark site (e.g. Richmondtown Restoration), or an interior landmark, as designated by the New York City Landmarks Preservation Commission.
    "zone_dist_1", -- The primary zoning classification of the property; 
    "condominium_number", -- The condominium number assigned to the complex, where applicable; 
    "industrial_business_zone", -- Whether the property is located in an industrial business zone; 
    "zone_dist_2", -- The zoning designation occupying the second greatest percentage of the property’s area, where applicable; 
    "overlay_2", -- The commercial overlay occupying the second greatest percentage of the property’s area, where applicable; 
    "potential_urban_ag", -- Whether the land is suitable for urban agriculture (for description, click “About” then “Attachments”)
    "address", -- An address for the tax lot.
    "lot", -- The number of the tax lot.
    "year_alter_1", -- If a building has only been altered once, this is the date of the alteration.
    "edc___occupied", -- For each property assigned to the economic development corporation, such list shall include the percentage of usable space actually occupied by a tenant or tenants.
    "longitude",
    "bbl",
    "nta",
    "block", -- The tax block that the tax lot is located in.
    "school_dist", -- The community school district that the tax lot is located in.
    "exempt_tot", -- The actual exempt total value, which is determined differently for each exemption program, is the dollar amount related to that portion of the tax lot that has received an exemption or abatement for Fiscal Year 2013.
    "exempt_land", -- The actual exempt land value, which is determined differently for each exemption program, is the dollar amount related to that portion of the tax lot that has received an exemption or abatement for Fiscal Year 2013.
    "lot_type_code", -- The location relative to another lot or water, expressed as mixed or unknown, block assemblage, waterfront, corner, through, inside, interior, island, alley, or submerged land;
    "current_uses", -- Sufficient information to determine the property’s current use or to determine that it has no current use; 
    "total_area", -- Total area, expressed in square feet and rounded to the nearest integer; 
    "proximity_code", -- Whether the structure or structures are detached, semi-detached or attached to neighboring structures, where applicable; 
    "irr_lot_code", -- Whether the property is irregularly shaped; 
    "bldg_front", -- The frontage along the street, measured in feet; 
    "lot_depth", -- The depth, measured in feet; 
    "office_floor_area", -- An estimate of the exterior dimensions of the portion of the structure(s) allocated for office use.
    "zip_code", -- The zip code that the tax lot is located in.
    "bsmt_code", -- A code describing the basement.
    "sp_dist_2", -- The special purpose district assigned to the tax lot.
    "govt_clean_up_program", -- Whether the property is enrolled in a government cleanup, and if so, the name of such program;
    "structure_completed", -- The year construction of the structure(s) was completed and whether such year is an estimate, where applicable; 
    "number_structures", -- The number of structures
    "lot_front", -- The frontage, measured in feet; 
    "contact", -- Agency contact information, including name, telephone number and email address.
    "pluto_version", -- The Version Number related to the release of PLUTO.
    "residential_units", -- The sum of residential units in all buildings on the tax lot.
    "agency", -- The city agency to which the property is assigned
    "boro", -- The borough that the tax lot is located in.
    "open_petroleum_spill", -- Whether the property contains the presence of an open petroleum spill;
    "year_alter_2" -- If a building has been altered more than once, this is the year of the most recent alteration.
FROM
    "cityofnewyork-us/suitability-of-cityowned-and-leased-property-for-4e2n-s75z:latest"."suitability_of_cityowned_and_leased_property_for"
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/suitability-of-cityowned-and-leased-property-for-4e2n-s75z with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cityofnewyork.us. When you querycityofnewyork-us/suitability-of-cityowned-and-leased-property-for-4e2n-s75z:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

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 (like this repository), 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, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.cityofnewyork.us, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "cityofnewyork-us/suitability-of-cityowned-and-leased-property-for-4e2n-s75z" \
  --handler-options '{
    "domain": "data.cityofnewyork.us",
    "tables": {
        "suitability_of_cityowned_and_leased_property_for": "4e2n-s75z"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

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/suitability-of-cityowned-and-leased-property-for-4e2n-s75z is just another Postgres schema.