Hello, I downloaded an OSM file from my area (Italy islands) to process it with Java and present an application to my organization. The purpose is, given a point on the map where a criminal activity is in progress, to find in the vicinity (e.g. 500 meters or 1 Km) all the POIs that represent sensitive targets (banks, schools, jewelers, etc.) that can become secondary targets for crimes. For now, I need this information in data format and not as a map. The problem is that in the OSM file I have the city field is often null and from the geographic coordinates of the city limits I cannot make an initial list of all the POIs present. At this point I thought about changing cities hoping that there is one that has a more complete OSM file. asked 10 May '21, 05:07 Lorenzopandolfo |
You cannot count on the addr:city field being set. You have to work, as you say, with the geographic coordinates of the city boundary which will often be present in OSM. If you load the OSM data into a PostgreSQL database with osm2pgsql, creating the list of POIs in a city is trivial. First, find the relation ID of the city,
(Add an "and name like '%something%' to reduce the list to certain names only. In some countries cities might have a different admin_level; sometimes this also depends on the city size. Check the boundary=administrative wiki page for details.) Once you have the ID of the boundary (let's say it was -41485 which is the city of Rome), you can do something like
You could also add something like "and amenity in ('bank','post_office', ...)" to that query to limit the results. answered 10 May '21, 09:43 Frederik Ramm ♦ |
Which "city field" is null? Is this about the
addr:city
tag?exactly I am referring to that tag.
What tool, or library, are you using to read the OSM file ? You probably can search around a point and don't care about the city limits.
If you need to reduce the size of the file, I pretty sure osmium, or osmconvert, can crop an OSM file based on a geoJSON, which you could get from overpass-turbo.
Regards.