0

I want accomplish the following using command line python tools only (shapely + fiona)

I was wondering if there was a straightforward way for me to do the following:

  1. Read in a shapefile (all counties in the UK)

  2. Read in a csv with a list of lat / lon (this I know how to do)

  3. Spit out a csv with the same list of points and the polygon id from the shapefile, indicating that the point lies within the polygon (i.e. in the county)

Ive got this to work by manually constructing polygons from a csv export of the shapefile, but I'm afraid that Im not going to deal very well with holes in counties, or edge cases. A standard out-of-the-box solution would be great.

1

The Shapely method object.within(other) looks tailored for your purpose.

You may also be interested in object.touches(other).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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