Updating Feature Layer through CSV?

2714
8
Jump to solution
06-12-2017 12:30 PM
EricHung
New Contributor II

Hi there,

I'm completely new to ArcGIS online. I've currently set up some webmaps/storymaps from a webmap that has a hosted feature layer. This layer was created from a .csv file I made listing all the things such as address, city, name, etc. I used the geocoding based off of the address when creating the feature layer, selecting the city, address, and postal fields. 

What I want to be able to do is update the hosted feature layer with an updated csv file, which will then reflect in all web maps and applications using that layer. Unfortunately, there is not overwrite option since I am not using latitude and longitude, but address. I can make changes to the existing data in the feature layer from the data tab but I cannot add more rows, etc. I want to be able to just upload an updated csv file and overwrite the existing data. Any solutions other than changing it from address to long/lat (since it is much easier for my organization to use address/postal/city)?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
EricHung
New Contributor II

In the end, the solution I figured out was to simply delete the hosted feature layer and publish a new one from the csv with the same name. All my maps take from the new layer just fine. Unless there's a way for the feature layer to update without having to delete it and make a new one, I can live with this method!

View solution in original post

0 Kudos
8 Replies
EricHung
New Contributor II

Is there no solution?

0 Kudos
KellyGerrow
Esri Frequent Contributor

Hi Eric,

Are you adding additional fields or updating existing records? It seems like you are looking to append data to an existing data source.

-Kelly

0 Kudos
CarmelConnolly
Regular Contributor

Hi Eric, 

Are you looking to add multiple new features at once or just one at a time? Have you tried editing the hosted layer when in the web map rather than through the Data tab? Click the map to add a new point (new row is added to the table) and fill in the new point details through the pop up? Edit features—ArcGIS Online Help | ArcGIS  

Do you have access to ArcGIS Pro, our desktop product?

Carmel

0 Kudos
EricHung
New Contributor II

In the end, the solution I figured out was to simply delete the hosted feature layer and publish a new one from the csv with the same name. All my maps take from the new layer just fine. Unless there's a way for the feature layer to update without having to delete it and make a new one, I can live with this method!

0 Kudos
StevenBowley1
New Contributor II

I have the exact same issue. We receive updated CSVs weekly and it would be ideal to just overwrite the CSV and that automatically update the hosted feature layer.  At the moment I have to do the same as Eric, delete the feature layer and create a new one from the updated CSV. This means all the visualization settings and pop-up configurations from the feature layer are lost and have to be redone. It should be possible to just over-write the CSV as the source layer and the feature layer would just update automatically to reflect the updated source data.

0 Kudos
KellyGerrow
Esri Frequent Contributor

HI Steven,

Check out the append function. I think this will accomplish what you are looking to do, without  needing to overwrite the entire service.

Check out this blog for more details.

https://www.esri.com/arcgis-blog/products/arcgis-online/data-management/whats-new-with-hosted-featur...

-Kelly

0 Kudos
KevinWarner1
New Contributor II

I have the same issue as Steve and Eric.  I've created a hosted feature layer from a CSV based on geocoded address fields (address, city, state, zip).  I now have a new CSV with a few thousand new records that I want to use to update the hosted feature layer, either by updating the CSV I originally uploaded or updating the resultant feature layer created from that CSV.

As far as I can tell, "Append" is not an option because:
1) There is no "Append" option for the hosted CSV file.  I only get an "Update" option which replaces the CSV with the new data but does not geocode any of the new records like it did when I initially uploaded the CSV to AGOL. The initial CSV upload allows me to choose "Publish this file as a hosted feature layer" and select the address fields to use for geocoding.


2) If I choose to append new CSV data directly to the resultant hosted feature layer (Update -> Append Data to Layer) it doesn't go through any geocoding process.  The records are added to the attribute table but no features are created.  Now I have 7000 table records but only 4000 points.

Perhaps I'm doing something wrong so any suggestions would be appreciated.

-Kevin 

Nahomdinka
New Contributor II

@KellyGerrow : I have a similar question but mine is to update an existing feature layer in AGOL using an open-source python library. Only one field (let us say field1) needs to be updated in the feature layer based on source data in csv. The feature layer and the .csv file have a common field to join them. Field_ID in the feature layer and CSV_ID in CSV file can be mapped. I do not think it matters but Field_ID is not unique. I am looking for a python code to automate the process of updating features in the feature layers using data from csv. I can not overwrite the feature layer because there are records or fields in the feature layer that are not in the csv. 

Below is the code I tried...

import pandas as pd

import os

from arcgis.gis import GIS

from arcgis import features

from arcgis.features import SpatialDataFrame

from arcgis.mapping import WebMap

import arcpy

from arcgis.features import FeatureLayerCollection

csvFile = pd.read_csv("csvfile.csv")

portal ="htttps://xyz.maps.arcgis.com/"

username  = "abc"

pw = "pword"

gis = GIS(portal, username, pw)

Feature_layerID  = gis.content.get("123456789")

#replace the records in the "field1" of the feature layer based on the data in csv file, using the two common IDs in the feature layer and the csv file. 

 

0 Kudos