PageSourceSearch

https://h3geo.org/assets/js/b9897a48.1b845def.js

js h3geo.org collected 2026-09-24 08:41:05 UTC 11,683 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkh3_website||=[]).push([[4117],{6527(e,n,a){a.r(n),a.d(n,{assets:()=>u,contentTitle:()=>c,default:()=>g,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"api/indexing","title":"Indexing functions","description":"These function are used for finding the H3 index containing coordinates, and for finding the center and boundary of H3 indexes.","source":"@site/versioned_docs/version-3.x/api/indexing.mdx","sourceDirName":"api","slug":"/api/indexing","permalink":"/docs/3.x/api/indexing","draft":false,"unlisted":false,"editUrl":"https://github.com/uber/h3/edit/master/website/docs/api/indexing.mdx","tags":[],"version":"3.x","frontMatter":{"id":"indexing","title":"Indexing functions","sidebar_label":"Indexing","slug":"/api/indexing"},"sidebar":"someSidebar","previous":{"title":"Quick Start","permalink":"/docs/3.x/quickstart"},"next":{"title":"Inspection","permalink":"/docs/3.x/api/inspection"}}');var t=a(4848),o=a(8453),l=a(4865),s=a(9365);const i={id:"indexing",title:"Indexing functions",sidebar_label:"Indexing",slug:"/api/indexing"},c=void 0,u={},d=[{value:"geoToH3",id:"geotoh3",level:2},{value:"h3ToGeo",id:"h3togeo",level:2},{value:"h3ToGeoBoundary",id:"h3togeoboundary",level:2}];function h(e){const n={a:"a",code:"code",h2:"h2",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"These function are used for finding the H3 index containing coordinates, and for finding the center and boundary of H3 indexes."}),"\n",(0,t.jsx)(n.h2,{id:"geotoh3",children:"geoToH3"}),"\n",(0,t.jsxs)(l.A,{groupId:"language",defaultValue:"c",values:[{label:"C",value:"c"},{label:"Python",value:"python"},{label:"Java",value:"java"},{label:"JavaScript (Live)",value:"javascript"}],children:[(0,t.jsx)(s.A,{value:"c",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-c",children:"H3Index geoToH3(const GeoCoord *g, int res);\n"})})}),(0,t.jsx)(s.A,{value:"python",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-py",children:"h3.geo_to_h3(lat, lng, resolution)\n"})})}),(0,t.jsx)(s.A,{value:"java",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"long geoToH3(double lat, double lng, int res);\nString geoToH3Address(double lat, double lng, int res);\n"})})}),(0,t.jsxs)(s.A,{value:"javascript",children:[(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:"h3.geoToH3(lat, lng, res)\n"})}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:"live",live:!0,children:"function example() {\n  const lat = 45;\n  const lng = 40;\n  const res = 2;\n  return h3v3.geoToH3(lat, lng, res);\n}\n"})})]})]}),"\n",(0,t.jsxs)(n.p,{children:["Indexes the location at the specified resolution, returning the index of the cell containing the location. This buckets\nthe geographic point into the H3 grid. See the ",(0,t.jsx)(n.a,{href:"../core-library/geoToH3desc",children:"algorithm description"})," for more information."]}),"\n",(0,t.jsx)(n.p,{children:"Returns 0 on error."}),"\n",(0,t.jsx)(n.h2,{id:"h3togeo",children:"h3ToGeo"}),"\n",(0,t.jsxs)(l.A,{groupId:"language",defaultValue:"c",values:[{label:"C",value:"c"},{label:"Python",value:"python"},{label:"Java",value:"java"},{label:"JavaScript (Live)",value:"javascript"}],children:[(0,t.jsx)(s.A,{value:"c",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-c",children:"void h3ToGeo(H3Index h3, GeoCoord *g);\n"})})}),(0,t.jsx)(s.A,{value:"python",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-py",children:"h3.h3_to_geo(h)\n"})})}),(0,t.jsx)(s.A,{value:"java",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"GeoCoord h3ToGeo(long h3);\nGeoCoord h3ToGeo(String h3Address);\n"})})}),(0,t.jsxs)(s.A,{value:"javascript",children:[(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:"h3.h3ToGeo(h3Index)\n"})}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:"live",live:!0,children:"function example() {\n  const h = '85283473fffffff';\n  return h3v3.h3ToGeo(h);\n}\n"})})]})]}),"\n",(0,t.jsxs)(n.p,{children:["Finds the center of the cell in grid space. See the\n",(0,t.jsx)(n.a,{href:"../core-library/h3ToGeoDesc",children:"algorithm description"})," for\nmore information."]}),"\n",(0,t.jsx)(n.p,{children:"The center will drift versus the centroid\nof the cell on Earth due to distortion from the gnomonic\nprojection within the icosahedron face it resides on and its\ndistance from the center of the icosahedron face."}),"\n",(0,t.jsx)(n.h2,{id:"h3togeoboundary",children:"h3ToGeoBoundary"}),"\n",(0,t.jsxs)(l.A,{groupId:"language",defaultValue:"c",values:[{label:"C",value:"c"},{label:"Python",value:"python"},{label:"Java",value:"java"},{label:"JavaScript (Live)",value:"javascript"}],children:[(0,t.jsx)(s.A,{value:"c",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-c",children:"void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp);\n"})})}),(0,t.jsx)(s.A,{value:"python",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-py",children:"h3.h3_to_geo_boundary(h, geo_json=False)\n"})})}),(0,t.jsx)(s.A,{value:"java",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"List<GeoCoord> h3ToGeoBoundary(long h3);\nList<GeoCoord> h3ToGeoBoundary(String h3Address);\n"})})}),(0,t.jsxs)(s.A,{value:"javascript",children:[(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:"h3.h3ToGeoBoundary(h3Index, [formatAsGeoJson])\n"})}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:"live",live:!0,children:"function example() {\n  const h = '85283473fffffff';\n  return h3v3.h3ToGeoBoundary(h);\n}\n"})})]})]}),"\n",(0,t.jsxs)(n.p,{children:["Finds the boundary of the cell. See the\n",(0,t.jsx)(n.a,{href:"../core-library/h3ToGeoBoundaryDesc",children:"algorithm description"}),"\nfor more information."]})]})}function g(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},9365(e,n,a){a.d(n,{A:()=>i});a(6540);var r=a(4164),t=a(7751);const o="tabItem_Ymn6";var l=a(4848);function s({children:e,className:n,hidden:a}){return(0,l.jsx)("div",{role:"tabpanel",className:(0,r.A)(o,n),hidden:a,children:e})}function i({children:e,className:n,value:a}){const{selectedValue:r,lazy:o}=(0,t.uc)(),i=a===r;return!i&&o?null:(0,l.jsx)(s,{className:n,hidden:!i,children:e})}},4865(e,n,a){a.d(n,{A:()=>p});a(6540);var r=a(4164),t=a(7559),o=a(7751),l=a(3104),s=a(2303);const i="tabList__CuJ",c="tabItem_LNqP";var u=a(4848);function d({className:e}){const{selectedValue:n,selectValue:a,tabValues:t,block:s}=(0,o.uc)(),i=[],{blockElementScrollPositionUntilNextRender:d}
1=(0,l.a_)(),h=e=>{const r=e.currentTarget,o=i.indexOf(r),l=t[o].value;l!==n&&(d(r),a(l))},g=e=>{let n=null;switch(e.key){case"Enter":h(e);break;case"ArrowRight":{const a=i.indexOf(e.currentTarget)+1;n=i[a]??i[0];break}case"ArrowLeft":{const a=i.indexOf(e.currentTarget)-1;n=i[a]??i[i.length-1];break}}n?.focus()};return(0,u.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":s},e),children:t.map(({value:e,label:a,attributes:t})=>(0,u.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:e=>{i.push(e)},onKeyDown:g,onClick:h,...t,className:(0,r.A)("tabs__item",c,t?.className,{"tabs__item--active":n===e}),children:a??e},e))})}function h({children:e}){return(0,u.jsx)("div",{className:"margin-top--md",children:e})}function g({className:e,children:n}){return(0,u.jsxs)("div",{className:(0,r.A)(t.G.tabs.container,"tabs-container",i),children:[(0,u.jsx)(d,{className:e}),(0,u.jsx)(h,{children:n})]})}function p(e){const n=(0,s.A)(),a=(0,o.OC)(e);return(0,u.jsx)(o.O_,{value:a,children:(0,u.jsx)(g,{className:e.className,children:(0,o.vT)(e.children)})},String(n))}},7751(e,n,a){a.d(n,{OC:()=>p,O_:()=>x,uc:()=>v,vT:()=>u});var r=a(6540),t=a(6347),o=a(205),l=a(7485),s=a(679),i=a(1682),c=a(4848);function u(e){return r.Children.toArray(e).filter(e=>"\n"!==e)}function d(e){const{values:n,children:a}=e;return(0,r.useMemo)(()=>{const e=n??function(e){return r.Children.toArray(e).flatMap(e=>{if(!e)return[];if((0,r.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return[e];const n="string"==typeof e.type?e.type:e.type.name;throw new Error(`Docusaurus error: Bad <Tabs> child <${n}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.\nIf you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:n,attributes:a,default:r}})=>({value:e,label:n,attributes:a,default:r}))}(a);return function(e){const n=(0,i.XI)(e,(e,n)=>e.value===n.value);if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e},[n,a])}function h({value:e,tabValues:n}){return n.some(n=>n.value===e)}function g({queryString:e=!1,groupId:n}){const a=(0,t.W6)(),o=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,l.aZ)(o),(0,r.useCallback)(e=>{if(!o)return;const n=new URLSearchParams(a.location.search);n.set(o,e),a.replace({...a.location,search:n.toString()})},[o,a])]}function p(e){const{defaultValue:n,queryString:a=!1,groupId:t}=e,l=d(e),[i,c]=(0,r.useState)(()=>function({defaultValue:e,tabValues:n}){if(0===n.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!h({value:e,tabValues:n}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}const a=n.find(e=>e.default)??n[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:n,tabValues:l})),[u,p]=g({queryString:a,groupId:t}),[f,v]=function({groupId:e}){const n=function(e){return e?`docusaurus.tab.${e}`:null}(e),[a,t]=(0,s.Dv)(n);return[a,(0,r.useCallback)(e=>{n&&t.set(e)},[n,t])]}({groupId:t}),x=(()=>{const e=u??f;return h({value:e,tabValues:l})?e:null})();(0,o.A)(()=>{x&&c(x)},[x]);return{selectedValue:i,selectValue:(0,r.useCallback)(e=>{if(!h({value:e,tabValues:l}))throw new Error(`Can't select invalid tab value=${e}`);c(e),p(e),v(e)},[p,v,l]),tabValues:l,lazy:e.lazy??!1,block:e.block??!1}}const f=(0,r.createContext)(null);function v(){const e=r.useContext(f);if(!e)throw new Error("useTabsContext() must be used within a Tabs component");return e}function x(e){return(0,c.jsx)(f.Provider,{value:e.value,children:e.children})}},8453(e,n,a){a.d(n,{R:()=>l,x:()=>s});var r=a(6540);const t={},o=r.createContext(t);function l(e){const n=r.useContext(o);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.