0

I have been querying one feature in Esri ArcGIS REST Service, but because it is a large data, I had to query it several times (1000 features query limit). This results in many JSON files as parts of one that is supposed to be a single feature. Convert from JSON to Feature only allows one JSON. so

Condition: I have many Esri JSON files

How do I bulk-convert multiple JSON files and merge it into a single shapefile/geodatabase feature?

Is there a single way to do this using ModelBuilder in ArcGIS Desktop?

I am familiar with Python (GeoPandas) but not familiar with ArcPy.

1

Have you considered using the ArcGIS Python API instead? Instead of getting JSON files, you could query feature layers directly and export them to a GDB all within the same library (this assumes ArcPy is installed in your computer). More on Spatially Enabled Dataframes from the ArcGIS Python API E.g.

import pandas as pd
from arcgis.gis import GIS
from arcgis.features import FeatureLayer

# if the features are not public and require your login
GIS('https://arcgis.com','username','pw')

flayer = FeatureLayer('your url to a feature layer')
sdf = pd.DataFrame.spatial.from_layer(flayer)
sdf.spatial.to_featureclass(location=r"c:\location\to\your.gdb\flayer");
| improve this answer | |
  • Oh! it works for one Feature Layer Service, but it doesn't work on my objective feature service! it returns "Error performing query operation (Error Code: 400)", why is that? – sutan May 28 at 13:17
  • I am not sure what an object feature service is. You can access always access the layer's item by doing item = gis.content.get('item_number') and then using item.layers to see the layer you want (gis variable will be what is returned from GIS()) – K. Freestone May 28 at 16:18
  • sorry, bad choice of words. I have 2 features service link (point features, and polygon). your suggestion works on point features but what I need is the (polygon) feature service. When I tried it on the (polygon) feature service link it returns "Error performing query operation" – sutan May 30 at 13:52
0

If you're using a recent version of ArcGISPro (i think 2.4 or newer) you can just put the endpoint into many gp tools.

For example the gp copyFeatures tool will copy all features/records from the input to a local fc. Here's what code looks like but you'll want to update the fs variable's path to have correct guid & fc-name.

Below is python code

    import arcpy    
    fs = r"https://services1.arcgis.com/{guid}/arcgis/rest/services/{fc-name}/FeatureServer/0"
    arcpy.management.CopyFeatures(fs, r"c:\myproject\x.gdb\fc-name")
| improve this answer | |
  • Question, why does the "r" has to be in the code? I do have and tried your code. It returns an error: (ERROR: code:500, Error performing query operation, Internal server error.) I've tried several layers and one returns (ERROR 000732: Input Features: Dataset {url} does not exist or is not supported Failed to execute (CopyFeatures). – sutan May 30 at 13:47
  • hi sutan, python string literals treat "\" as an escape sequence, so "\t" is a tab, and "\n" is a carriage return, etc... When setting windows paths, you end up with a lot of "\", like if you do x = "c:\temp", the value of x will be c: emp. So to avoid "\" being treated as an escape sequence, you can do x = r"c:\temp" which tells python to treat the literal as raw string. For more see docs.python.org/3/reference/… – gotchula Jun 1 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.