0

Geopandas is able to read in only part of a file using:

roi= geopandas.GeoDataFrame(geometry)
indexed_data = geopandas.read_file("path-to-file", mask=roi)

or

geopandas.read_file("path-to-file", bbox=(0, 0, 10, 20))  

However, some of the vector data I want to read extends (far) beyond the bbox / mask as the full line which comes into contact with the bbox / mask is included. To avoid reading superfluous data, I would like to clip the vector while reading it into Python.

Is there a method to read vector data while clipping it by a certain region?

Reading all data and subsequently clipping it to a region would be an option, but is rather avoided since the data set is quite large.

4
  • what do you want to cut? a raster?
    – Helios
    Mar 18, 2022 at 14:43
  • I would like to cut a vector (coastline, hence possibly very long for some regions in the world).
    – sir_olf
    Mar 18, 2022 at 17:10
  • Define a different bbox or mask for the data you want?
    – GISHuman
    Mar 18, 2022 at 18:28
  • seems like using mask parameter is fine? have you tried it tho? did it take long?
    – sutan
    Mar 24, 2022 at 14:29

1 Answer 1

-1

Same question, the result with mask only use spatial index(for intersection). So it's fast. If you are considering performance(ignore memory), reading all data and subsequently clipping it may be same.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.