├── LICENSE ├── Overpass_Fish.py ├── README.md └── stores.txt /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Overpass_Fish.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | def get_nearby_fish_stores(latitude, longitude, meters): 4 | # Query Builder/Tester 5 | # https://overpass-turbo.eu/ 6 | 7 | # Search Parameters/Syntax 8 | # https://wiki.openstreetmap.org/wiki/Overpass_turbo/Wizard 9 | 10 | # Types of Shops (Not an Exhaustive List, Some Stores use "Fish"/"Fishmonger" instead of "Fishing" for instance) 11 | # https://wiki.openstreetmap.org/wiki/Map_features#Shop 12 | 13 | overpass_query = f""" 14 | [out:json]; 15 | ( 16 | node[shop=pet](around:{meters}, {latitude}, {longitude}); 17 | node[shop=aquarium](around:{meters}, {latitude}, {longitude}); 18 | node[shop~fish](around:{meters}, {latitude}, {longitude}); // Finds any shop w/ "fish" anywhere in the description 19 | node[shop=seafood](around:{meters}, {latitude}, {longitude}); 20 | node[product~fish](around:{meters}, {latitude}, {longitude}); 21 | ); 22 | out body; 23 | """ 24 | # Make a POST request to Overpass API 25 | response = requests.get('http://overpass-api.de/api/interpreter', params={'data': overpass_query}) 26 | 27 | # Check if the request was successful 28 | if response.status_code == 200: 29 | return response.json() # Return the response in JSON format 30 | else: 31 | print("Error:", response.status_code) 32 | return None 33 | 34 | def write_to_file(data, filename): 35 | with open(filename, 'a') as file: # Open in append mode 36 | for element in data['elements']: 37 | tags = element.get('tags', {}) 38 | latitude = element['lat'] 39 | longitude = element['lon'] 40 | name = tags.get('name') or tags.get('contact:name') 41 | phone = tags.get('phone') or tags.get('contact:phone') 42 | email = tags.get('email') or tags.get('contact:email') 43 | website = tags.get('website') or tags.get('contact:website') 44 | twitter = tags.get('twitter') or tags.get('contact:twitter') 45 | facebook = tags.get('facebook') or tags.get('contact:facebook') 46 | instagram = tags.get('instagram') or tags.get('contact:instagram') 47 | youtube = tags.get('youtube') or tags.get('contact:youtube') 48 | 49 | output = [] 50 | # Preparing the output string 51 | if name: 52 | output.append(f"Name: {name}\n") 53 | if phone: 54 | output.append(f"Phone: {phone}\n") 55 | if email: 56 | output.append(f"Email: {email}\n") 57 | if website: 58 | output.append(f"Website: {website}\n") 59 | if twitter: 60 | output.append(f"Twitter: {twitter}\n") 61 | if facebook: 62 | output.append(f"Facebook: {facebook}\n") 63 | if youtube: 64 | output.append(f"Youtube: {youtube}\n") 65 | if instagram: 66 | output.append(f"Instagram: {instagram}\n") 67 | if latitude and longitude: 68 | output.append(f"Location: {latitude}, {longitude}\n") 69 | output.append("\n") 70 | try: 71 | file.write("".join(output)) 72 | except Exception as e: 73 | print("Failed to output because of: " + str(e)) 74 | 75 | # https://www.latlong.net/ 76 | latitude = 45.512230 77 | longitude = -122.658722 78 | meters = 16000 # 10 Miles 79 | 80 | data = get_nearby_fish_stores(latitude, longitude, meters) 81 | 82 | if data: 83 | write_to_file(data, 'stores.txt') 84 | print("Data appended to stores.txt") -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nearby Fish (/etc) Store Finder 2 | 3 | ## Overview 4 | 5 | This Python script utilizes the Overpass API to find nearby fish, coral, and aquarium stores based on their geographical coordinates. The script allows you to specify a radius in meters to search for various types of shops related to fish. 6 | 7 | ![image](https://github.com/user-attachments/assets/39b08d56-4ebb-4c27-8f69-ea3048a9f72b) 8 | 9 | 10 | ## Features 11 | 12 | - Query the Overpass API for nearby stores. 13 | - Support for multiple types of shops (pet, aquarium, seafood, etc.). 14 | - Retrieve various attributes such as name, phone, email, social media links, and location. 15 | - Append results to a text file for easy access. 16 | 17 | ## Requirements 18 | 19 | - Python 3.x 20 | - Requests library 21 | 22 | ## Installation 23 | 24 | 1. **Clone this repository**: 25 | 26 | ```bash 27 | git clone https://github.com/connor9994/Overpass-API.git 28 | cd Overpass-API 29 | ``` 30 | 31 | 2. **Install the required dependencies**: 32 | 33 | If you haven't already installed the `requests` library, do so using pip: 34 | 35 | ```bash 36 | pip install requests 37 | ``` 38 | 39 | ## Usage 40 | 41 | 1. **Set the latitude, longitude, and search radius**: 42 | 43 | Example below is 10 miles surounding Portland, Oregon 44 | 45 | ```python 46 | # https://www.latlong.net/ 47 | latitude = 45.512230 48 | longitude = -122.658722 49 | meters = 16000 # Set the desired search radius in meters 50 | ``` 51 | 52 | Query for this script is: 53 | 54 | ``` 55 | [out:json]; 56 | ( 57 | node[shop=pet](around:{meters}, {latitude}, {longitude}); 58 | node[shop=aquarium](around:{meters}, {latitude}, {longitude}); 59 | node[shop~fish](around:{meters}, {latitude}, {longitude}); // Finds any shop w/ "fish" anywhere in the description 60 | node[shop=seafood](around:{meters}, {latitude}, {longitude}); 61 | node[product~fish](around:{meters}, {latitude}, {longitude}); 62 | ); 63 | out body; 64 | ``` 65 | 66 | And can be modified according to/with these sources 67 | 68 | [Query Builder/Tester](https://overpass-turbo.eu/) 69 | 70 | [Search Parameters/Syntax](https://wiki.openstreetmap.org/wiki/Overpass_turbo/Wizard) 71 | 72 | [Types of Shops](https://wiki.openstreetmap.org/wiki/Map_features#Shop) (Not an Exhaustive List, Some Stores use Fish/Fishmonger instead of "Fishing" for instance) 73 | 74 | [ChatGPT, write me an Overpass API Query to find my local Gamestops](https://platform.openai.com/playground/p/4qgIBvFcHodXtUrwBqsPky72?model=undefined&mode=chat) 75 | 76 | 77 | 78 | 79 | 3. **Run the script**: 80 | 81 | Execute the script to find nearby fish stores and append the data to a text file called `stores.txt`. 82 | 83 | ```bash 84 | python nearby_fish_stores.py 85 | ``` 86 | 87 | 4. **Check the results**: 88 | 89 | After running the script, the results will be appended to `stores.txt`. Each entry includes: 90 | 91 | - Name 92 | - Phone number 93 | - Email address 94 | - Website 95 | - Social Media Links (Twitter, Facebook, Instagram, YouTube) 96 | - Location (latitude and longitude) 97 | 98 | ## Example Script 99 | 100 | Here is a brief overview of the script functionality: 101 | 102 | ```python 103 | import requests 104 | 105 | def get_nearby_fish_stores(latitude, longitude, meters): 106 | ~~~ 107 | 108 | def write_to_file(data, filename): 109 | ~~~ 110 | 111 | # Example usage: 112 | latitude = 45.512230 113 | longitude = -122.658722 114 | meters = 16000 # 10 Miles 115 | data = get_nearby_fish_stores(latitude, longitude, meters) 116 | 117 | if data: 118 | write_to_file(data, 'stores.txt') 119 | print("Data appended to stores.txt") 120 | ``` 121 | 122 | ## Contributing 123 | 124 | Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes. 125 | 126 | ## License 127 | 128 | This is free and unencumbered software released into the public domain. 129 | 130 | Anyone is free to copy, modify, publish, use, compile, sell, or 131 | distribute this software, either in source code form or as a compiled 132 | binary, for any purpose, commercial or non-commercial, and by any 133 | means. 134 | -------------------------------------------------------------------------------- /stores.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Connor9994/Overpass-API/7173992dede32b14f4482d857df9532e57009f0d/stores.txt --------------------------------------------------------------------------------