ArcGIS Blog

Developers

ArcGIS Online

Introducing the Spatial analysis services guide for developers

By Mark Torrey and Allan Laframboise

Spatial analysis services developer guide

Earlier this year we released the
Spatial analysis services guide for developers. This article provides an inside look at the guide, who it is for, the different types of spatial analysis applications you can build, and some tips to help you use the guide.

What is spatial analysis?

Spatial analysis is the process of discovering patterns, finding trends, and gaining insights into your geospatial data.

As a developer, you can perform spatial analyses interactively with tools such as Map Viewer or ArcGIS Pro to prototype applications you want to build, or you can just build the applications with client-side APIs and services such the ArcGIS Maps SDKs, scripting languages, spatial analysis service, and raster analysis service.

You can build spatial analysis applications to answer geospatial problems such as:

  • Which parcels are within the 100-year floodplain?
  • Where are the high and low clusters of traffic crash incidents?
  • Find underserved areas by evaluating distances to healthcare facilities.
  • Identify critical conservation areas by analyzing vegetation cover, water sources, and human encroachment.
  • Based on population density and drive times, where is the best place to build a new store location?
  • Are all hydrants within a certain distance of the street?
  • How many trailheads are within a half mile of my campsite?

This developer guide focuses on Geometry analysisFeature analysis, Raster analysisand 3D visual analysis.

Who is the guide for?

The spatial analysis services guide is for both new and experienced developers who have ArcGIS Location Platform or ArcGIS Online, although many of the patterns apply to developers using ArcGIS Enterprise with their own spatial analysis services.

If you are new to developing with ArcGIS, the Get started page contains all the information you need to get an account, select a type of authentication, and find resources to perform different types of analysis.

Spatial analysis services guide getting started page

Tip: The fastest way to find content and code in the guide is to use “Search topics”. 

What is in the guide?

Inside the guide, you will find how-to pages, conceptual topics, APIs, spatial analysis services, code examples, tutorials, and more. The guide covers four types of spatial analysis.

Geometry analysis

Geometry analysis uses the ArcGIS Maps SDKs to perform client-side spatial operations with points, polylines, and polygons. The input is a geometry or collection of geometries and the output is a Boolean or a new geometry.

The operations include the following:

Below is an example of performing an overlap spatial relationship using the ArcGIS Maps SDKs:

overlaps spatial relation code sample

Tip: The code examples and tutorials are available for ArcGIS Maps SDKs and scripting languages.

Feature analysis

Feature analysis uses scripting APIs and tools to perform server-side geometric and analytic operations on large feature datasets with the spatial analysis service. All operations are job transactions. The input is typically feature data and the output results in new feature data. 

The types of feature analysis are grouped by functionality, such as:

Below is an example of performing a hot spot feature analysis using the ArcGIS API for Python:
Hot spot feature analysis example code

Tip: The formatted REST (cURL & HTTP) requests are available for each step required to make a request. You can also run the examples in Postman.

Raster analysis

Raster analysis uses scripting APIs, ArcGIS Maps SDKs, and tools to perform server-side geometric and analytic operations on raster data with the raster analysis service. All operations are job transactions. The input is typically existing raster data and the output results in the creation of a new raster dataset.

Raster analysis can be performed as a single operation or chained together using raster functions.

Below is an example of performing a raster function analysis using the ArcGIS scripting APIs:

ArcGIS REST JS Code example of performing an analysis using ArcGIS REST JS

Tip: The formatted REST (cURL & HTTP) requests are available for each step required to make a request. You can also run the examples in Postman.

3D visual analysis

3D visual analysis uses the ArcGIS Maps SDKs to perform client-side calculations to display spatial information derived from terrain, buildings, and other 3D objects within a scene.

The types of 3D visual analysis include:

Below is an ArcGIS Maps SDK for .NET code example of performing a line of sight 3D visual analysis.

Line of sight 3d visual analysis using the ArcGIS Maps SDK

Tip: The code examples and tutorials are available for ArcGIS Maps SDKs.

Learn how to build spatial analysis apps

The How to pages in the guide show you the high-level steps required to perform each type of analysis. Go to these pages to get an overview of how to implement each type of analysis and the APIs and tools required for each. 

Spatial analysis services guide How-to page

Tutorials

The tutorials show you how to perform different types of analysis programmatically or by using tools such as Map Viewer and ArcGIS Pro. Go to the tutorials to get step-by-step instructions and everything you need to perform the analysis.

Feature analysis tutorials pages

Tip: If you are new to performing spatial analysis, it is recommended to follow the tools tutorials first, and after achieving the desired results, write the code to perform the analysis programmatically.

Ready to start building apps?

We hope you found this overview of the guide and tips helpful! To get started go to the Get started page and start building spatial analysis applications. 

In future blogs, we will explore in greater depth how to use various APIs to build spatial analysis applications. 

We want your feedback!

Please take our survey to let us know if the guide was helpful and how we can improve it.

spatial analysis feedback survey

Share this article

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Carissa Choong(@cchoongsidwell)
November 9, 2021 11:08 am

This script is going to be such a huge help but I am running into an error when I run the script as coped: it says that: name “GetParameter” is not defined. Is it because I am running ArcGIS Pro 2.4 perhaps? Thanks!

Katarina Hirai(@khiraisl)
November 18, 2021 11:56 am

Anyone try this? I can’t get the Time Zone to set correctly. After publishing, the feature service reflects UTC for our data’s date fields even though I set the “timezone” parameter to “Pacific Standard Time”.

Yuguang Liu(@yuguangl_uom)
January 23, 2022 7:55 pm

Hi there,

I have created the publish web feature layer, but the input is “map”. What I want to select and publish is a “layer” in the content pane. Could you please tell me how to solve the problem? Thanks in advance.

Best
Leo

James Shreeve(@jshreevesnorfolk)
January 31, 2022 6:08 am
Reply to  Jonah Lay

Hi Jonah, you sent me to this blog from another post last week (thank you!) and I’ve been working through the above and have come across the same problem as Leo. I’ve had a look at the code sample you supplied, is there a way to create a script tool using that code or does it need to be run as a standalone Python script? Or is there a way to alter the code for this blog to look at features rather than map files? Many thanks in advance

Robert Thomson(@miramichiadministrator)
January 24, 2022 12:22 pm

This is great but I can only get it to work if I leave share_groups blank or just use one group name. Otherwise I get 0x800 “This value is not a member of” Any ideas? I’m separating group names with commas. I’m running ArcGIS Pro 2.9.

Robert Thomson(@miramichiadministrator)
January 25, 2022 8:42 am
Reply to  Jonah Lay

That was all I needed, thanks.

Nicholas Gray(@graynic)
February 10, 2022 1:46 pm

Thank you very much for posting this! Is there a way to set the Portal connection where the data will publish to? It looks like it defaults to whatever Portal you are/were signed in to last. I have several Portal/ArcGIS Online connections in Pro but would like to specify which one it publishes too. I plan on setting this up as a scheduled task so I need to make sure it publishes to the right Portal. Thank you!

jonathan molineaux(@jonathan-molineaux_noaa)
February 24, 2022 5:13 am

Thank you for posting this article. I am having an issue with seeing my Portal connection in the output folder though. Is there a workaround for this? If I add the SignInToPortal ArcPy function, will this allow me to view the Portal Connection in my output folder?

Last edited 3 years ago by jonathan molineaux
Evan Marshall(@evan-marshallci-stpaul-mn-us_stpaul)
April 1, 2022 8:02 am

Hello, I implemented this script tool and generally it works well. We do have a weird issue where if we try to use it to overwrite an existing hosted table, it works, but converts the item to a hosted feature layer. We need these items to persist in AGO as hosted tables. Any thought to adding a parameter to tell it to overwrite as a table rather than a service? or choose no geometry type? thanks!

Wilson, Jared(@jcwilson4_ncdenr)
April 8, 2022 11:24 am

