PostGIS: Spatial Joins Summing using Lats/Lngs

المشرف العام

Administrator
طاقم الإدارة
I have a table, called pets, with lats and lng coordinates and variables and a table that was created by uploading a shape file, called city, with columns left, right, top, bottom, lat, lng, and geom.

lat lng cats dogs -99.4 42.1 2 0 -98.1 44.3 1 1 -99.7 43.6 0 3 -99.8 42.0 2 1 I'm wondering how I would construct a query that will sum up the number of cats and dogs within each boundary. Usually I would do a spatial join in QGIS but my dataset is too large and it crashes before successfully joining the two.

I am pretty familiar with QGIS and Postgres, but very new to PostGIS. I've constructed a query but unsuccessful in getting the answer I needed:

select sum(pets.dogs) from pets, city WHERE ST_Within(pets.dogs, city.geom); Any pointers or resources on PostGIS written for a newbie would be greatly appreciated. Thanks!



أكثر...
 
أعلى