How to create a feature layer from geojson in memory?

340
1
03-04-2024 09:12 AM
EricEagle
Occasional Contributor III

I'm a newbie to the Portal API for Python, and I am just trying to figure out how to go from geojson loaded into memory (say, a WFS response object) to a feature layer on an ArcGIS Enterprise portal.  I'm happy to read documentation and follow examples, but everything I've seen involves messing around with CSVs and pandas (which then requires cleaning up field headings etc).

Additionally all the questions seem to presuppose you have a geojson file sitting around, but what about when you want to avoid the IO overhead?  Seems silly to write the content out to a file, only to read it right back in again.

Is there a more-or-less direct path to go from the data in the buffer, in json format, right to a new feature layer?

Tags (4)
1 Reply
Clubdebambos
Occasional Contributor III

I have not performed this workflow myself but this would be my approach.

  • Create an empty feature service if needed with create_service(), or use an existing. 
  • Read the GeoJSON and parse to get the required info - geomtype, field names, attributes and geometry.
  • Create a Feature Layer in the Feature Service based on the geomtype and define schema, or use an existing Feature Layer. Achievable by using JSON to create the layer, ill need to dig out some code for you later.
  • Edit the Feature Layer to add in the records. append()edit_features()
~ learn.finaldraftmapping.com
0 Kudos