Getting Started with casaGeoTools
Introduction
The casaGeoTools library is designed to seamlessly integrate powerful location services into your Python data science workflow. This guide will walk you through the installation, secure authentication, and your first isochrone request.
1. Installation
Install the library directly via PyPI. Use your terminal or command prompt:
pip install casaGeoTools
For your first script, you should import the following packages:
1.1 Explanations
- pd.set_option(): These settings ensure that all columns in the results are displayed in your output.
2. Access and API Key
- A valid access key is required to use the services. You can request your credentials here: https://www.casageo.de/en/here-connector-for-python.html
- New users can request a one-time trial access to test the functionality immediately.
3. Secure Setup (.env)
In professional projects, API keys should never be hardcoded. We recommend using a .env file.
- Create a file named .env in your project folder.
- Add your key: CASAGEOTOOLS_API_KEY= your_key_here
- Use python_dotenv to load the key.
3.1 Explanations
- cga.preferred_language: Sets the language for the returned results.
- cga.account_info().json(): Provides user information such as expiration dates, package details, and a credit overview.
4. Your First Request
Calculating isochrones with casaGeoTools is efficient and delivers data directly in the GeoDataFrame format.
4.1 Explanations
- cgs.transport_mode: Currently "car", "pedestrian", and "bicycle" are available..
- cgs.routing_mode: Choose between "fast" (quickest route) and "short" (shortest distance).
- cgs.isolines(...,[3,9,15],range_type="time"): [3,9,15] generates 3, 9, and 15-minute isochrones around the location. For a single 5-minute isochrone, use [5]. Time parameters are always in minutes, distance parameters in meters. For example, [3000, 9000, 15000] calculates areas for 3, 9, and 15 kilometers (change range_type from "time" to "distance").
- cgs.isolines().dataframe(departure_info=False): Hides the departure time in the result table. By default, traffic is not considered, making this info irrelevant in this case.
5. Downloads
To jumpstart your development, you can download this example as a Jupyter Notebook or a standalone Python script below