<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey everyone,<div><br></div><div>I have a neat problem! I have been asked to make some maps of weighted polling data! So I have attached \d of the table at the end of this email. Don't
worry about joining to the geometry_columns. I can handle that pretty
easily. </div><div><p>
The problem is specifically that I have a column called finalwt ("Final
weight") that tells me what the weight is for any particular record,
where one row is the record for one respondent, and while I can get
weighted xtabs by doing this in PSQL:<br>
</p><p>
SELECT q1, SUM(1*finalwt) <br>
FROM table <br>
GROUP BY q1;<br>
</p><p>
to get the weighted counts for each question. That's not the problem.
The problem is that QGIS creates maps for export by saying <br>
</p><p>
SELECT q1, count(q1) AS numbers<br>
FROM table<br>
GROUP BY q1;<br>
</p><p>
and then looking at the results of numbers to decide which one gets assigned the colour code for the space.<br>
</p><p>
So I have been looking online to see if there's a way to get QGIS to handle weights, and I can't find one.</p><div>So is there some way I can prep the table in PSQL to be well suited to mapping in QGIS?</div></div><div><br></div><div>Thanks,</div><div><br></div><div>-dx</div><div><br></div><div><br></div><div><br></div><div>Table Description:</div><div><br></div><div><div>nm01=# \d weighted_final </div><div> Table "public.weighted_final"</div><div> Column | Type | Modifiers </div><div>--------------------------+------------------------+-----------</div><div> phone_to | character varying(255) | not null</div><div> phone_from | character varying(255) | not null</div><div> twilio_sid | character varying(255) | not null</div><div> call_start_date_utc | character varying(255) | not null</div><div> call_start_time_utc | character varying(255) | not null</div><div> call_end_date_utc | character varying(255) | not null</div><div> call_end_time_utc | character varying(255) | not null</div><div> q1 | character varying(255) | not null</div><div> q2 | character varying(255) | not null</div><div> q3 | character varying(255) | not null</div><div> q4 | character varying(255) | not null</div><div> q5 | character varying(255) | not null</div><div> q6 | character varying(255) | not null</div><div> q7 | character varying(255) | not null</div><div> q8 | character varying(255) | not null</div><div> q9 | character varying(255) | not null</div><div> q10 | character varying(255) | not null</div><div> q11 | character varying(255) | not null</div><div> q12 | character varying(255) | not null</div><div> q13 | character varying(255) | not null</div><div> q14 | character varying(255) | not null</div><div> q15 | character varying(255) | not null</div><div> q16 | character varying(255) | not null</div><div> q17 | character varying(255) | not null</div><div> q18 | character varying(255) | not null</div><div> q19 | character varying(255) | not null</div><div> q20 | character varying(255) | not null</div><div> q21 | character varying(255) | not null</div><div> q22 | character varying(255) | not null</div><div> q23 | character varying(255) | not null</div><div> q24 | character varying(255) | not null</div><div> q25 | character varying(255) | not null</div><div> q26 | character varying(255) | not null</div><div> q27 | character varying(255) | not null</div><div> q28 | character varying(255) | not null</div><div> q29 | character varying(255) | not null</div><div> q30 | character varying(255) | not null</div><div> q31 | character varying(255) | not null</div><div> q32 | character varying(255) | not null</div><div> q33 | character varying(255) | not null</div><div> q34 | character varying(255) | not null</div><div> q35 | character varying(255) | not null</div><div> q36 | character varying(255) | not null</div><div> qreligion | character varying(255) | not null</div><div> qunion | integer | not null</div><div> qbirthyear | integer | not null</div><div> qrace | character varying(255) | not null</div><div> qparty | character varying(255) | not null</div><div> qgender | character varying(255) | not null</div><div> listid | character varying(255) | not null</div><div> clusternumber | integer | not null</div><div> dwid | integer | not null</div><div> firstname | character varying(255) | not null</div><div> middlename | character varying(255) | not null</div><div> lastname | character varying(255) | not null</div><div> namesuffix | character varying(255) | not null</div><div> fullname | character varying(255) | not null</div><div> age | integer | not null</div><div> electiondayage | integer | not null</div><div> gender | character varying(255) | not null</div><div> gendersource | character varying(255) | not null</div><div> race | character varying(255) | not null</div><div> raceconfidence | character varying(255) | not null</div><div> ethnicity | character varying(255) | not null</div><div> religion | character varying(255) | not null</div><div> racesource | character varying(255) | not null</div><div> partyaffiliation | character varying(255) | not null</div><div> longpartyname | character varying(255) | not null</div><div> registrationdate | character varying(255) | not null</div><div> earliestregistrationdate | character varying(255) | not null</div><div> voterstatus | character varying(255) | not null</div><div> phone | character varying(255) | not null</div><div> phonematchscore | character varying(255) | not null</div><div> regaddrline1 | character varying(255) | not null</div><div> regaddrline2 | character varying(255) | not null</div><div> regaddrcity | character varying(255) | not null</div><div> regaddrstate | character varying(255) | not null</div><div> regaddrzip | character varying(255) | not null</div><div> mailaddrline1 | character varying(255) | not null</div><div> mailaddrline2 | character varying(255) | not null</div><div> mailaddrcity | character varying(255) | not null</div><div> mailaddrstate | character varying(255) | not null</div><div> mailaddrzip | character varying(255) | not null</div><div> mailaddrisdifferent | character varying(255) | not null</div><div> permanentabsenteevoter | character varying(255) | not null</div><div> state | character varying(255) | not null</div><div> countyfips | integer | not null</div><div> fcounty | character varying(255) | not null</div><div> soscountycode | character varying(255) | not null</div><div> ftownship | character varying(255) | not null</div><div> precinctcode | integer | not null</div><div> precinctname | character varying(255) | not null</div><div> uniqueprecinctcode | character varying(255) | not null</div><div> ward | character varying(255) | not null</div><div> congressionaldistrict | integer | not null</div><div> fstatehouse | integer | not null</div><div> statesenate | integer | not null</div><div> municipaldistrict | character varying(255) | not null</div><div> countycommission | character varying(255) | not null</div><div> schoolboard | character varying(255) | not null</div><div> judicialdistrict | character varying(255) | not null</div><div> precinctsplit | integer | not null</div><div> citycouncil | character varying(255) | not null</div><div> countylegislative | character varying(255) | not null</div><div> schooldistrict | character varying(255) | not null</div><div> supervisordistrict | character varying(255) | not null</div><div> district1 | real | not null</div><div> district2 | character varying(255) | not null</div><div> district3 | character varying(255) | not null</div><div> district4 | character varying(255) | not null</div><div> district5 | character varying(255) | not null</div><div> district6 | character varying(255) | not null</div><div> district7 | character varying(255) | not null</div><div> district8 | character varying(255) | not null</div><div> district9 | character varying(255) | not null</div><div> district10 | character varying(255) | not null</div><div> district11 | character varying(255) | not null</div><div> district12 | character varying(255) | not null</div><div> district13 | character varying(255) | not null</div><div> district14 | character varying(255) | not null</div><div> district15 | character varying(255) | not null</div><div> statecountyfips | integer | not null</div><div> name | character varying(255) | not null</div><div> e2000g | character varying(255) | not null</div><div> e2000p | character varying(255) | not null</div><div> e2000s | character varying(255) | not null</div><div> e2001g | character varying(255) | not null</div><div> e2001p | character varying(255) | not null</div><div> e2001s | character varying(255) | not null</div><div> e2002g | character varying(255) | not null</div><div> e2002p | character varying(255) | not null</div><div> e2002s | character varying(255) | not null</div><div> e2003g | character varying(255) | not null</div><div> e2003p | character varying(255) | not null</div><div> e2003s | character varying(255) | not null</div><div> e2004g | character varying(255) | not null</div><div> e2004p | character varying(255) | not null</div><div> e2004s | character varying(255) | not null</div><div> e2005g | character varying(255) | not null</div><div> e2005p | character varying(255) | not null</div><div> e2005s | character varying(255) | not null</div><div> e2006g | character varying(255) | not null</div><div> e2006p | character varying(255) | not null</div><div> e2006s | character varying(255) | not null</div><div> e2007g | character varying(255) | not null</div><div> e2007p | character varying(255) | not null</div><div> e2007s | character varying(255) | not null</div><div> e2008g | character varying(255) | not null</div><div> e2008p | character varying(255) | not null</div><div> e2008s | character varying(255) | not null</div><div> e2009g | character varying(255) | not null</div><div> e2009p | character varying(255) | not null</div><div> e2009s | character varying(255) | not null</div><div> e2010g | character varying(255) | not null</div><div> e2010p | character varying(255) | not null</div><div> e2010s | character varying(255) | not null</div><div> married | character varying(255) | not null</div><div> age_model2010 | character varying(255) | not null</div><div> partisanscore2010 | real | not null</div><div> voteprop2010 | real | not null</div><div> voteprop2012 | real | not null</div><div> cell_phone | character varying(255) | not null</div><div> newAge | character varying(255) | not null</div><div> voteYear | integer | not null</div><div> racewt | real | not null</div><div> sexwt | real | not null</div><div> agewt | real | not null</div><div> collrace | character varying(255) | not null</div><div> compVoteAge | integer | not null</div><div> collage | integer | not null</div><div> finalwt | real | not null</div><div><br></div><div>nm01=# </div></div><div><br></div></body></html>