Skip to content

eddiegulay/GIS-APIs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GIS APIs (🌍´◡`🌍)

A collection of maps API from Google maps and Mapbox (mostly experimental)

👌 Available APIs

  1. Coordinate Geocoding
  • Google Maps
  • Map Box
  1. Region Boundary
  • Open Street Overpass API
  • osmnx lib
  1. Distance API
  • Open Street Map (nx network graph)

🗺 Google Maps Geocoding

  1. After Creating account and getting API Key Register it in the code
# Define your API key and endpoint
API_KEY = 'your_api_key_here'
  1. Add Address names to places you want to get geo coordinates
# provide address list
addresses = ['Ubungo Maji', 'Mbezi Louis']
  1. Code response list(longitude, latitude)
lat = result['results'][0]['geometry']['location']['lat']
lng = result['results'][0]['geometry']['location']['lng']

🗺 MapBox GeoCoding

  1. After Creating Account and getting public key
// api_key looks like
* pk.eyJ1IjoiZWRkaWVndWxsZWQiLCJhIj......
  1. Add YOUR_MAPBOX_ACCESS_TOKEN
# add access token here
YOUR_MAPBOX_ACCESS_TOKEN = keys.API_key
  1. Add Address names to places you want to get geo coordinates
# provide list of addresses here
address_list = ['kigamboni']
  1. Output definition
response_body = {
    "place_name": place_name, 
    "longitude" : coordinates[0], 
    "latitude" : coordinates[1],
    "bbox_center" : center,
    "boundary_square_matrix" : boundary
}

@@@ Check response.json to see complete mapbox response @@@

(●'◡'●) Region Boundaries

Just provide location address name and the method will find all coordinated for that region

Overpass API

Response From Overpass API is not very reliable and has complex queries as per requirements (Not satble)

Osmnx API

from osmnx api call get_coordinates(str:)

address_name = "Kigamboni, Tanzania"
boundary_coords = get_coordinates(address_name)
boundary_coords : [(long), (lat)]

📏📐 Map Distance

Getting distance from one point to another on a map. You can either get linear distance with Haversine Algorithm or get distance by following roads

# define starting and ending points
point1 = (39.275229073736654,-6.819505513688398)
point2 = (39.27989377640603,-6.821308691427461)

# call distance method
distance = get_distance(point1, point2) # for linear distance
road_distance = get_road_distance(point1, point2, "drive") # Following road distance

About

maps APIs using Open Street Network package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages