Introduction¶
Many spatial data sets are stored in ArcGIS online and are available through the REST API. This set of scripts uses the frictionless framework to document and download data. It reads available metadata and iteratively downloads the data in GeoJSON format and returns a GDF, and optionally archives the file.
import morpc
Creating a resource file¶
test_url = 'https://services1.arcgis.com/EjjnBtwS9ivTGI8x/arcgis/rest/services/MORPC_MPO_Boundary_2020/FeatureServer/0'
resource = morpc.rest_api.resource_from_services_url(test_url)
resource
{'name': 'morpc-mpo-boundary-2020',
'type': 'json',
'path': 'https://services1.arcgis.com/EjjnBtwS9ivTGI8x/arcgis/rest/services/MORPC_MPO_Boundary_2020/FeatureServer/0',
'scheme': 'https',
'format': 'json',
'mediatype': 'application/geo+json',
'schema': {'fields': [{'name': 'OBJECTID',
'type': 'string',
'title': 'OBJECTID'},
{'name': 'SQMILES',
'type': 'number',
'title': 'SQMILES'},
{'name': 'NAME', 'type': 'string', 'title': 'NAME'},
{'name': 'Updated',
'type': 'string',
'title': 'Updated'},
{'name': 'Source', 'type': 'string', 'title': 'Source'},
{'name': 'Shape__Area',
'type': 'number',
'title': 'Shape__Area'},
{'name': 'Shape__Length',
'type': 'number',
'title': 'Shape__Length'}]},
'_metadata': {'type': 'arcgis_service',
'total_records': 1,
'max_record_count': 2000,
'wkid': 102723}}
resource.to_json('../docs/temp_data/rest_resource.json')
'{\n "name": "morpc-mpo-boundary-2020",\n "type": "json",\n "path": "https://services1.arcgis.com/EjjnBtwS9ivTGI8x/arcgis/rest/services/MORPC_MPO_Boundary_2020/FeatureServer/0",\n "scheme": "https",\n "format": "json",\n "mediatype": "application/geo+json",\n "schema": {\n "fields": [\n {\n "name": "OBJECTID",\n "type": "string",\n "title": "OBJECTID"\n },\n {\n "name": "SQMILES",\n "type": "number",\n "title": "SQMILES"\n },\n {\n "name": "NAME",\n "type": "string",\n "title": "NAME"\n },\n {\n "name": "Updated",\n "type": "string",\n "title": "Updated"\n },\n {\n "name": "Source",\n "type": "string",\n "title": "Source"\n },\n {\n "name": "Shape__Area",\n "type": "number",\n "title": "Shape__Area"\n },\n {\n "name": "Shape__Length",\n "type": "number",\n "title": "Shape__Length"\n }\n ]\n },\n "_metadata": {\n "type": "arcgis_service",\n "total_records": 1,\n "max_record_count": 2000,\n "wkid": 102723\n }\n}'
gdf = morpc.rest_api.gdf_from_rest_resource('../docs/temp_data/rest_resource.json')
0/1 |....................................................................................................| 0.0%
gdf.to_crs('epsg:3735').explore()
Loading...