I have a database with one table (ca_licenses) of business addresses and a second table in the public schema (ca_la_la_council) of city council district polygons.
I'm running this query to place the district number from the council table inside the business address table:
UPDATE poursafe.ca_licenses dst
SET prem_council = div_city
FROM public.ca_la_la_council src
WHERE st_within(dst.geom,src.geom) AND dst.geom&&src.geom;
My problem is I keep getting zero results. Both geom columns are geometry type and the SRID is 4326.
#create poursafe.ca_licenses table
CREATE TABLE ca_licenses (
id INTEGER,
license VARCHAR,
lat DOUBLE PRECISION,
lon DOUBLE PRECISION,
geom GEOMETRY,
prem_council VARCHAR
);
#create public.ca_la_la_council table
CREATE TABLE ca_la_la_council (
gid INTEGER,
div_city VARCHAR,
shape_leng NUMERIC,
shape_area NUMERIC,
geom GEOMETRY
);
Sample ca_licenses data: https://raw.githubusercontent.com/PourSafe/data_samples/master/ca_licenses.csv
Sample ca_la_la_council data: https://raw.githubusercontent.com/PourSafe/data_samples/master/ca_la_la_council.csv
I need to populate the ca_licenses table column 'prem_council' with the council district number 'div_city'. To do this I'm running the above query which finds which council district the ca_licenses points lie within.
I created a spatial_ref_sys table for the public.ca_la_la_district table but, do not have a spatial_ref_sys table for the ca_licenses table. Do I need one for this table as well? I believe the SRID for both geom columns is set at 4326.
I'm using postgis 2.4.4 and postgres 9.2 on a centos 7 setup.