Create a FeatureCollection/Table from CSV file?

329
3
Jump to solution
02-07-2024 08:34 AM
NeilBaines
New Contributor II

I am essentially wanting to create a similar function to what ArcGIS Pro and ArcMap can do which is the 'Import XY Data'. I have a CSV file with lat,long and some other fields, and want to be able to turn this into a FeatureLayer/Table/Collection and then build graphics from that. 

I know I could parse the CSV file myself, and build each graphic manually but after looking into the Feature API's it looks like something like Import CSV may be possible? Any help would be appreciated. 

Thanks

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

There is a service endpoint that offers this capability (/generate: Generate—ArcGIS REST APIs | ArcGIS Developers) but client-side you'll need to parse the CSV and create the features or graphics yourself. Note features and graphics are similar, but feature collections are within the operational layers collection of the map (and can be saved in a webmap or as a portal item) whereas graphics existing only in the graphics overlay and cannot be saved/persisted (other than saving to JSON for example). 

 

Note it should be more efficient to use the method that takes a collection of features: Method AddFeaturesAsync (arcgis.com) 

View solution in original post

0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor

There is a service endpoint that offers this capability (/generate: Generate—ArcGIS REST APIs | ArcGIS Developers) but client-side you'll need to parse the CSV and create the features or graphics yourself. Note features and graphics are similar, but feature collections are within the operational layers collection of the map (and can be saved in a webmap or as a portal item) whereas graphics existing only in the graphics overlay and cannot be saved/persisted (other than saving to JSON for example). 

 

Note it should be more efficient to use the method that takes a collection of features: Method AddFeaturesAsync (arcgis.com) 

0 Kudos
NeilBaines
New Contributor II

Thanks Michael 

0 Kudos
dotMorten_esri
Esri Notable Contributor

You can also parse the CSV and insert it into a local geodatabase, so you only have to convert it once. Here's an example of creating an entire map using a programmatically created geodatabase:

https://github.com/Esri/arcgis-maps-sdk-dotnet-demos/blob/main/src/GeometryEditor/MapCreator.cs#L36-...

0 Kudos