Using Python I'm attempting to determine the state a coordinate pair resides within.
I've downloaded the US Census State And Equivalent dataset, extracted the shapefiles, and put them into Shapely objects.
sf = shapefile.Reader('shapes/tl_2017_us_state.shp') for record in sf.shapeRecords(): shapely_shape = shape(record.shape) # Ive also tried to parse the shapefile like this according to: # https://gis.stackexchange.com/questions/113799/how-to-read-a-shapefile-in-python?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa # shapely_shape = shape(record.shape.__geo_interface__) if isinstance(shapely_shape, Polygon): shapely_shape = MultiPolygon([shapely_shape]) point = Point(37.907478, -122.369055) if shapely_shape.touches(point): print(record.record)
According to Google Maps the point
(37.907478, -122.369055) should be on the California coast, however the
.touches() doesn't appear to show the intersection. My suspicion is that I'm losing some accuracy when going from a shapefile to a shapely object, so I'm looking for some insight into what I'm doing wrong.