Selecting polygon id's if their centroid falls in another polygon using PostGIS?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I'm trying to select polygons which centroids fall in another polygon:
SELECT smaller_polygons.id
FROM big_polygon
LEFT JOIN big_polygon smaller_polygons
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
I expect 33,44 to be selected but I get id of the big polygon.
What am I doing wrong?
postgis
add a comment |Â
up vote
2
down vote
favorite
I'm trying to select polygons which centroids fall in another polygon:
SELECT smaller_polygons.id
FROM big_polygon
LEFT JOIN big_polygon smaller_polygons
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
I expect 33,44 to be selected but I get id of the big polygon.
What am I doing wrong?
postgis
1
Hi BERA, it seemsLEFT JOIN
limits the records to the ones provided by thebig_polygon
table. How aboutCROSS JOIN
?
– Kazuhito
1 hour ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to select polygons which centroids fall in another polygon:
SELECT smaller_polygons.id
FROM big_polygon
LEFT JOIN big_polygon smaller_polygons
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
I expect 33,44 to be selected but I get id of the big polygon.
What am I doing wrong?
postgis
I'm trying to select polygons which centroids fall in another polygon:
SELECT smaller_polygons.id
FROM big_polygon
LEFT JOIN big_polygon smaller_polygons
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
I expect 33,44 to be selected but I get id of the big polygon.
What am I doing wrong?
postgis
postgis
edited 1 hour ago
PolyGeo♦
52.1k1779235
52.1k1779235
asked 1 hour ago


BERA
12.4k51737
12.4k51737
1
Hi BERA, it seemsLEFT JOIN
limits the records to the ones provided by thebig_polygon
table. How aboutCROSS JOIN
?
– Kazuhito
1 hour ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago
add a comment |Â
1
Hi BERA, it seemsLEFT JOIN
limits the records to the ones provided by thebig_polygon
table. How aboutCROSS JOIN
?
– Kazuhito
1 hour ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago
1
1
Hi BERA, it seems
LEFT JOIN
limits the records to the ones provided by the big_polygon
table. How about CROSS JOIN
?– Kazuhito
1 hour ago
Hi BERA, it seems
LEFT JOIN
limits the records to the ones provided by the big_polygon
table. How about CROSS JOIN
?– Kazuhito
1 hour ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
This seems to work:
SELECT
smaller_polygons.id
FROM smaller_polygons
INNER JOIN big_polygon
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This seems to work:
SELECT
smaller_polygons.id
FROM smaller_polygons
INNER JOIN big_polygon
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
add a comment |Â
up vote
2
down vote
This seems to work:
SELECT
smaller_polygons.id
FROM smaller_polygons
INNER JOIN big_polygon
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
add a comment |Â
up vote
2
down vote
up vote
2
down vote
This seems to work:
SELECT
smaller_polygons.id
FROM smaller_polygons
INNER JOIN big_polygon
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
This seems to work:
SELECT
smaller_polygons.id
FROM smaller_polygons
INNER JOIN big_polygon
ON ST_Within(ST_Centroid(smaller_polygons.wkb_geometry),big_polygon.wkb_geometry)
answered 58 mins ago


BERA
12.4k51737
12.4k51737
add a comment |Â
add a comment |Â
Â
draft saved
draft discarded
Â
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f299579%2fselecting-polygon-ids-if-their-centroid-falls-in-another-polygon-using-postgis%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Hi BERA, it seems
LEFT JOIN
limits the records to the ones provided by thebig_polygon
table. How aboutCROSS JOIN
?– Kazuhito
1 hour ago
INNER JOIN seems to work with correct FROM table etc.
– BERA
50 mins ago