Import data as a feature layer

Learn how to create hosted feature layers and feature services for your data.

You can use the developer dashboard, ArcGIS Online or scripting APIs to import and store data in the cloud as hosted layers. If your data contains geometries with attributes, such as a CSV or GeoJSON file, it is imported as a hosted feature layer. A hosted feature layer is also referred to as a feature layer. A feature layer is used to store point, line, or polygon geometries with attributes. After a feature layer is created, applications can access it by ID or URL and then query, edit, and display features.

In this tutorial, you use data management tools and scripting APIs to import Trailheads (CSV), Trails (GeoJSON), and Parks and Open Space (Shapefile) files and publish them as feature layers. These layers are used in other tutorials.

Prerequisites

You need an ArcGIS Developer or ArcGIS Online account to access and manage hosted layers.

Steps

Download the data

  1. Download the LA_Hub_Datsets zip file from ArcGIS Online. The zip file contains the following:

    • Trailheads.csv
    • Trails.geojson
    • Parks_and_Open_Space.zip (Shapefile)
  2. Navigate to and unzip the file.

  3. Sign in to your ArcGIS account

Import the Trailheads CSV file

The Trailheads CSV file contains point data with attributes. Importing the file will create a new point feature layer in a feature service. The import tool attempts to match field names and data types in the CSV file. The four supported field types are: String, Integer, Double, and Date.

Steps to use the developer dashboardSteps to use ArcGIS OnlineSteps to use scripting APIs
  1. Go to your developer dashboard.

  2. Click Layers to go to the Layers tab.

  3. Click Import data. To upload the Trailheads.csv, either:

    • Drag and drop the file into the Drop a file here area.
    • Or, click Select file and navigate to the file path.
    • Click Upload file.
  4. In the Define geometry and Column data types panes, leave all settings at their defaults. Click Next to go to the Item Details pane.

  5. Set the following details in the Item Details pane:

    • Title: Trailheads
    • Tags: Los Angeles Trailheads.
    • Description: Trailheads in the Santa Monica Mountains.
  6. At the bottom, click Create layer to create the new Trailheads feature layer and feature service.

  7. In the item page, click the Settings tab.

  8. Under Layer access (Sharing), ensure that People with access is set to Public (authentication not required).

Find the Trailheads ID and URL

To access a hosted feature layer from an application, you need to be able to identify its ID and URL. If a hosted feature layer is public, you use the URL to access it directly with your web browser or any application. If the layer is private, you need to provide an access token. For example:

Public: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0

Private: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0?token=ACCESS_TOKEN

  1. In the item page of the layer, find the Item ID and Point Layer URL. They should look something like this:
  1. Go to ArcGIS Online and sign in.

  2. In the top navigation bar, click Content.

  3. Click New item. To upload the Trailheads.csv file, you can either:

    • Drag and drop the file.
    • Or, click Your device and navigate to the file path.
  4. Select Add Trailheads.csv and create a hosted feature layer to publish the file as a hosted feature layer.

  5. In Fields, leave all fields at their default settings and click Next.

  6. In Location settings, leave the default settings and click Next.

  7. Set the following information in the item details pane:

    • Title: Trailheads
    • Tags: Los Angeles Trailheads.
    • Summary: Trailheads in the Santa Monica Mountains.
  8. Click Next to create the new Trailheads feature layer and feature service.

  9. In the item page, click Share > Everyone (public) > Save.

Find the Trailheads ID and URL

To access a hosted feature layer from an application, you need to be able to identify its ID and URL. If a hosted feature layer is public, you use the URL to access it directly with your web browser or any application. If the layer is private, you need to provide an access token. For example:

Public: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0

Private: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0?token=ACCESS_TOKEN

  1. In the item page, scroll down to the bottom of the page to find the Service URL. For example:

    • Service URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/
  2. Click View to access the feature service. Locate the Service ItemId, which will look something like this:

  1. Import libraries.
  2. Provide authentication.
  3. Create portal item.
  4. Execute the publish operation.
  5. Handle results.
ArcGIS REST JSArcGIS REST JSArcGIS API for Python
Expand
Use dark colors for code blocksCopy
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  // create item
  const csvItem = await createItem({
    authentication: auth,
    item: {
      title: 'Trailheads CSV',
      description: 'Trailheads imported from CSV file in Mahou Riviera',
      tags: 'LA Trailheads',
      type: 'CSV',
    },
    file: f,
  });

  // execute publish operation
  const publishedService = await request(publishURL, {
    authentication: auth,
    params: {
      itemid: csvItem.id,
      filetype: 'csv',
      publishParameters: publishParams,
    },
  });

  // handle results
  console.log('New service created: ');
  publishedService.services.forEach((s) => {
    console.log(`\n\tid: ${s.serviceItemId} \n\turl:${s.serviceurl}`);
  });

Import the Trails GeoJSON file

The Trails GeoJSON file contains line (polyline) data with attributes. Importing the file will create a new line feature layer in a feature service.

Steps to use the developer dashboardSteps to use ArcGIS OnlineSteps to use scripting APIs
  1. In the developer dashboard, click Layers > Import data to upload your next file.

  2. Upload the Trails.geojson file. Either:

    • Drag and drop the file into the Drop a file here area.
    • Or, click Select file to browse to the file path.
    • Click Upload file.
  3. In the Item Details pane, set the following values:

    • Title: Trails
    • Tags: Los Angeles Trails.
    • Description: Trails in the Santa Monica Mountains.
  4. At the bottom, click Create layer to create the new Trails feature layer and feature service.

  5. In the item page, click the Settings tab.

  6. Under Layer access (Sharing), set People with access to Public (authentication not required).

Find the Trails ID and URL

