I came across this recently. It is the Diccionario geografico-estadistico de España y Portugal published in 1826. It lists thousands of towns and villages and gives their population!
They are in pdf format and are searchable. If you can not find the village you are looking for, check Volume 11, which is a supplement for those places that were missed.
Volume 1: A – Bar
https://books.google.com/books?id=rkkFAAAAYAAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 2: Bar – Cas
https://books.google.com/books?id=egpDAAAAcAAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 6: Mem – Pes
https://books.google.com/books?id=3gpDAAAAcAAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 7: Pes – Sol
https://books.google.com/books?id=-wpDAAAAcAAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 8: Sol – Ton
https://books.google.com/books?id=EgtDAAAAcAAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 9 – 10: Ton – Zuz
https://books.google.com/books?id=ImrCOb1PrmUC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Volume 11: Supplement A - Z