Skip to main content

Accessing information on population in the word.

Project description

xa

Accessing information on population in the word.

To install: pip install xa

Description

The xa package provides tools for accessing and estimating population data based on geographical locations. It utilizes MongoDB to store and query geographical and population data, which must be pre-loaded into a MongoDB collection named geo_pop_density within a database called util.

The main functionalities include:

  • Retrieving the population of the nearest location given latitude and longitude.
  • Estimating the population within a specified radius of a given point.
  • Advanced methods for approximating population based on population density and fuzzy logic approaches.

The data is expected to be in a specific format, derived from the Global Rural-Urban Mapping Project (GRUMP), available from the Socioeconomic Data and Applications Center (SEDAC).

Usage Examples

Initializing the GeoPop Class

from xa import Geopop

# Create an instance of Geopop
geo = Geopop()

Getting Population of the Nearest Point

# Latitude and Longitude of New York City
latitude = 40.7128
longitude = -74.0060

# Get population of the nearest point
population = geo.population_of_nearest_latlon(latitude, longitude)
print(f"The population at the nearest point is: {population}")

Estimating Population Within a Radius

# Define radius in kilometers
radius = 50  # 50 km radius

# Estimate population within this radius
estimated_population = geo.population_within_radius(latitude, longitude, radius)
print(f"Estimated population within {radius} km: {estimated_population}")

Advanced Usage: Population Density Approach

# This method estimates population based on density and has not been fully verified.
estimated_population_density = geo.population_within_radius_density_approach_not_verified(latitude, longitude, radius)
print(f"Estimated population using density approach within {radius} km: {estimated_population_density}")

Documentation of Key Functions/Classes

Class Geopop

  • __init__(self, pop_db='util', pop_col='geo_pop_density', ...): Initializes the data access connection with MongoDB.
  • population_of_nearest_latlon(self, lat, lon): Returns the population of the nearest location to the given latitude and longitude.
  • population_within_radius(self, lat, lon, radius_km): Estimates the population within a specified radius of a given point. Uses a simple nearest data point calculation if no data points are within the radius.
  • population_within_radius_density_approach_not_verified(self, lat, lon, radius_km): Estimates population using a density approach. Not verified and should be used with caution.

Helper Functions

  • _import_data_into_mongo(filepath='gl_centroids_utf8.csv', ...): Imports data into MongoDB from a specified CSV file. This function is crucial for setting up the database for the Geopop class.

Installation

Ensure that MongoDB is installed and running on your system. Import your geographical and population data into MongoDB using the provided _import_data_into_mongo function before using the Geopop class functionalities.

For more detailed examples and advanced usage, refer to the function documentation within the code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xa-0.0.5.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xa-0.0.5-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file xa-0.0.5.tar.gz.

File metadata

  • Download URL: xa-0.0.5.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for xa-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7cad4b916b184356b5cc04225b00b14a4869920e501b1c7e64924c24853c2eb9
MD5 94877d8b6345884f7fdf9b60b84ba765
BLAKE2b-256 f1fa9a887cfae2fd0b5190c568ebcdf500003a18c7fd9bf99bdcda786e759c57

See more details on using hashes here.

File details

Details for the file xa-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: xa-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for xa-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 386294d901661ffd24f4e40caa1f5d4a8a63a55c406a2b4dd690591747675405
MD5 836f467f108b7142afded8ffac75b634
BLAKE2b-256 2d719a4f5b74a93b417b602528a58f30d261f5fb656ccfe1a3d7e0c51b47ccf4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page