I’ve downloaded and used the model as it is used in the demonstration map and it uploaded the layer directly to my AGOL content pane, however, when I attempt to run the Publish Web Feature Layer in my own map, the tool runs for a very extended period of time seemingly without end. Is there an option I should be selecting that is different? I selected to run the tool exactly how I had it in the demo as well.

steve miller(@suasteve)
April 26, 2022 7:35 am

I’ve downloaded the script and got the Model working with one exception, I have a date field and I can’t get it to publish in Eastern Time Zone. What should I be putting in the Time zone parameter? I’ve tried EDT and Eastern_Daylight_Time, but the date field in the web layer is showing UTC. As a side note, when I query the AGOL rest the date field is in EDT.

Thank
Steve

Julia Hillin(@jhillin)
June 24, 2022 11:40 am

I’ve tried running this script but I get a traceback error to lines 30, 68, and 122 and a ValueError: Missing target server. I copied the script over directly and used the correct inputs/configurations, so I’m not sure what the issue is. Any ideas?

Last edited 3 years ago by Julia Hillin
Michael Olkin(@swscgisadmin)
November 2, 2022 9:45 am

I have successfully run this script within a model in a project, but I have not yet had success running it as a scheduled task. Here’s the error that I see in the log after attempting to run it as a scheduled task:

<msg code=”100″ type=”-2147467259″>Failed to execute. Parameters are not valid.</msg><msg code=”100″ type=”735″>The value is empty. ERROR 000735: Map: Value is required</msg>

I have checked and re-checked the script and parameters, but all appears to be set up correctly.

Nicholas Gray(@graynic)
December 13, 2024 9:41 am
Reply to  Michael Olkin

@Michael Olkin did you ever fix this issue? I am experiencing the same thing. I can run the model fine and it publishes but when I schedule it I get this same error. @Jonah Lay Thank you!

Amin Alhassan(@amin-alhassanloudoun-gov_loudounps)
August 9, 2023 10:18 am

Hello Jonah,
Thanks for sharing this script, it’s still “golding” to me. I have adapted it and tried to set the time zone to Eastern Standard Time or ET,EST and all the ways I can imagine the eastern standard time; yet, the time aware data after publishing still shows UTC time values. I have read others comments on the same issue. Are you able to look into that or any other work around. I really appreciate the effort put in.

Thanks,
Amin

Amin Alhassan(@amin-alhassanloudoun-gov_loudounps)
August 15, 2023 10:36 am
Reply to  Jonah Lay

Thanks Jonah, it worked at last. Any thought on overwriting a stand alone hosted feature layer in AGOL? This did not set the time zone but the feature was overwritten when I tried on a hosted feature layer not in a web map.

Carlos Alberto Duarte Carranza(@caduarte_vrip)
September 25, 2023 11:46 am

Dear Jonah,
Thanks for this great and absolutely useful tutorial!
I have a model which ends with a feature layer as output. How can I connect my model with the model in your tutorial to publish (only) my output feature to AGOL?

Thanks in advance!

Carlos

Andrew Ferguson(@andrew-ferguson_whg)
October 9, 2023 3:31 am

Dear Jonah, Thank you. This is an excellent article. I’m having some difficulty publishing a single feature via a model I’ve created. I’ve modified the code to select my layer with “selected_layer = m.listLayers()[0]” and provided this variable within a list as a parameter in the m.getWebLayerSharingDraft() function however I am getting the error: Error 001272: Analzer errors were encountered ([{"code":"00102", "message":"Selected layer does not contain a required layer type for web feature layer", "object":"Map"}]). I can manually publish the layer to AGOL without any analyser errors though. Can you offer any insight as to why this is happening? Thanks… Read more »

Adam Hart(@ahart_midlandcounty)
July 3, 2024 11:25 am

Jonah,

This is a great tool and I am hoping to use it with some of our data. I have one question…How would the code be modified to overwrite a layer with attachments? The steps in the model work fine to add the attachments to the feature class, but I’m having trouble trying to overwrite the AGO layer with the updated attachments. Any help would be greatly appreciated. Thanks