Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h3_polyfill crashes PostgreSQL on random geometry #56

Closed
FelisPimeja opened this issue Jul 12, 2021 · 6 comments
Closed

h3_polyfill crashes PostgreSQL on random geometry #56

FelisPimeja opened this issue Jul 12, 2021 · 6 comments
Assignees

Comments

@FelisPimeja
Copy link

Hello!
When executing query like

select h3_polyfill(st_geomfromtext('POLYGON ((-110.0018386 72.1254917, -110.0018638 72.5810473, -110.0018377 72.108825, -110.0018386 72.1254917))'), 8) h3

I get this error:

SQL Error [XX000]: ERROR: invalid memory alloc request size 1227058752
  Where: SQL function "h3_polyfill" statement 1

env:
PostgreSQL 13.2 (Ubuntu 13.2-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
POSTGIS="3.2.0dev 0a9809b" [EXTENSION] PGSQL="130" GEOS="3.9.0-CAPI-1.16.2" PROJ="8.0.0" LIBXML="2.9.10"
H3 extension version:
3.7.1

I will be pleased to provide any additional information.

@alpha-beta-soup
Copy link

I get this error when indexing large geometries, where "large" is a function of absoliute size as well as the target H3 cell size. I get around this by dividing large geometries into smaller ones before doing polyfill. There are probably also resource constraints on the postgres cluster than can be increased if appropriate.

However in this case I think it's more a matter of your polygon being invalid? It appears to have no area.

Screenshot from 2021-07-13 09-54-22

@zachasme
Copy link
Owner

Hi @FelisPimeja! Yes there is a limit to the size of the geometry that can be polyfilled, in which case you need to divide it beforehand. We should probably provide a helper h3_polyfill_slow (similar to h3_to_children_slow) that handles this for you.

Regarding the invalid polygon, can you tell me what is the H3Index of the polygon?

@zachasme zachasme self-assigned this Jul 19, 2021
@FelisPimeja
Copy link
Author

@zachasme , I'm not pretty sure that's the point. I presubdivide all of the geometries before processing polyfill. So that the initial test example is a sub part of the oiginal much bigger feature. And It managed to return h3 indexes for much larger geometries. More strange is that when I further experimented with "bad features" (causing error) - I've noticed that they are all concentrated around that area in Canada for some reason. No other clues for now, though.

@jashanbhullar
Copy link

jashanbhullar commented Apr 9, 2022

Getting this same error when I increase the number of shapes to be polyfilled. You are talking about splitting up the shapes and then polygilling. How does that work exactly? Any postgis function?
Also, will increasing any of the mem parameters in postgres.conf will help solve this issue?
@FelisPimeja @zachasme

@zachasme
Copy link
Owner

I've merged #65 (thanks @mngr777), and released it as 3.7.2. Could I ask you to test if it solves your issue?

@mngr777
Copy link
Contributor

mngr777 commented Apr 20, 2022

@zachasme Yes, the issue is solved, thank you, 3.7.2 works with mostly the same workflow and data that FelisPimeja was using.
Sorry for answering late, I'm not actually running it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants