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.

asked Mar 18, 2022 at 13:10
4
  • what do you want to cut? a raster? Commented Mar 18, 2022 at 14:43
  • I would like to cut a vector (coastline, hence possibly very long for some regions in the world). Commented Mar 18, 2022 at 17:10
  • Define a different bbox or mask for the data you want? Commented Mar 18, 2022 at 18:28
  • seems like using mask parameter is fine? have you tried it tho? did it take long? Commented 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.

answered Oct 19, 2022 at 3:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.