-
Notifications
You must be signed in to change notification settings - Fork 2
Spatial Attributes Assignment
Spatial Attributes can be put into two categories, geometries (geom, longtitude, latitude) and spatial boundaries (geo_cd, geo_censusblock2010, geo_censustract2010, etc). You can find all final consolidated geospatial fields from the table SPATIAL_devdb
CREATE TABLE SPATIAL_devdb (
uid integer,
geo_bbl text,
geo_bin text,
geo_address_numbr text,
geo_address_street text,
geo_address text,
geo_zipcode text,
geo_boro text,
geo_cd text,
geo_council text,
geo_ntacode2010 text,
geo_ntaname2010 character varying,
geo_censusblock2010 text,
geo_censustract2010 text,
geo_csd text,
geo_policeprct text,
geo_firedivision text,
geo_firebattalion text,
geo_firecompany text,
geo_puma text,
geo_schoolelmntry character varying,
geo_schoolmiddle character varying,
geo_schoolsubdist character varying,
geo_latitude double precision,
geo_longitude double precision,
latitude double precision,
longitude double precision,
geom geometry,
geomsource text
);- Input:
-- for Devdb main table
SELECT
distinct uid,
address_numbr as house_number,
address_street as street_name,
boro as borough
FROM _INIT_devdb- Pass through 1B
regularmode - If
2failed, then pass through 1Btpadmode - If
3failed, then mark status asfailure
db-developments/developments_build/python/geocode.pydb-developments/developments_build/sql/_geo.sql
- For every job in
_INIT_devdbwe will passaddress_numbr,address_streetandboro. Geocoded results will be recorded in_GEO_devdb. Here are the columns included below:
CREATE TABLE _GEO_devdb (
geo_address_street text,
geo_address_numbr text,
latitude text,
longitude text,
geo_bin text,
geo_bbl text,
geo_boro text,
geo_cd text,
geo_puma text,
geo_firedivision text,
geo_firebattalion text,
geo_firecompany text,
geo_censustract2010 text,
geo_censusblock2010 text,
geo_council text,
geo_csd text,
geo_policeprct text,
geo_zipcode text,
geo_ntacode2010 text,
grc text,
grc2 text,
msg text,
msg2 text,
uid text,
mode text,
func text,
status text
);-
To create the field
geom, we uselongitudeandlatitudefrom_GEO_devdbas default. For all records, we will creategeomusing the following hierachy:- Take geometry from using DoITT building footprints centroid using
binas a join_key (notebinfromdob_jobapplicationsdirectly) - Take geometry from using DoITT building footprints centroid using
geo_binas a join_key (note thatgeo_binare bins from geosupport, taking from_GEO_devdb) - Then take lat / long from BBL point via GeoSupport
- Lastly, take BBL centroid from shoreline clipped MapPLUTO using
bblas join_key (notebblfromdob_jobapplicationsdirectly)
- Take geometry from using DoITT building footprints centroid using
-
Table
GEO_devdbwill be created with consolidated geometries with the following schema.
CREATE TABLE geo_devdb (
uid integer,
job_number character varying,
bbl text,
bin character varying,
date_lastupdt character varying,
job_desc character varying,
geo_bbl text,
geo_bin text,
geo_address_numbr text,
geo_address_street text,
geo_address text,
geo_zipcode text,
geo_boro text,
geo_cd text,
geo_council text,
geo_ntacode2010 text,
geo_censusblock2010 text,
geo_censustract2010 text,
geo_csd text,
geo_policeprct text,
geo_puma text,
geo_firedivision text,
geo_firebattalion text,
geo_firecompany text,
geo_latitude double precision,
geo_longitude double precision,
mode text,
latitude double precision,
longitude double precision,
geom geometry,
geomsource text
);-
Corrections are applied on
GEO_devdbwith manually researchedlongitude,latitudeandgeom. Note that you can find where geoms are coming from by looking at geomsource. e.g.BIN DOB buildingfootprints BBL DOB MapPLUTO Lat/Long geosupport Lat/Long DCP
db-developments/developments_build/sql/_spatial.sql
- Building on
GEO_devdb, we will use thegeomfield to extract the spatial boundary fields using spatial join and create_SPATIAL_devdb. This table is created to help filling NULLs in any of the spatial attributes. Note thatgeo_schoolelmntry,geo_schoolmiddle, andgeo_schoolsubdistare only coming from spatial joins.
CREATE TABLE _SPATIAL_devdb (
uid integer,
geo_cd character varying,
geo_ntacode2010 character varying,
geo_censusblock2010 character varying,
geo_censustract2010 character varying,
geo_csd character varying,
geo_boro character varying,
geo_council character varying,
geo_bbl character varying,
geo_zipcode character varying,
geo_policeprct character varying,
geo_firecompany character varying,
geo_firebattalion character varying,
geo_firedivision character varying,
geo_puma character varying,
geo_bin character varying,
base_bbl character varying,
geo_schoolelmntry character varying,
geo_schoolmiddle character varying,
geo_schoolsubdist character varying
);- Merging
_SPATIAL_devdbandGEO_devdbwe will create a consolidated spatial attributes with bothgeomand other spatial boundaries.
CREATE TABLE SPATIAL_devdb (
uid integer,
geo_bbl text,
geo_bin text,
geo_address_numbr text,
geo_address_street text,
geo_address text,
geo_zipcode text,
geo_boro text,
geo_cd text,
geo_council text,
geo_ntacode2010 text,
geo_ntaname2010 character varying,
geo_censusblock2010 text,
geo_censustract2010 text,
geo_csd text,
geo_policeprct text,
geo_firedivision text,
geo_firebattalion text,
geo_firecompany text,
geo_puma text,
geo_schoolelmntry character varying,
geo_schoolmiddle character varying,
geo_schoolsubdist character varying,
geo_latitude double precision,
geo_longitude double precision,
latitude double precision,
longitude double precision,
geom geometry,
geomsource text
);-
About
-
Workflow
-
Previous Releases