[postgis-users] query multipolygon

sgrocho2 sgrocho at gmail.com
Tue Jun 2 11:05:56 PDT 2009


I am having trouble querying a multipolygon feature intersection with another
multipolygon feature.  When I execute the query it takes 45 seconds and
returns and incomplete answer, 167 rows.  If I explode the parcel polygon
into its 6 parts and then run the same query it takes 5 seconds and returns
209 rows which is the correct answer.  Is there a way to write this query to
return the all the rows without having to first manipulate the data?  The
same query works fine in SQL Server but we want to use PostGIS. Below is the
code for each of the Parcel tables they include only one parcel - one with 1
row, the other with 6 rows.

THIS IS THE SINGLE FEATURE MULTIPOLYGON CODE: 45sec 167 rows
SELECT DISTINCT g1.objectid As taxpar_id, g1.tax_parcel_num As
parcel_number, g2.objectid As fw_id, g2.wdfw_phs, g2.wdfw_occur_pt,
g2.wdfw_haulout, g2.pc_for_fish, g2.wdfw_fish_dist, g2.pc_oaks,
g2.pc_salmon, g2.wdfw_occur_pl, g2.doh_sf, g2.wdfw_owl, g2.pc_eelgrass,
g2.pc_hydro, g2.wdfw_sasi
	FROM loader.single_parcel As g1, loader.potential_fw_habitat_cons_areas_pg
As g2
    WHERE (g1.tax_parcel_num = '0618161001' AND
ST_Intersects(ST_Buffer(g1.Shape,-1), g2.Shape))

THIS IS THE EXPLODED 6 FEATURES CODE: 5sec 209 rows
SELECT DISTINCT g1.objectid As taxpar_id, g1.tax_parcel_num As
parcel_number, g2.objectid As fw_id, g2.wdfw_phs, g2.wdfw_occur_pt,
g2.wdfw_haulout, g2.pc_for_fish, g2.wdfw_fish_dist, g2.pc_oaks,
g2.pc_salmon, g2.wdfw_occur_pl, g2.doh_sf, g2.wdfw_owl, g2.pc_eelgrass,
g2.pc_hydro, g2.wdfw_sasi
	FROM loader.multi_parcel As g1, loader.potential_fw_habitat_cons_areas_pg
As g2
    WHERE (g1.tax_parcel_num = '0618161001' AND
ST_Intersects(ST_Buffer(g1.Shape,-1), g2.Shape))
 
-- 
View this message in context: http://www.nabble.com/query-multipolygon-tp23836573p23836573.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list