To access a hosted feature layer from an application, you need to be able to identify ID and URL.

  1. In the Overview, find the Layer ID and Line Layer URL. It should look something like this:

In ArcGIS Online click Content > New item to upload your next file.

  1. Upload the Trails.geojson file. Either:

    • Drag and drop the file into the Drag and drop your file area.
    • Or, click Your device and navigate to the file path.
  2. Select Add Trails.geojson and create a hosted feature layer to publish the file as a hosted feature layer.

  3. Set the following information in the item details pane:

    • Title: Trails
    • Tags: Los Angeles Trails.
    • Summary: Trails in the Santa Monica Mountains.
  4. Click Next to create the new Trails feature layer and feature service.

  5. In the item page, click Share > Everyone (public) > Save.

Find the Trails ID and URL

To access a hosted feature layer from an application, you need to be able to identify ID and URL.

  1. In the item page, scroll down to the bottom of the page to find the Service URL. For example:

    • Service URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer
  2. Click View to access the feature service. Locate the Service ItemId, which will look something like this:

  1. Import libraries.
  2. Provide authentication.
  3. Create portal item.
  4. Execute the publish operation.
  5. Handle results.
ArcGIS REST JSArcGIS REST JSArcGIS API for Python
Expand
Use dark colors for code blocksCopy
                                                                              
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  // create item
  const csvItem = await createItem({
    authentication: auth,
    item: {
      title: 'Trails GeoJSON',
      description: 'Trails imported from a GeoJSON file in Mahou Riviera',
      tags: 'LA Trails',
      type: 'GeoJson',
    },
    file: f,
  });

  // execute publish operation
  const publishedService = await request(publishURL, {
    authentication: auth,
    params: {
      itemid: csvItem.id,
      filetype: 'geojson',
      publishParameters: publishParams,
    },
  });

  // handle results
  console.log('New service created: ');
  publishedService.services.forEach((s) => {
    console.log(`\tid: ${s.serviceItemId} \n\turl:${s.serviceurl}`);
  });

Import the Parks and Open Spaces Shapefile

The Parks and Open Spaces Shapefile contains polygon data with attributes. Importing the file will create a new polygon feature layer in a feature service.

Steps to use the developer dashboardSteps to use ArcGIS OnlineSteps to use scripting APIs
  1. In the developer dashboard, click Layers > Import data to upload your next file.

  2. Upload the Parks and Open Space.zip file. Either:

    • Drag and drop the file into the Drop a file here area.
    • Or, click Select file to browse to the file path.
    • Select Shapefile.
    • Click Upload file.
  3. Set the following details in the Item Details pane:

    • Title: Parks and Open Space
    • Tags: Los Angeles Parks.
    • Description: Parks and open spaces in the Santa Monica Mountains.
  4. At the bottom, click Create layer to create the new Parks and Open Space feature layer and feature service.

  5. In the item page, click the Settings tab.

  6. Under Layer access (Sharing), set People with access to Public (authentication not required).

Find the Parks and Open Spaces ID and URL

To access a hosted feature layer from an application, you need to be able to identify its ID and URL.

  1. In the Overview, find the Layer ID and Polygon Layer URL. It should look something like this:
    • Layer ID: f2ea5d874dad427294641d2d45097c0e
    • Polygon Layer URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer
  1. In ArcGIS Online click Content > New item to upload your next file.

  2. Upload the Parks and Open Space.zip file. Either:

    • Drag and drop the file into the Drag and drop your file area.
    • Or, click Your device to browse to the file path.
  3. Set the file type to Shapefile. Select Add Parks_and_Open_Space.zip and create a hosted feature layer to publish the file as a hosted feature layer.

  4. Set the following information in the item details pane:

    • Title: Parks and Open Space
    • Tags: Los Angeles Parks.
    • Summary: Parks and open spaces in the Santa Monica Mountains.
  5. Click Next to create the new Parks and Open Space feature layer and feature service.

  6. In the item page, click Share > Everyone (public) > Save.

Find the Parks and Open Spaces ID and URL

To access a hosted feature layer from an application, you need to be able to identify ID and URL.

  1. In the item page, scroll down to the bottom of the page to find the Service URL. For example:

    • Service URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space/FeatureServer
  2. Click View to access the feature service. Locate the Service ItemId, which will look something like this:

  1. Import libraries.
  2. Provide authentication.
  3. Create portal item.
  4. Execute the publish operation.
  5. Handle results.
ArcGIS REST JSArcGIS REST JSArcGIS API for Python
Expand
Use dark colors for code blocksCopy
                                                                              
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  // publish parameters
  // https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm#ESRI_SECTION1_1016F32E313240D38E8CF741BDBC0BE8
  const publishParams = {
    name: 'Parks and Open Space',
    maxRecordCount: 2000,
    hasStaticData: true,
    layerInfo: { capabilities: 'Query' },
  };

  // create item
  const zipItem = await createItem({
    authentication: auth,
    item: {
      title: 'Parks and Open Space',
      description: 'Parks and open spaces in Mahou Riviera.',
      tags: 'LA Parks',
      type: 'Shapefile',
    },
    file: f,
  });

  // execute publish operation
  const publishedService = await request(publishURL, {
    authentication: auth,
    params: {
      itemid: zipItem.id,
      filetype: 'shapefile',
      publishParameters: publishParams,
    },
  });

  // handle results
  console.log('New service created: ');
  publishedService.services.forEach((s) => {
    console.log(`\tid: ${s.serviceItemId} \n\turl:${s.serviceurl}`);
  });

Now you have three hosted feature layers in ArcGIS Online. You can access each hosted layer with their URL or layer ID in your applications. To manage your hosted layer properties and capabilities, visit the Manage a feature layer tutorial.

What's next?

Learn how to use additional tools, APIs, and location services in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.