I am writing a Simulink/Matlab Application that takes in a shapefile. When given a coordinate(lat,long), I want to see if the coordinate is inside a polygon in shapefile in real-time.

My current option: 1) Use OGR tool to read the shapefile and use its feature deterimine if pointi in polygon. I do not know if it is easy to integrate OGR library into Simulink environment.

2) Use Python library to first read shapefile. Pass the read information into Simulink application to perform points in polygon tests.


I would perform the Intersection in Matlab. Use shapewrite() to create a Line Shapefile from 0,0 to the Lat Long point. Import both shapefiles using shaperead(), use polyxpoly to determine the Intersection. Polyxpoly only returns points of intersection at the polygon edge, this is why the Line shapefile is like a ray. An odd number of intersection points indicates the Lat Long point is inside the Polygon.

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.