How to identify city names from shapefiles with coordinate bounds provided

4 views (last 30 days)
I have urban sprawl shapefiles showing the urban expansion cities across the US. However, the attribute table does not provide city names or zip codes. Only city bounds are available in the form of polygons in the shapefile. Is it possible to identify particular city names that surround the urban areas from the available shapefile based on the urban lat-long bounds of the polygons?
  1 Comment
Steven Lord
Steven Lord on 7 Jul 2025
I wonder if you're going to run into problems similar to those with the old XKCD color name survey, where different people may call a region by different names.
For example, would there be people reviewing your work who would be offended if you labeled one of the boroughs of New York City as just "New York City"? Or would that cause problems for your analysis if in one place you labeled a polygon as Brooklyn and in another labeled it as NYC?

Sign in to comment.

Accepted Answer

dpb
dpb on 5 Jul 2025
Moved: dpb on 5 Jul 2025
One would have to have the coordinates of the cities with their names as an auxiliary database. The MATLAB Mapping Toolbox <contains one such file for 318 world populated places>; if your locations are one of those, it should be simple enough to determine which is contained within the boundaries you have. If it isn't, then you'll be out of luck.
  13 Comments
dpb
dpb on 8 Jul 2025
Edited: dpb on 8 Jul 2025
Again, the tools are there, but the specific functionality you're looking for is not implemented directly as with a dedicated GIS system that has its own database of locations and is tied to the location of the device or an input user value. That doesn't just happen by magic; somebody wrote a lot of code and there's a lot of firmware and hardware making that happen so apparently easily. Looks are deceiving.
The first problem here is still that MATLB does not include a builtin list of the locations of all the municipalities in the US in order to be able to ascertain what is the location of the polygon of interest -- only the small(ish) global list.
The file at the link I posted above has something approaching 30,000 US locations in it; your mission, should you choose to accept it, is to use those centroids with isinterior to identify them (the municipality to which the polygon belongs)*.
As I pointed out earlier, with the data structure of one ROI polygon per element, it will take a nested loop to iterate over the polygons with each of the location coordinates. If you could first create a composite of the ROIs as one polyval object, then the lookup could be for each location in turn over a single loop. In practice, it would likely be about as effective to do the double loop directly as to build the composite object over which isinterior will then iterate over internally, anyways.
MATLAB has ways to interact with web services, but I'd expect that to be quite slow in comparison to a direct search and you will have to locate a suitable web server that has the particular service you're needing and figure out how to interact with it.
(*) This, then, likely will also not suffice to answer the question you've posed in that knowing that some place is identified as being within a given polygon may tell you what the name of that suburb is, but it still won't tell you which larger metropolitan areay/city it is a suburb of...and, of course, there is not unique set of names of such entities in each city, there can and are duplicates there. One would have to find or somehow create the list of "proximate to" cities for each of these individual entities. I suppose that has also been done somewhere...
Poulomi
Poulomi on 8 Jul 2025
Thanks, I will work on it and get back if I have any further queries on double looping.

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!