h3-pg
h3-pg copied to clipboard
Dont get h3_polygon_to_cells to work
Hi,
I am new to h3 and am trying to get this function to work like this:
SELECT h3_polygon_to_cells(polygon(way), array[]::polygon[], 8) FROM planet_osm_polygon where admin_level = '4' LIMIT 5;
Do I do something wrong? The query returns 0 results and when I remove admin_level = '4' runs forever, even though this query returns a count of 8:
SELECT count(*) FROM planet_osm_polygon WHERE admin_level = '4';
Hi stefano! Have you tried increasing the resolution parameter for polygon_to_cells to something higher than 8? What does polygon way look like?
Hi Zacharias! I think the polygon is just too big. I developed a different, very fast way to map polygons to their respective h3 index. Just render a geometry out of each h3 index and cache it next to each h3's geohash in a table. Then ST_INTERSECT them with each polygon, make sure you hit a spatial index. Query takes seconds for an entire state of Germany.
Thanks for the awesome h3 library.
((944324.3535942477,7094859.220597934),(944740.4547188837,7094306.8928755205),(945320.1175713426,7093166.6053562155),(946597.7981588712,7089589.946048961),(948067.2933609862,7087828.8264905065),(950200.0189572982,7085651.066239045),(950601.3257216079,7085174.587010805),(951795.6168785837,7083421.566037993),(952186.793569231,7083062.9089042405),(952500.6032137773,7082562.6854350595),(952787.7629722276,7081944.314529372),(952674.3729389056,7081769.596400095),(952695.7128852908,7081421.332790491),(952369.9920552297,7080682.924438904),(952288.8624103395,7080614.294961216),(952218.5530199545,7080562.781110394),(952021.3060142179,7080401.5941665685),(951647.9627059954,7080163.227749748),(951388.5103688035,7080007.441472043),(951841.313529554,7079387.434916697),(952084.1681306688,7079050.284331785),(951743.9201070592,7078845.301234445),(951275.899571917,7078571.8239501165),(951251.9658813964,7078563.212414376),(950427.3333574982,7078098.259524216),(950210.8503437523,7077969.843952838),(949508.424356847,7077492.759000911),(949492.7283086451,7077486.394817551),(949225.6060585375,7077299.233954739),(948539.4327172878,7076797.296271775),(948516.7235411659,7076790.932646256),(948319.6101188184,7076630.926575161),(947867.3969513685,7076266.755878271),(947635.4405284027,7076055.481650843),(947514.6811447903,7075927.679288319),(947374.8861282519,7075757.210722037),(947355.9618148172,7075743.549440938),(947116.0015204631,7075405.805137517),(947033.0796317711,7075295.977709971),(946884.6016949512,7075086.787706242),(946734.8992437323,7074878.351698329),(946426.7112334713,7074366.650391044),(946415.3566454103,7074350.933317356),(946396.2096929939,7074291.6203554105),(946318.2971813877,7074051.042546547),(946143.1136987263,7073548.749022911),(946085.5726539354,7073384.505358393),(946074.3293853651,7073363.738945077),(946034.176445036,7073256.091219433),(945849.7200487916,7072703.619822336),(945755.1207455155,7072426.799945624),(945582.9317571564,7071981.454102793),(945574.6829828887,7071866.923003319),(945460.814275756,7071557.306372182),(945392.8537266268,7071373.633271535),(945399.9893059868,7070869.695017127),(946322.3714747507,7070694.154562781),(946846.1074150348,7070630.791883356),(946976.5293304484,7070967.023828873),(947013.3204221554,7071034.3168143155),(947196.2851372233,7071276.654840833),(947253.2027928659,7071390.111305888),(947283.938104274,7071439.695245563),(947306.1908704834,7071441.191559384),(947306.8810513264,7071433.7099931035),(947323.4342596073,7071420.392822567),(947339.0189883184,7071410.311440071),(947353.423730427,7071402.324899395),(947368.4852575315,7071399.575436427),(947394.400434988,7071399.369694336),(947504.4397516372,7071411.340151984),(947577.5989209866,7071420.0000411915),(947740.4593360171,7071437.768741938),(947768.1556253264,7071439.639133803),(947813.4292622323,7071419.36410948),(947843.730427626,7071405.373624744),(947869.411834152,7071389.512784179),(947894.7926780528,7071365.085655388),(947914.7077349558,7071332.746945863),(948085.8837159487,7071048.474971998),(948100.0992149229,7071029.042579727),(948138.137084927,7071067.58946009),(948168.171083543,7071085.020716367),(948171.677647503,7071089.546864276),(948258.684961507,7071201.915859726),(948263.8279219816,7071209.602944683),(948444.8000181642,7071479.51599326),(948509.2762672318,7071550.180075884),(948536.0820006148,7071567.967772293),(948636.1359589398,7071676.172441571),(948685.8846393753,7071733.09037308),(948760.8249205772,7071819.711905893),(948869.8734937585,7071925.376118037),(948918.0303054757,7071954.761830479),(949006.3845853182,7071999.635575836),(949065.0276930683,7072041.965648211),(949120.587250923,7072087.812569882),(949178.8407404552,7072121.987497737),(949336.8587576362,7072247.12847314),(949404.04007033,7072291.947753797),(949479.815247713,7072324.64578602),(949574.8486970033,7072346.943377234),(949632.4231376414,7072365.911343907),(949680.6690049513,7072375.601111636),(949748.0284288302,7072376.237119972),(949793.1462184489,7072363.460844679),(950037.2475978603,7072348.664334868),(950118.9338402045,7072351.844366253),(950190.4454810899,7072344.343235436),(950240.539251947,7072342.790633185),(950256.2130362508,7072339.386132927),(950310.4701560633,7072343.782053863),(950352.804958412,7072349.150692528),(950411.0918437913,7072347.149143889),(950439.2779388602,7072347.336204487),(950457.912821619,7072352.686139482),(950469.2562777307,7072346.101604615),(950481.9133038339,7072348.140565114),(950504.6670077522,7072343.538875197),(950526.7305308274,7072340.433671309),(950548.4712273793,7072333.119611543),(950571.1024798576,7072332.521018713),(950588.8134108429,7072329.303583032),(950608.6616760512,7072332.352664488),(950634.8774161332,7072348.776571243),(950650.7070477238,7072364.171676436),(950656.7628280229,7072371.167760839),(950576.4792112629,7072471.844717193),(950834.3062838892,7072551.12263959),(951786.5109442367,7072780.486846225),(952325.1525643382,7072962.415294939),(952928.9160865535,7073191.267563507),(953518.9761794525,7073427.946625771),(953885.8072974634,7073628.018994852),(954068.7497486332,7073764.559028257),(954110.7951203058,7073803.736610532),(954143.534182548,7073810.696545094),(954176.2398489431,7073797.094743188),(954180.2362186625,7073796.870229458),(954206.6412018788,7073762.706797781),(954235.3838944016,7073718.477907535),(954243.3655018915,7073717.91662879),(954275.6926820178,7073728.6370597575),(954293.0028628362,7073774.007281355),(954450.5199423085,7073928.717009986),(954559.624175235,7073563.117465088),(954578.8824471424,7073504.52132512),(954642.0562581676,7073434.232720335),(954696.8922393323,7073397.919367773),(954771.3315828259,7073370.792036116),(954965.6842818018,7073322.580448636),(955032.2978650925,7073325.255744419),(955138.8862775271,7073353.318341934),(955221.5187355429,7073390.866252621),(955319.8806376077,7073448.320325334),(955484.7114076253,7073541.134507461),(955547.3508850947,7073572.771276788),(955616.8587751462,7073596.905857419),(955654.1508045619,7073531.686531614),(955700.6489558662,7073473.109332438),(955775.9009316426,7073450.8272855515),(955816.5436777311,7073441.67875545),(955922.5198329663,7073431.87543429),(956211.2046684405,7073315.901567296),(956411.7801269519,7073216.28026497),(956432.8640385082,7073190.874694474),(956451.3096781325,7073200.266140371),(956448.4153713718,7073237.719786119),(956471.8258602857,7073294.106377383),(956490.9728127022,7073283.311700338),(956550.1279901097,7073248.79502392),(956560.0354247902,7073249.0943548875),(956585.5498520802,7073263.237755896),(956597.4944334422,7073265.819490547),(956619.5579565174,7073276.165145798),(956640.6975278192,7073304.826235845),(956689.1326382632,7073334.890558377),(956715.7157326647,7073345.049219554),(956736.254178716,7073348.472859676),(956768.1026850321,7073345.311137326),(956821.4692489182,7073335.002808706),(956867.900608528,7073332.944886266),(956924.2950625641,7073332.383634786),(956949.2974201962,7073336.892356144),(956960.0174871597,7073342.523584348),(957000.2483511323,7073349.296030197),(957016.5121287373,7073348.360609154),(957037.7852834278,7073346.340100081),(957079.4855646789,7073353.430592521),(957108.4397642342,7073346.65814314),(957127.0523830948,7073339.698615548),(957186.9979288871,7073310.0271497015),(957211.2767098291,7073302.487696549),(957280.2280024264,7073277.530848131),(957285.8162408643,7073272.778953354),(957326.214084073,7073261.778514938),(957370.8198040338,7073231.826718249),(957404.9948877076,7073215.625481206),(957436.5873591948,7073203.596177634),(957448.7991073347,7073201.912450752),(957467.2447469593,7073189.060013982),(957481.7051488131,7073183.48501877),(957539.9586383455,7073144.516285756),(957565.150239112,7073145.26460336),(957581.603259851,7073143.3751015505),(957619.9973522256,7073131.794897302),(957660.5065149253,7073115.78094318),(957695.0044251222,7073098.195563503),(957710.9119803567,7073087.232782695),(957751.3209555146,7073464.241407039),(957725.8287921229,7073572.022918874),(957721.064317917,7073619.656040931),(958188.7731584848,7073658.982581056),(958396.7179672866,7073677.055642498),(958515.5849195558,7073687.383124657),(958523.8114299253,7073744.072260673),(958524.3680273794,7073764.25967785),(958526.0712155885,7073771.518928459),(958534.3645176527,7073776.645310468),(958791.7240484176,7073888.11687395),(958924.5949926283,7073973.9761161525),(959409.7921251999,7074218.630470321),(959414.1113214426,7074221.044121516),(959507.9647841306,7074273.452341251),(959565.5280928198,7074318.657281503),(959650.2088294661,7074423.400512653),(959872.4136650386,7074684.7220039135),(960008.5128744825,7074844.763680689),(960077.4752990288,7074923.46652402),(960091.1564644474,7074940.924963806),(960111.0381255031,7074916.87985575),(960125.4873954081,7074886.6598427305),(960132.923537393,7074863.101410859),(960133.5580584906,7074836.885954518),(960154.675365894,7074831.81502328),(960209.6004026515,7074818.641844369),(960233.823523848,7074812.822449849),(960364.6573213774,7075216.9530537715),(960376.5351110449,7075227.9562028805),(960387.1661224158,7075253.854831749),(960397.2294043836,7075280.745332813),(960611.1965976371,7075215.905135607),(960602.9255594712,7075234.861248125),(960591.8826659847,7075254.865329098),(960593.6415139391,7075279.4915635185),(960672.7340121478,7075472.106533744),(960674.9158741673,7075508.841076741),(960668.3702881088,7075544.452973842),(960656.9043805569,7075596.98221734),(960645.4718688525,7075623.349895306),(960623.9760751803,7075657.147061347),(960549.4476760944,7075727.193362726),(960497.2610988105,7075769.3561820965),(960474.206832267,7075783.410505008),(960467.5053989213,7075828.418191296),(960480.3850640062,7075903.350473192),(960545.1062159532,7076274.971899949),(960547.2435501765,7076334.655283194),(960601.0887878733,7076335.067023364),(960631.211842082,7076344.10659704),(960754.2644072049,7076334.730145038),(960806.4843803358,7076336.320959469),(960854.7970393401,7076326.588923251),(960906.7721095916,7076336.058942954),(960954.0717612294,7076336.058942954),(961015.0637102353,7076358.1245070165),(961078.048278126,7076372.572899433),(961088.679289497,7076381.9493961455),(961124.7134086667,7076397.801502631),(961191.4160475499,7076414.346119796),(961229.876931619,7076447.95949802),(961243.9699791535,7076466.581670312),(961253.287420533,7076486.53270942),(961266.1782175667,7076491.380108297),(961288.7538102997,7076494.711527005),(961307.6224639892,7076512.622605491),(961326.5579093731,7076535.64317327),(961369.8166634953,7076547.303209914),(961391.7688670796,7076556.399173351),(961427.9254376893,7076597.724175586),(961466.8538636197,7076629.260837036),(961503.2553371092,7076685.69025032),(961543.7199720124,7076714.120345568),(961533.4451830123,7076743.879408905),(961413.0531537194,7077094.539420331),(961498.6244462922,7077092.536674364),(961834.8315723861,7077412.140149493),(962054.4649277211,7077589.532653483),(962183.1613910274,7077689.789156283),(962273.909039922,7077745.75814337),(962395.5255836135,7077817.76965843),(962415.0955500951,7077831.621701453),(962447.1332995453,7077771.627554447),(962538.3262264031,7077810.8062081),(962590.4571439417,7077831.528106488),(962646.083493491,7077836.93789736),(962681.7057305449,7077835.739881071),(962742.1299501475,7077867.712002819),(962831.586292949,7077914.884221031),(962914.6528969788,7077972.108990828),(962992.8771031592,7078032.572640623),(963029.5457434267,7078054.174935592),(962910.3448326853,7078398.677715029),(962845.7127363305,7078349.93012171),(962809.0440960635,7078436.343111323),(962703.6134063329,7078705.959186521),(963161.9046179799,7079014.3009808175),(962999.5896684543,7079274.837609035),(962985.9864266794,7079294.45870762),(962856.132240669,7079661.951379612),(962831.0630913422,7079652.6084520025),(962703.5243507402,7079605.051435933),(962432.9511964184,7079504.714556674),(962200.927981758,7080271.830570567),(962025.9003463835,7080464.56678926),(961794.9569307838,7080720.357247399),(961779.6282369016,7080708.897059156),(961751.6759127635,7080690.901600891),(961738.7739837805,7080808.387774899),(961732.8406549211,7080851.8322582925),(961731.4046334899,7080861.307681538),(961729.4008826559,7080871.382353452),(961728.3322155442,7080891.51300946),(961729.2450353686,7081019.93843432),(961742.8594090927,7081020.743674663),(961663.3772926662,7081793.250263936),(961626.8978955331,7082180.618072974),(961636.0928854728,7082188.072321656),(961632.9870716794,7082206.745432657),(961623.7586858929,7082214.424457964),(961614.652751546,7082535.69531821),(961617.2576276305,7082556.972737849),(961625.461874102,7082568.960041657),(961698.1423696411,7082622.640908765),(961989.1649144217,7082894.534649714),(961964.4408555165,7082910.643279023),(961959.5205340235,7082921.394870738),(961973.7360329978,7083101.083473076),(961989.4988728941,7083293.139182478),(961993.9739164241,7083337.646270312),(962033.3253564193,7083828.608242983),(962043.7559927067,7083851.968517457),(962396.8168897068,7083596.67648446),(962339.9103660133,7084621.884491326),(962337.0494550997,7084671.082821416),(962301.5496694859,7085256.821196608),(962299.6015783969,7085294.350546814),(962380.6087718473,7085670.759331348),(962428.4872848373,7085882.739548279),(962477.3788051939,7086097.5924245175),(962522.7303657429,7086302.669360177),(962533.2723215212,7086347.530646922),(962554.6790596008,7086437.2352425875),(962420.2273786206,7086388.531911287),(962250.9215650731,7086328.4355235),(962085.9349477683,7086269.876182498),(962008.3675265836,7086297.591093499),(961933.182342502,7086308.32853942),(961857.2290539335,7086275.666510869),(961755.3494559596,7086196.063920507),(961608.7973463302,7086098.679258334),(961509.0216867322,7086061.520869519),(961348.1984183833,7086063.732004274),(961286.2713856548,7086076.811441104),(961180.5735291467,7086122.908195661),(961087.6551501815,7086182.815638524),(961027.520361255,7086247.070949757),(960979.4526051306,7086329.953387372),(960901.8183922514,7086400.412573209),(960810.7590487825,7086432.063193206),(960792.0796382272,7086491.298352013),(960635.0746284124,7086982.942888257),(960567.7152045334,7087255.960726883),(960527.7515073387,7087386.96315123),(960421.997991085,7087724.374641519),(960307.5058948041,7088115.274895938),(960240.3245821103,7088310.188682645),(960209.9454930729,7088394.985829213),(960194.0045419913,7088454.947931014),(960182.8391970647,7088535.922792638),(960175.1024924545,7088591.162368418),(960173.6887349215,7088602.8963760575),(960172.1079981523,7088609.588142182),(960168.4567188543,7088631.031822946),(960159.3953123037,7088661.1542941565),(960150.2003223642,7088683.422877879),(960135.4727537323,7088713.807973918),(960126.7787015012,7088730.434537829),(960103.1567055549,7088776.977855395),(960080.1914946042,7088819.47253661),(960058.2838188161,7088866.897394674),(960050.6250378496,7088908.249103241),(960020.3461363538,7088937.097952413),(959930.7339462653,7089094.97181152),(959796.2933972342,7089331.825987849),(959798.1413007814,7089349.691097192),(959786.2301152665,7089390.5579205295),(959772.7604568806,7089399.7436116645),(959658.1125133125,7089622.246797913),(959592.1111872212,7089765.267772279),(959509.1892985292,7089876.79555279),(959564.0586755414,7090255.09057482),(959554.3850117914,7090283.775590297),(959579.9773627247,7090511.909526746),(959618.60522603,7090564.031778169),(959621.0542548274,7090594.217843088),(959769.2984207168,7090842.235404708),(959910.7632296168,7091100.59215893),(959910.5405906353,7091118.405004015),(959915.1603495033,7091125.923911691),(959927.6837922174,7091146.343125881),(960081.5050645957,7091489.615054767),(960192.8022914906,7091666.985231291),(960325.1389021459,7091895.927824847),(960387.5780045319,7091979.5631842),(960451.7982187705,7092066.181093179),(960574.5613532173,7092234.375185883),(960830.1175082314,7092504.029513445),(960846.9156193921,7092521.095364813),(961171.1447682765,7092839.502130562),(961506.739637171,7093156.852642325),(961681.7895364434,7093322.387832352),(961901.1668569498,7093532.809693705),(961846.5201189193,7093580.806691896),(961648.4604808999,7093752.465392607),(961678.0825974,7093790.991577815),(962129.6278479047,7094207.120076968),(962233.5891203566,7094298.601875051),(962284.5511832419,7094342.0640712585),(962320.2513439392,7094372.170738811),(962364.445181784,7094414.489089203),(963163.8861049159,7095179.953762354),(963202.8256627956,7095216.629639856),(963255.8471362605,7095271.934557709),(963224.0765535878,7095297.185845982),(963160.7023674793,7095314.482837284),(963160.7023674793,7095297.185845982),(963056.6186435876,7095326.902175369),(963039.7203448851,7095331.761105987),(963018.7811486671,7095355.962001717),(963010.9219926168,7095395.133840746),(963005.155642994,7095521.880830801),(962889.9399700229,7095493.064285543),(962843.8425688853,7095510.36170443),(962803.52264932,7095464.266605748),(962774.7131651025,7095493.064285543),(962734.3821135883,7095481.545201064),(962636.4432255884,7095510.36170443),(962596.1233060231,7095544.919133773),(962551.4173985205,7095541.373331967),(962579.8595284183,7095456.424649835),(962602.4351211512,7095418.922197655),(962623.5746924526,7095378.418247817),(962614.3240427676,7095352.510086492),(962566.9575994351,7095308.798463959),(962540.0294146125,7095272.065879213),(962504.0843510352,7095200.53350494),(962479.1265211994,7095119.978281383),(962436.2462533459,7095061.203876035),(962099.8053563214,7095303.357978458),(962092.5139296744,7095373.709372227),(962065.2295224809,7095458.450800381),(962008.968651834,7095502.819875067),(961963.361056456,7095520.136076052),(961937.846629166,7095547.827067657),(961906.0871784429,7095559.121117761),(961792.307526903,7095585.123759424),(961767.9619542664,7095603.622083143),(961651.4549752023,7095627.448588088),(961618.6045934692,7095630.881862025),(960215.990141423,7095777.181988515),(960212.4056538194,7095776.938090183),(960196.2420637562,7095776.056303976),(959959.3653192972,7095763.092181939),(959887.3861365505,7095748.814786996),(959221.5508662686,7095475.429211877),(959021.7101163965,7095398.454450949),(958753.7863659554,7095302.964012412),(958555.3816375143,7095066.156442367),(958099.4949268686,7094541.614322707),(957856.6514577031,7094288.622673312),(957756.0409019243,7094186.149003647),(957636.0941505944,7094064.0939565515),(957578.8981962247,7094000.244178321),(957525.7987991164,7093949.787461304),(957449.8900383444,7093898.824627513),(957249.4481632222,7093799.169506857),(957109.5863549894,7093735.621968336),(957001.7956920546,7093682.1096341),(956557.5084723494,7093468.157690238),(956342.2277091041,7093516.210565032),(956332.2868785764,7093697.658746904),(956323.0584927895,7093702.929321614),(956291.933563164,7093715.496186496),(956266.163101045,7093725.962336935),(956190.8999933198,7093756.291743424),(956174.0684863118,7093763.08164501),(956161.0218419909,7093768.408533198),(955985.8717551768,7093839.815439935),(955778.8954259448,7093901.7694713315),(955726.285834596,7093913.66139956),(955685.9213872342,7093922.777306145),(955659.6722513053,7093931.555596476),(955720.1966584497,7094033.688342887),(955780.4205029688,7094126.312346398),(955771.4370200618,7094128.84460957),(955680.9342740468,7094152.647922951),(955543.020556903,7094187.368250578),(955418.8102690759,7094219.63146825),(955231.9271079322,7094263.4121143855),(955262.4509123076,7094381.531028233),(955253.2447904189,7094383.313048512),(955191.8075634501,7094398.188243962),(954963.8252463054,7094458.458394777),(954929.9729891553,7094462.885352028),(954876.2835987458,7094435.291942701),(954848.6318372327,7094435.70462385),(954463.0990447684,7094576.580215994),(954085.0914498816,7094716.670438806),(954075.2396749463,7094714.269300035),(954070.1412422681,7094722.4669408575),(953982.8890253843,7094752.106079104),(953739.3999031723,7094837.741300777),(953136.3488256977,7095041.374881995),(953084.6075263771,7095070.1522651855),(952917.6394221361,7095135.999213098),(952892.347633828,7095152.995693629),(952735.9882770597,7095293.227429206),(952722.4852228266,7095318.8164711725),(952710.0397037559,7095332.680363469),(952696.7258926571,7095339.996906393),(952678.5919476066,7095339.865583768),(952663.1630661828,7095325.66399275),(952605.8891881697,7095260.472075252),(952588.4899517586,7095259.290183569),(952455.4631602608,7095311.800112732),(952397.3321221685,7095317.859694652),(952331.5200392116,7095346.281634558),(952303.4897914298,7095350.052473848),(952254.4312918371,7095346.206592993),(952226.5123635462,7095350.85917104),(952181.6394768074,7095366.298995988),(952167.846991898,7095381.100994923),(952148.4662685511,7095395.471529857),(951450.1145750085,7095633.076906797),(950836.220979131,7095849.976594652),(950255.6341748985,7096044.911835848),(950154.4670216657,7096078.308344884),(950144.4705313923,7096081.479144352),(950080.8737063021,7095851.552567749),(950008.6718845736,7095574.636392239),(949311.5113095825,7095829.995534362),(949289.9264603178,7095836.16808189),(949267.1393605523,7095833.747842315),(949249.5286171089,7095827.612819741),(949234.9568957641,7095810.427277216),(949065.0610889154,7095446.368947393),(949051.958784849,7095440.965888666),(948941.229287357,7095599.250771512),(948864.8752486219,7095708.384195804),(948825.2789057466,7095764.987081235),(948812.7331991345,7095836.918543917),(948811.987358546,7095900.070178574),(948810.6403927073,7096014.667478341),(948800.1986244709,7096025.887145879),(948781.4746861196,7096024.104756165),(948782.098075268,7096012.003278683),(948560.6056844366,7095961.5712738605),(948490.8862873529,7095937.631193445),(948407.1628983271,7095923.278436971),(947242.4604620042,7095623.339917949),(946443.9880184423,7095404.213930697),(945709.869372508,7095201.959268485),(945385.1949456603,7095117.539500708),(945120.9336064662,7095061.016278885),(944324.3535942477,7094859.220597934))
It would be way easier and faster if you subdivide the polygons first, as in https://carto.com/blog/subdivide-all-things/.
The polyfill function is quite memory demanding and big and/or complex polygons really stretch the limits. Just using firstST_Subdivide and then h3_polygon_to_cells will help a lot, usually