orbisgis / geoclimate

Geospatial processing toolbox for environmental and climate studies
GNU Lesser General Public License v3.0
59 stars 16 forks source link

Side location conflict : Invalid geometries on two cases on OSM workflow around San Diego Zoo #823

Closed MGousseff closed 1 year ago

MGousseff commented 1 year ago

I encounter weird side location conflict error.

First case, the configuration file for the OSM workflow contains :
"input": { "locations": [ "San-Diego"], "area": 2800 }

The error is : 10:54:53.227 [main] INFO org.orbisgis.geoclimate.osm.OSM - Coastline layer created org.h2.jdbc.JdbcSQLNonTransientException: Exception calling user-defined function: "intersection(POLYGON ((502046.43162578647 3611372.4622532343, 502017.7138190603 3611363.8763185465, 502003.5820983386 3611395.7993378933, 502009.8052573869 3611419.146385439, 501988.7344115624 3611443.906880027, 501987.7736849294 3611464.1596649275, 501958.56871275225 3611501.544845948, 501949.18320109707 3611533.7016755263, 501949.1644427181 3611533.701671857, 501971.7224780927 3611528.2299357196, 501970.7681091702 3611516.556847901, 501984.41864935536 3611497.5037996387, 501998.78029611794 3611487.263785165, 502006.4341347131 3611485.3586393236, 502013.8545058477 3611478.4539487073, 502007.6387087478 3611465.3497829237, 502011.71267143113 3611448.6782034603, 502025.1207312957 3611423.6723186234, 502038.2812452597 3611417.0016079578, 502036.13674519793 3611400.56156221, 502046.43162578647 3611372.4622532343)), POLYGON ((470908.2913958587 3599756.131642534, 471096.57950132166 3663995.405250641, 508795.6353204656 3663956.6684471252, 508852.9327798619 3599717.7490409724, 470908.2913958587 3599756.131642534))): side location conflict: arg 0 [ (501949.18463144905, 3611533.6967748255, NaN) ]"; SQL statement: SELECT a."ID",a."barrier",a."crop",a."fence_type",a."hedge",a."landcover",a."landuse",a."layer",a."leisure",a."natural",a."produce",a."surface",a."trees",a."vegetation",a."vineyard",a."wetland", st_intersection(a.the_geom, b.the_geom) as the_geom FROM OSM_VEGETATION_e6282fa0_d460_43bb_84a9_97afa1f56f10 AS a, ZONE_ENVELOPE_45a38672_8c3f_4699_90cd_6b3ddc0099c8 AS b WHERE a.the_geom && b.the_geom [90105-214]

I tried to refine the place where it fails and got an error with the following in the OSM workflow configuration file : "locations": [ [32.704906,-117.167730,32.742815,-117.127991] ] What I don't understand is the error does not show the same polygon :

