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.
1 Answer 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.
mask
parameter is fine? have you tried it tho? did it take long?