Noah Holmes Foster
Noah Holmes Foster

Reputation: 1

Trying to export shapefile from feature server using restapi module for python

I'm trying to download a shapefile from an ArcGIS feature server to manipulate using geopandas. I came across the restapi python module, which seems fairly user friendly, but I'm having difficulty exporting a layer.

Here is the code that I tried. I've made some tweaks, but still no luck.

import restapi

connect to USDOT REST server

tracts_url = 'https://services.arcgis.com/xOi1kZaI0eWDREZv/ArcGIS/rest/services/Transportation_Cost_Burden_Census_Tracts/FeatureServer/0'
tracts = restapi.FeatureLayer(tracts_url)

export shapefile

tracts.export_layer('C:/Users/03760/Documents/PythonStuff/cost_burdened_tracts.shp')

Here is my error message:

AttributeError Traceback (most recent call last) c:\Users\03760\Documents\PythonStuff.venv\lib\site-packages\restapi\rest_utils.py in getattr(self, name) 858 # it is a class attribute --> 859 return object.getattribute(self, name) 860 except AttributeError:

AttributeError: 'FeatureCollection' object has no attribute 'fields'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_5700\447033721.py in <module> 7 8 # export shapefile ----> 9 tracts.export_layer('C:/Users/03760/Documents/PythonStuff/cost_burdened_tracts.shp') 10 11 # access the cost burdened census tract layer

c:\Users\03760\Documents\PythonStuff.venv\lib\site-packages\restapi\common_types.py in export_layer(self, out_fc, fields, where, records, exceed_limit, sr, include_domains, include_attachments, qualified_fieldnames, chunk_size, **kwargs) 2154 # get any domain info 2155 f_dict = {f.name: f for f in self.fields} -> 2156 for field in fs.fields: 2157 if field: 2158 field.domain = f_dict[field.name].get(DOMAIN) ... --> 865 raise AttributeError(name) 866 867 def str(self):

AttributeError: fields

Upvotes: 0

Views: 8

Answers (0)

Related Questions