{"id":13648280,"url":"https://github.com/EverythingMe/geodis","last_synced_at":"2025-04-22T07:31:01.792Z","repository":{"id":46580713,"uuid":"1532306","full_name":"EverythingMe/geodis","owner":"EverythingMe","description":"A redis based geo-resolving library","archived":false,"fork":false,"pushed_at":"2021-10-04T21:24:20.000Z","size":19620,"stargazers_count":322,"open_issues_count":4,"forks_count":41,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-04-28T17:03:16.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EverythingMe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-27T10:30:58.000Z","updated_at":"2024-02-27T07:57:15.000Z","dependencies_parsed_at":"2022-08-28T04:52:26.048Z","dependency_job_id":null,"html_url":"https://github.com/EverythingMe/geodis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgeodis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgeodis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgeodis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgeodis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EverythingMe","download_url":"https://codeload.github.com/EverythingMe/geodis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250195033,"owners_count":21390230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:04:06.520Z","updated_at":"2025-04-22T07:31:00.474Z","avatar_url":"https://github.com/EverythingMe.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/EverythingMe/geodis.svg?branch=master)](https://travis-ci.org/EverythingMe/geodis)\n\n# Geodis - a Redis based geo resolving library\n\n\n* * * * * *\n\nGeodis is a simple and fast python module that allows you to convert IP addresses and latitude/longitude\ncoordinates into geographical locations such as cities, zipcodes and countries.\n\nIt currently supports cities worldwide, and zipcode areas in the US (of course each of these includes higher level data such as country).\nBut it is written in an extensible way, so that adding a new layer of objects and indexing them is very simple.\n\nGeodis is fast, since it uses redis, which is a very fast in memory database, and geohashing to index coordinates.\n\nA single thread, single process python program can resolve about 2000 ips and 3000 lat/lon pairs per second on\na regular desktop machine, when the database is fully loaded with IP ranges, zipcodes and all major cities in the world.\n\n# Geodis - Getting started\n\nBefore you jump into python shell to test geodis , you must first ensure that redis server is running and on which port.\nIf you do not have a clue how to get started with redis-server [here is a link](https://redis.io/topics/quickstart) to get started, download install.\n\nonce redis-server is up and running you can test in python shell as shown below:\n\n    \u003e\u003e\u003e import redis\n    \u003e\u003e\u003e rs = redis.Redis(\"localhost\")\n    \u003e\u003e\u003e rs\n    Redis\u003cConnectionPool\u003cConnection\u003chost=localhost,port=6379,db=0\u003e\u003e\u003e\n\nThe above line showing host and port ensures that redis server is running and accepting incoming connections at port `6379`.\n\n\nUSAGE\n------------------------\n    \u003e\u003e\u003e import redis\n    \u003e\u003e\u003e import geodis.city\n    \u003e\u003e\u003e conn = redis.Redis()\n\n    #getting a city by lat,lon\n    \u003e\u003e\u003e print geodis.city.City.getByLatLon(31.78,35.21, conn)\n    Location: {'name': 'West Jerusalem', 'country': 'Israel', 'lon': '35.21961', 'zipcode': '', 'state': 'Jerusalem District', 'lat': '31.78199'}\n\n    #getting a location by ip\n    \u003e\u003e\u003e print geodis.iprange.IPRange.getCity('62.219.0.221', '62.219.0.221', 31.78, 35.21, conn)\n    Location: {'name': 'West Jerusalem', 'country': 'Israel', 'lon': '35.21961', 'zipcode': '', 'state': 'Jerusalem District', 'lat': '31.78199'}\n\n\nGeodis can also be used as a command line utility\n------------------------\n    $ geodis -P  188.127.241.156 -p 6379\n    Location: {'name': 'Crosby', 'country': 'United Kingdom', 'lon': '-3.03333', 'zipcode': '', 'state': 'England', 'key': 'loc:crosby:united kingdom:england:', 'lat': '53.47778'}\n\n    $ geodis -L  40.90732,-74.07514 -p 6379\n    Location: {'name': 'Rochelle Park', 'country': 'United States', 'lon': '-74.07514', 'zipcode': '', 'state': 'New Jersey', 'key': 'loc:rochelle park:united states:new jersey:', 'lat': '40.90732'}\n\nIMPORTING DATA\n------------------------\nGeodis needs to import its data into redis. In the data folder you will find a list of all cities in the world, and a zipcode database.\n\nThe data files should be where the geodis files are installed if you've installed from pip (e.g `/usr/local/lib/python2.7/site-packages/geodis/data/cities1000.json`), or in the source tree if you've cloned this repo.\n\ndata is imported using a utility called geodis.py. run ./geodis.py --help for more details on importing it.\n\nExamples:\n\n* Cities are imported by running\n      \n        geodis -g -f \u003cdata directory\u003e/cities1000.json -p 6379\n    \n* Zipcodes are imported by running\n     \n        geodis -z -f \u003cdata directory\u003e/zipcode.csv -p 6379\n\n\n** *IMPORTANT*: IP to location data is not provided, you need to buy an ip resolving database that can resolve ip ranges to lat,lon pairs **\n\nRefreshing countries mapping:\n------------------------\nThe data is already generated but if you ever need to update, use:\n\n        python external/geonames/update.py \u003e geodis/countries.py\n\n\nINSTALLING:\n------------------------\n\n* `pip install geodis`\n\n\nRUNNING:\n------------------------\n1. Install geodis\n\n2. Install redis\n\n3. Import data as described above.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEverythingMe%2Fgeodis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEverythingMe%2Fgeodis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEverythingMe%2Fgeodis/lists"}