3

I am quite familiar how to work with the Toblerity RTree library:

import fiona
import rtree

with fiona.open(input_path,'r') as source:   
    p = rtree.index.Property()
    p.filename = "index.idx"
    p.overwrite = False
    p.fill_factor=0.6 # some - absurd  - values for tunning the index
    p.get_pagesize=20 # another absurd value, for demo purposes   
    index = rtree.index.Index(properties=p) #create index
    for f in source:
        ... # process features, add to index etc

I am, however, wondering, how to pass parameters to an index when calling the Geopandas sindex on a GeoDataFrame:

gpd.sindex 

does not take any arguments.

The documentation states that all parameters from RTree are supported, but I am unsure how to pass them to the sindex.

4
  • 1
    The sindex attribute returns an already created spatial index object (either an rtree or pygeos tree object), so currently you cannot control how it is created (i.e. you can't pass custom parameters to its constructor) Commented May 20, 2022 at 18:27
  • Wonderful, thank you, good to know. Can you please add whether the index is now automatically created upon filling the GeoDataFrame, or is it called on-demand when calling sindex (that was my understanding). Commented May 23, 2022 at 23:45
  • 1
    Indeed, it is created on-demand on the first time accessing the sindex attribute. Commented May 24, 2022 at 6:54
  • @joris please post your comments as an answer so this thread can be marked as solved Commented Jun 13, 2022 at 11:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.