13:37:30.058 [main] INFO org.orbisgis.geoclimate.osm.OSM - Coastline layer created org.h2.jdbc.JdbcSQLNonTransientException: Exception calling user-defined function: "isIntersects(POINT (485322.5708640533 3619007.564778357), POLYGON ((485174.22636156116 3618978.43946186, 485175.90418379934 3618978.569985263, 485182.342901626 3618978.5714680045, 485237.2553941395 3618979.010760376, 485236.2445009904 3619068.2064767624, 485236.3898918749 3619071.443237188, 485238.7141756658 3619071.4397842744, 485246.62423823215 3619071.428037301, 485247.5801936617 3619071.426618071, 485248.22518308886 3619051.3497557063, 485262.82704531937 3619051.3835176844, 485263.0211639221 3619049.5652020182, 485296.6393807031 3619049.770370118, 485296.532135013 3619065.966495733, 485322.1555028752 3619065.9286153116, 485322.1529812763 3619064.221446619, 485335.9299301319 3619064.156764586, 485338.17927130585 3619064.1756166066, 485343.61519817176 3619064.234110857, 485345.9863768472 3619064.2527849465, 485348.23946095514 3619035.027992972, 485361.6418257073 3619035.141267647, 485361.9976234184 3619028.5448505585, 485362.05352889036 3619021.959960827, 485354.11519643536 3619021.894058642, 485354.18693291704 3619013.335920485, 485358.6294051493 3619013.373716232, 485358.66163459467 3619009.804126762, 485347.72436148615 3619009.8535039546, 485347.8769640936 3618979.866909732, 485378.8056253128 3618980.098493961, 485383.06066829956 3618980.1365764723, 485383.17769334395 3618970.491990288, 485383.3202754119 3618959.106937943, 485370.9405491634 3618947.053008888, 485369.9672898385 3618948.041054108, 485373.1493863857 3618951.3731153994, 485365.03530757595 3618959.289046781, 485357.2647556644 3618952.2722654124, 485348.27100936254 3618961.0763494386, 485335.7393099329 3618960.3853597324, 485325.8627854268 3618967.9602727545, 485238.12926937744 3618967.912842496, 485225.40958725195 3618954.2521963217, 485206.65567073255 3618954.21358308, 485176.5519754942 3618954.180843219, 485174.45253142 3618954.1396329626, 485174.34543968865 3618957.7425913666, 485174.25453919085 3618972.1982638533, 485174.22636156116 3618978.43946186), (485192.60801719374 3618967.6923433472, 485192.62360668555 3618965.574983061, 485206.1572459031 3618965.6656818395, 485206.1416700322 3618967.794127604, 485192.60801719374 3618967.6923433472), (485212.9740935325 3618967.839386269, 485212.98968736036 3618965.7220260296, 485226.5233260521 3618965.81275254, 485226.50774582155 3618967.9411982596, 485212.9740935325 3618967.839386269), (485247.7729756297 3619043.4575258754, 485248.3491796225 3619002.2960793516, 485269.6805671687 3619002.4750618096, 485272.4493921018 3618998.868159244, 485281.7649289264 3618998.5772193186, 485282.28776048205 3618978.234489761, 485336.62777467107 3618978.1541590155, 485335.84137269895 3619042.2518782923, 485333.6295641956 3619042.266227985, 485333.608545723 3619040.7253696783, 485333.64977822657 3619036.91188489, 485331.40980301437 3619036.89302004, 485331.33297676913 3619035.6404680284, 485331.4301795135 3619031.6495320797, 485329.2370147573 3619031.5973420143, 485329.2351654074 3619030.3446793333, 485329.3136230647 3619026.3537710677, 485326.783075936 3619026.3131651613, 485326.8277105823 3619024.8054665616, 485326.81563760823 3619022.9763711956, 485324.49135893106 3619022.9908889728, 485324.6950496355 3619014.9535757066, 485328.3877153926 3619014.970294192, 485328.6921302302 3619005.325429952, 485316.55501733033 3619005.2435865025, 485316.4100065976 3619014.9325577733, 485321.74280127423 3619014.946850443, 485321.68945015274 3619016.8979833014, 485319.884896865 3619019.793973435, 485307.96382011205 3619020.0222163917, 485300.02673181286 3619020.798856193, 485293.2441100887 3619022.715603791, 485288.6544934183 3619024.5736815613, 485272.916754917 3619035.9707512143, 485268.98428277986 3619038.559509597, 485266.28750529187 3619040.181995796, 485262.13788258383 3619041.6957819774, 485253.9209503764 3619043.3486310523, 485247.7729756297 3619043.4575258754), (485247.9830076964 3618976.6003542207, 485272.9790303712 3618976.8071612236, 485272.9528030349 3618978.0820365045, 485272.4493921018 3618998.868159244, 485269.6805671687 3619002.4750618096, 485248.3491796225 3619002.2960793516, 485247.9830076964 3618976.6003542207), (485257.2622504432 3619046.5917352107, 485257.355050813 3619045.970807562, 485257.635392598 3619045.416114895, 485258.1033416097 3619044.971999274, 485258.6840029822 3619044.6939995005, 485259.3399539233 3619044.626513243, 485259.9681008844 3619044.769693443, 485260.52158314013 3619045.123609599, 485260.9159692272 3619045.6329592494, 485261.1325313239 3619046.308855691, 485261.1333863065 3619046.885302254, 485260.91873152065 3619047.495325071, 485260.51648609905 3619048.005856318, 485259.964039931 3619048.3503273483, 485259.32694860717 3619048.4953843337, 485258.6801727172 3619048.4298305544, 485258.1174500087 3619048.164612492, 485257.6669626368 3619047.7440304607, 485257.366248474 3619047.2012853613, 485257.2622504432 3619046.5917352107), (485260.9159692272 3619045.6329592494, 485266.6675024786 3619043.6290338114, 485271.4431196158 3619040.806228534, 485289.2025257296 3619027.5770501737, 485293.9139463183 3619025.6966213156, 485299.44110709906 3619024.0588696874, 485304.9693024416 3619023.119508296, 485319.48667597695 3619023.0315377926, 485320.24749106955 3619024.1611383827, 485320.4368665309 3619025.4689517086, 485322.0127803787 3619026.4088943033, 485322.5787936335 3619028.902303561, 485324.84534023836 3619034.220012743, 485327.5622055399 3619039.8474525316, 485327.6507613269 3619042.6963042114, 485327.0226152319 3619042.5531197367, 485326.3760358561 3619042.620587684, 485325.7859839802 3619042.887511824, 485325.31804823224 3619043.342709755, 485325.03770261863 3619043.897400496, 485324.9448816314 3619044.5072419867, 485325.05826403596 3619045.127864499, 485291.364940674 3619044.8451126046, 485291.2457774613 3619046.6522311964, 485262.06050428475 3619046.396163652, 485261.1325313239 3619046.308855691, 485260.9159692272 3619045.6329592494), (485296.6034869933 3619063.516486855, 485296.6410373449 3619050.890006711, 485298.7497668736 3619050.8868868053, 485301.6176226329 3619050.8715589414, 485315.86321295076 3619050.817241547, 485321.98319827626 3619050.7971144514, 485322.62044106046 3619063.444768704, 485296.6034869933 3619063.516486855), (485324.49135893106 3619022.9908889728, 485326.81563760823 3619022.9763711956, 485326.8277105823 3619024.8054665616, 485324.4940601749 3619024.8199981754, 485324.49135893106 3619022.9908889728), (485326.704602926 3619030.2929879413, 485326.783075936 3619026.3131651613, 485329.3136230647 3619026.3537710677, 485329.2351654074 3619030.3446793333, 485326.704602926 3619030.2929879413), (485329.13924634684 3619060.5972454706, 485329.2939188865 3619051.0967136384, 485334.0550922804 3619051.178369949, 485333.89104307134 3619060.6789155244, 485329.13924634684 3619060.5972454706), (485329.13981289085 3619035.588277982, 485329.2370147573 3619031.5973420143, 485331.4301795135 3619031.6495320797, 485331.33297676913 3619035.6404680284, 485329.13981289085 3619035.588277982), (485331.36855500255 3619040.69541933, 485331.40980301437 3619036.89302004, 485333.64977822657 3619036.91188489, 485333.608545723 3619040.7253696783, 485331.36855500255 3619040.69541933), (485333.6295641956 3619042.266227985, 485335.88824975333 3619042.2628946514, 485335.91253958095 3619046.020855092, 485333.6538548786 3619046.0241884235, 485333.6295641956 3619042.266227985))): side location conflict [ (485248.3491796225, 3619002.2960793516, NaN) ]"; SQL statement: CREATE TABLE filtered_area_543c51ed_e5df_4c5e_b68d_08ffc3a24d00 AS SELECT a.EXPLOD_ID , a.the_geom, st_area(b.the_geom) as area_imp, b.* EXCEPT(the_geom) from polygonized_exploded_b598c7c5_62f3_4501_8443_5754a817708e as a , OSM_IMPERVIOUS_509a2859_5c3f_4959_9a6f_3b3a725c598f as b where a.the_geom && b.the_geom AND st_intersects(st_pointonsurface(a.the_geom), b.the_geom) [90105-214]

Maybe I do something wrong ?

For the record, the following location in an OSM configuration file does not return an error, almost in the same area. "locations": [ [ 32.711622,-117.162752, 32.749889,-117.122154]

ebocher commented 1 year ago

It seems that in San Diego some OSM geometries are invalid.

san_diego_invalid_polygon

geoms_pb

Using the st_valid function we can fix it but it takes a little more time to prepare the data

Below are the LCZs on San Diego with this fix

san_diego

ebocher commented 1 year ago

Fixed

MGousseff commented 1 year ago

Thank you for the fix.