# ezesri
A lightweight Python package for extracting data from Esri REST API endpoints.
[](https://badge.fury.io/py/ezesri)
[](https://opensource.org/licenses/MIT)
## Features
- **Multiple export formats**: Export to GeoJSON, Shapefile, CSV, File Geodatabase, and GeoDataFrame.
- **Robust extraction**: Automatically handles Esri's pagination.
- **Filtering**: Filter data by bounding box or attribute query.
- **Bulk exports**: Download all layers from a MapServer or FeatureServer.
- **Simple CLI**: An easy-to-use command-line interface for all features.
- **Human-readable metadata**: Get a clean summary of layer metadata.
## Installation
```bash
pip install ezesri
```
## Usage
### Python library
You can use `ezesri` as a library to integrate with your Python scripts.
```python
import ezesri
# URL for a public Esri feature layer, e.g. City of Los Angeles boundaries:
# https://services5.arcgis.com/VAb1qw880ksyBtIL/ArcGIS/rest/services/City_Boundary_of_Los_Angeles_(new)/FeatureServer/0
url = "your_esri_layer_url_here"
# Get layer metadata
metadata = ezesri.get_metadata(url)
print(ezesri.summarize_metadata(metadata))
# Extract layer to a GeoDataFrame
gdf = ezesri.extract_layer(url)
print(gdf.head())
```
### Command-line interface
`ezesri` also provides a command-line tool for quick data extraction.
#### Fetch metadata
Get a clean, human-readable summary of a layer's metadata.
```bash
ezesri metadata <YOUR_ESRI_LAYER_URL>
```
To get the raw JSON output, use the `--json` flag:
```bash
ezesri metadata <YOUR_ESRI_LAYER_URL> --json
```
#### Fetch layer data
You can fetch a layer and save it to a file in various formats.
- **GeoJSON**
```bash
ezesri fetch <YOUR_ESRI_LAYER_URL> --format geojson --out output.geojson
```
- **Shapefile**
```bash
ezesri fetch <YOUR_ESRI_LAYER_URL> --format shapefile --out output.shp
```
- **CSV** (geometry is dropped)
```bash
ezesri fetch <YOUR_ESRI_LAYER_URL> --format csv --out output.csv
```
- **File Geodatabase**
```bash
ezesri fetch <YOUR_ESRI_LAYER_URL> --format gdb --out output.gdb
```
You can also filter by a bounding box (in WGS84 coordinates):
```bash
ezesri fetch <URL> --bbox <xmin,ymin,xmax,ymax> --format geojson --out <FILE>
```
Or, use a more advanced spatial filter with a GeoJSON object:
```bash
ezesri fetch <URL> --geometry '{"type": "Polygon", ...}' --format geojson --out <FILE>
```
#### Bulk-fetch all layers from a service
You can discover and export all layers from a MapServer or FeatureServer to a specified directory.
```bash
ezesri bulk-fetch <YOUR_ESRI_SERVICE_URL> <YOUR_OUTPUT_DIRECTORY> --format gdb
```
## CLI command aliases
To make the CLI easier to use, the following aliases are available for common options:
- `--out`: `--output`
- `--format`: `--fmt`
- `--spatial-rel`: `--srs`
## Examples
For a detailed, real-world example of using `ezesri` to acquire, process, and visualize data, see the scripts in the `examples/` directory:
- `examples/palm_springs_fetch.py`: Demonstrates how to use `ezesri` to download data from multiple Esri feature layers, merge them based on a common attribute, and save the result as a GeoJSON file.
- `examples/palm_springs_pools_map.py`: Shows how to load the prepared data, perform analysis to identify residential properties, and create a final map visualizing the results with `matplotlib`.
To run these examples, you will first need to install the required dependencies:
```bash
pip install geopandas matplotlib
```
Then, you can run the scripts directly:
```bash
python examples/palm_springs_fetch.py
python examples/palm_springs_pools_map.py
```
## Testing
This project uses `pytest` for unit testing. For details on how to run the test suite, please see the [testing guide](TESTING.md).
## Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss your ideas.
Raw data
{
"_id": null,
"home_page": "https://github.com/stiles/ezesri",
"name": "ezesri",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "esri, gis, geospatial, arcgis, rest-api",
"author": "Justin Myles",
"author_email": "justin@myles.com",
"download_url": "https://files.pythonhosted.org/packages/6e/17/21640873b55ed33cad9c856394c1caaf11259968328ddf98c1d7e350871d/ezesri-0.3.0.tar.gz",
"platform": null,
"description": "# ezesri\n\nA lightweight Python package for extracting data from Esri REST API endpoints.\n\n[](https://badge.fury.io/py/ezesri)\n[](https://opensource.org/licenses/MIT)\n\n## Features\n\n- **Multiple export formats**: Export to GeoJSON, Shapefile, CSV, File Geodatabase, and GeoDataFrame.\n- **Robust extraction**: Automatically handles Esri's pagination.\n- **Filtering**: Filter data by bounding box or attribute query.\n- **Bulk exports**: Download all layers from a MapServer or FeatureServer.\n- **Simple CLI**: An easy-to-use command-line interface for all features.\n- **Human-readable metadata**: Get a clean summary of layer metadata.\n\n## Installation\n\n```bash\npip install ezesri\n```\n\n## Usage\n\n### Python library\n\nYou can use `ezesri` as a library to integrate with your Python scripts.\n\n```python\nimport ezesri\n\n# URL for a public Esri feature layer, e.g. City of Los Angeles boundaries: \n# https://services5.arcgis.com/VAb1qw880ksyBtIL/ArcGIS/rest/services/City_Boundary_of_Los_Angeles_(new)/FeatureServer/0\nurl = \"your_esri_layer_url_here\"\n\n# Get layer metadata\nmetadata = ezesri.get_metadata(url)\nprint(ezesri.summarize_metadata(metadata))\n\n# Extract layer to a GeoDataFrame\ngdf = ezesri.extract_layer(url)\nprint(gdf.head())\n```\n\n### Command-line interface\n\n`ezesri` also provides a command-line tool for quick data extraction.\n\n#### Fetch metadata\n\nGet a clean, human-readable summary of a layer's metadata.\n\n```bash\nezesri metadata <YOUR_ESRI_LAYER_URL>\n```\n\nTo get the raw JSON output, use the `--json` flag:\n```bash\nezesri metadata <YOUR_ESRI_LAYER_URL> --json\n```\n\n#### Fetch layer data\n\nYou can fetch a layer and save it to a file in various formats.\n\n- **GeoJSON**\n ```bash\n ezesri fetch <YOUR_ESRI_LAYER_URL> --format geojson --out output.geojson\n ```\n\n- **Shapefile**\n ```bash\n ezesri fetch <YOUR_ESRI_LAYER_URL> --format shapefile --out output.shp\n ```\n\n- **CSV** (geometry is dropped)\n ```bash\n ezesri fetch <YOUR_ESRI_LAYER_URL> --format csv --out output.csv\n ```\n\n- **File Geodatabase**\n ```bash\n ezesri fetch <YOUR_ESRI_LAYER_URL> --format gdb --out output.gdb\n ```\n\nYou can also filter by a bounding box (in WGS84 coordinates):\n```bash\nezesri fetch <URL> --bbox <xmin,ymin,xmax,ymax> --format geojson --out <FILE>\n```\n\nOr, use a more advanced spatial filter with a GeoJSON object:\n```bash\nezesri fetch <URL> --geometry '{\"type\": \"Polygon\", ...}' --format geojson --out <FILE>\n```\n\n#### Bulk-fetch all layers from a service\n\nYou can discover and export all layers from a MapServer or FeatureServer to a specified directory.\n\n```bash\nezesri bulk-fetch <YOUR_ESRI_SERVICE_URL> <YOUR_OUTPUT_DIRECTORY> --format gdb\n```\n\n## CLI command aliases\n\nTo make the CLI easier to use, the following aliases are available for common options:\n\n- `--out`: `--output`\n- `--format`: `--fmt`\n- `--spatial-rel`: `--srs`\n\n## Examples\n\nFor a detailed, real-world example of using `ezesri` to acquire, process, and visualize data, see the scripts in the `examples/` directory:\n\n- `examples/palm_springs_fetch.py`: Demonstrates how to use `ezesri` to download data from multiple Esri feature layers, merge them based on a common attribute, and save the result as a GeoJSON file.\n- `examples/palm_springs_pools_map.py`: Shows how to load the prepared data, perform analysis to identify residential properties, and create a final map visualizing the results with `matplotlib`.\n\nTo run these examples, you will first need to install the required dependencies:\n```bash\npip install geopandas matplotlib\n```\nThen, you can run the scripts directly:\n```bash\npython examples/palm_springs_fetch.py\npython examples/palm_springs_pools_map.py\n```\n\n## Testing\n\nThis project uses `pytest` for unit testing. For details on how to run the test suite, please see the [testing guide](TESTING.md).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue to discuss your ideas.\n",
"bugtrack_url": null,
"license": null,
"summary": "A lightweight Python package for extracting data from Esri REST API endpoints.",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/stiles/ezesri"
},
"split_keywords": [
"esri",
" gis",
" geospatial",
" arcgis",
" rest-api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "755a1caa98b578296c3239d5dbcf817b5a493d22a4c978e64abc54d2e373e272",
"md5": "e298d2052e58189cca33ee49f2287ca5",
"sha256": "880088e2d21306cd81ec6096eb70af5b9a2a1beb7829f90bdfa6c22115bf9340"
},
"downloads": -1,
"filename": "ezesri-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e298d2052e58189cca33ee49f2287ca5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 10280,
"upload_time": "2025-07-12T14:29:16",
"upload_time_iso_8601": "2025-07-12T14:29:16.358146Z",
"url": "https://files.pythonhosted.org/packages/75/5a/1caa98b578296c3239d5dbcf817b5a493d22a4c978e64abc54d2e373e272/ezesri-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6e1721640873b55ed33cad9c856394c1caaf11259968328ddf98c1d7e350871d",
"md5": "1d7b78bc088e924704019d3ca59d4ce8",
"sha256": "c6860f1269d1cfff1600fbe57dee76064d77095fd522ec7694d6de1c3c1b6f8f"
},
"downloads": -1,
"filename": "ezesri-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "1d7b78bc088e924704019d3ca59d4ce8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 12230,
"upload_time": "2025-07-12T14:29:17",
"upload_time_iso_8601": "2025-07-12T14:29:17.495593Z",
"url": "https://files.pythonhosted.org/packages/6e/17/21640873b55ed33cad9c856394c1caaf11259968328ddf98c1d7e350871d/ezesri-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-12 14:29:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stiles",
"github_project": "ezesri",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ezesri"
}