Skip to main content

improved esri rest io for geopandas

Project description

restgdf

improved esri rest io for geopandas

License: MIT python

Publish to PyPI GitHub tag (with filter) Read the Docs

Code Climate maintainability Code Climate issues Code Climate technical debt coverage

pre-commit Ruff Checked with mypy Code style: black

security: bandit Known Vulnerabilities

gpd.read_file(url, driver="ESRIJSON") does not account for max record count limitations

so if you read a service with 100000 features but there's a limit of 1000 records per query, then your gdf will only have 1000 features

these functions use asyncio to read all features from a service, not limited by max record count

keyword arguments to FeatureLayer.getgdf are passed on to requests.Session.post; include query parameters like where str and token str in data dict

this enables enhanced control over queries and allow use of any valid authentication scheme (eg requests_ntlm.HttpNtlmAuth) with use of requests.Session.auth or data={"token": str}

Usage

pip install restgdf
import asyncio

from aiohttp import ClientSession

from restgdf import FeatureLayer


beaches_url = r"https://maps1.vcgov.org/arcgis/rest/services/Beaches/MapServer/6"

zipcodes_url = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_ZIP_Codes_2016/FeatureServer/0"

async def main():
    async with ClientSession() as session:
        beaches = await FeatureLayer.from_url(beaches_url, session=session)
        beaches_gdf = await beaches.getgdf()

        daytona = await beaches.where("LOWER(City) LIKE 'daytona%'")
        daytona_gdf = await daytona.getgdf()

        oh_zipcodes = await FeatureLayer.from_url(zipcodes_url, where="STATE = 'OH'", session=session)
        oh_zipcodes_gdf = await oh_zipcodes.getgdf()

    return beaches_gdf, daytona_gdf, oh_zipcodes_gdf


beaches_gdf, daytona_gdf, oh_zipcodes_gdf = asyncio.run(main())

print(beaches_gdf.shape)
# (243, 10)

print(daytona_gdf.shape)
# (83, 10)

print(oh_zipcodes_gdf.shape)
# (1026, 8)

Documentation

https://restgdf.readthedocs.io/

Uses

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

restgdf-1.0.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

restgdf-1.0.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file restgdf-1.0.0.tar.gz.

File metadata

  • Download URL: restgdf-1.0.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for restgdf-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5e8f078fb481fe2f0fbe2c9019cdb198c129f63f43f7697f44cdb3875494775d
MD5 9025843d0d71c70905263d716be9045f
BLAKE2b-256 cb525fac588debc7106693267d9d986cb4685b1dd1b82a99e397737b5647c447

See more details on using hashes here.

File details

Details for the file restgdf-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: restgdf-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for restgdf-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed8d97aec659c2431d80838144e6a1c7c2fa5a9260c77f269ee3a9ff4d700f8d
MD5 77e709e124a7e07461ccb5f8fd838740
BLAKE2b-256 453e115d039f90867d3f23ce4313360039e13aafa0158bf459e1e9db822f4bde

See more details on using hashes here.

Supported by

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