- Obtain a shapefile of the coastline for the region you are interested in. Obtain a list of city locations with their coordinates. You can find such files from various sources such as OpenStreetMap, Natural Earth and GeoNames.
- Load both the coastline and city data into MATLAB using the shaperead function to read the shapefile.
- Use the distance function in MATLAB’s Mapping Toolbox to calculate the distance between each city location and the coastline.
- Create a logical index of cities that are within 100 km distance from the coastline by checking if the distance between each city and the coastline is less than or equal to 100 km.
- Use the logical index to select the cities that are within 100 km distance from the coastline.
- In this example, the coastline.shp and cities.shp files represent the coastline and city data, respectively. The geopoint function is used to create a geographic point for each city location. The distance function is used to calculate the distance between each city location and the coastline.