A comprehensive package for analyzing Australian geospatial data with PBF, OpenStreetMap Overpass API, and Google Maps API support
Project description
OpenCivics Python Package
A comprehensive Python package for analyzing Australian geospatial data, including census data, OpenStreetMap features, and interactive map visualization.
Features
🏛️ Census & ABS Data (census module)
- Download Australian Statistical Geography Standard (ASGS) boundary files
- Load and process Suburbs and Localities (SAL) and Local Government Areas (LGA) data
- Merge census data with geographical boundaries
- Calculate centroids for mapping applications
🗺️ Location Data Extraction
PBF-based (osm module):
- Extract features from large OSM PBF files using configurable tag rules
- Spatial analysis of amenities, services, and infrastructure
- Built-in feature configurations for Australian contexts
- Custom metrics calculation for urban analysis
API-based (api_extractor module):
- OpenStreetMap Overpass API: Free, no API key required
- Google Maps Places API: Commercial data with ratings and reviews
- No need to download large PBF files
- Automatic chunking for large areas
- Concurrent processing for faster extraction
- Same feature configuration system as PBF extraction
📊 Interactive Mapping (mapping module)
- Create interactive Folium maps with Australian city presets
- Multi-layer visualizations with custom styling
- Automated popup generation from analysis data
- City-specific zoom levels and bounds for major Australian cities
Installation
pip install -e .
For development:
pip install -e ".[dev]"
Quick Start
Option 1: Using OpenStreetMap Overpass API (Free)
import opencivics
# Download and load ABS boundary data
boundary_files = opencivics.download_aus_boundary_files("boundaries/")
boundaries = opencivics.load_abs_boundaries(boundary_files, "SAL", state_filter=["Victoria"])
# Extract OSM features using Overpass API (no PBF file needed!)
analysis_result = opencivics.analyze_osm_features_api(
boundaries_gdf=boundaries,
area_code_col='area_code',
feature_config=opencivics.FEATURE_TAGS,
api_type="overpass", # Free OpenStreetMap data
max_workers=3
)
# Create an interactive map for Melbourne
map_config = {
'Schools': {'column': 'school_count', 'caption': 'Number of Schools', 'default': True},
'Retail': {'column': 'retail_count', 'caption': 'Retail Outlets'}
}
melbourne_map = opencivics.create_city_map(
analysis_result,
'Melbourne',
map_config,
output_filename='melbourne_analysis.html'
)
Option 2: Using Google Maps API (Commercial)
import opencivics
# Same boundary setup as above...
# Extract features using Google Maps API (requires API key)
analysis_result = opencivics.analyze_osm_features_api(
boundaries_gdf=boundaries,
area_code_col='area_code',
feature_config=opencivics.FEATURE_TAGS,
api_type="google",
google_api_key="YOUR_GOOGLE_API_KEY",
max_workers=2 # Be conservative with commercial API
)
# Same mapping code as above...
Option 3: Using PBF Files (For large-scale analysis)
import opencivics
# Download and load ABS boundary data
boundary_files = opencivics.download_aus_boundary_files("boundaries/")
boundaries = opencivics.load_abs_boundaries(boundary_files, "SAL", state_filter=["Victoria"])
# Extract OSM features from PBF file
analysis_result = opencivics.analyze_osm_features(
boundaries, "australia.osm.pbf", "area_code", opencivics.FEATURE_TAGS
)
# Same mapping code as above...
Supported Australian Cities
The package includes predefined configurations for:
- Sydney, Melbourne, Brisbane, Perth, Adelaide
- Canberra, Darwin, Hobart
- Gold Coast, Newcastle, Wollongong, Geelong, Townsville, Cairns
Dependencies
- pandas, geopandas, shapely
- requests (for downloading ABS data)
- folium, branca (for interactive maps)
- osmium (for OSM data processing)
- numpy, openpyxl
License
MIT License - see LICENSE file for details.
Contributing
Contributions welcome! Please read our contributing guidelines and submit pull requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opencivics-0.3.1.tar.gz.
File metadata
- Download URL: opencivics-0.3.1.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c00731b0c9e48c5a0b5a9df24330babf71fb3e98ea1df77bd18b847e86dcb05
|
|
| MD5 |
44496ded02e9fc09d66e8f836fe9374f
|
|
| BLAKE2b-256 |
72bdb823a804bc3976d9c6f4abb7d51cec54720e00351986a407b16244cc6b22
|
File details
Details for the file opencivics-0.3.1-py3-none-any.whl.
File metadata
- Download URL: opencivics-0.3.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c53d59d308620bb67211831fe12079ba805383cdeb8ff98686a831c7df14401a
|
|
| MD5 |
33be11154d5da650eedb05a92f597c51
|
|
| BLAKE2b-256 |
df98136879a36989fff4bcaa171da65c6dc8cc03b5afba09f85910e752e35969
|