I want to know how far a specific geographic coordinate is from a list of cities ('far' meaning the euclidean distance between the coordinate and the city, not taking roads into account). For this I need to find a bounding-box for each of the cities - all located in Israel.
This post discusses country bounding-boxes, but I need them at the city level.
Is there any way to get this information for a long list of cities, other than drawing rectangles by hand on a map and extracting the coordinates?
You can find the bounding box of those cities at www.mapdevelopers.com/geocode_bounding_box.php. Entering a city will display a box on a map and give the latitude and longitude of each side. Hopefully that will give you the information you need.
The area of the box is the width times height. Here, 29 times 50, or 1450. The perimeter of the box is twice the width plus height. Here, that is 2(29+50), or 158.
A bounding box (usually shortened to bbox) is an area defined by two longitudes and two latitudes, where: Latitude is a decimal number between -90.0 and 90.0. Longitude is a decimal number between -180.0 and 180.0.
A bounding box is an abstract rectangle that acts as a reference point for object detection and produces a collision box for that object. These rectangles are drawn over images by data annotators, who identify the X and Y coordinates of the point of interest within each image.
You can find the bounding box of those cities at www.mapdevelopers.com/geocode_bounding_box.php. Entering a city will display a box on a map and give the latitude and longitude of each side. Hopefully that will give you the information you need.
For a long list of cities, use the Google Geocoding service. Once you get set up, you can use any language to access the REST API. For example you could use the popular standard requests library for Python.
Or, you could use Google's own Google Maps Java API, Python API, or JavaScript API. Any of these contain the Google Geocoding service.
See some simple examples of the Python and Java library here: https://developers.google.com/maps/documentation/webservices/client-library.
Here's the schema for the Geocoding results:
results[]: {
types[]: string,
formatted_address: string,
address_components[]: {
short_name: string,
long_name: string,
postcode_localities[]: string,
types[]: string
},
partial_match: boolean,
place_id: string,
postcode_localities[]: string,
geometry: {
location: LatLng,
location_type: GeocoderLocationType
viewport: LatLngBounds,
bounds: LatLngBounds
}
}
The bounding box is located in the geometry>viewport
variable and looks like this
"viewport" : {
"northeast" : {
"lat" : 37.4238253802915,
"lng" : -122.0829009197085
},
"southwest" : {
"lat" : 37.4211274197085,
"lng" : -122.0855988802915
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With