ArcPy vs ArcGIS Python API for uploading data to local ArcGIS Server?

1297
12
Jump to solution
01-24-2018 12:32 PM
MatthewSanders1
New Contributor III

I am tasked with integrating information from a different data collection system into a client's existing ArcGIS Server (local server running version 10.2). Eventually, I will rewrite the data collection system to directly use the ArcGIS Server as a backend, but for now I am writing a Python script that will run every night and sync the data to the ArcGIS Server.

I'm a bit stuck on the difference between using ArcPy or the ArcGIS Python API tool available from Esri. Which one is better suited for my task at hand?

Thanks!

Sanders

0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Frequent Contributor

Might be a terminology thing, but can you explain what you mean by syncing data to the ArcGIS Server?  I assume you mean you're interseted in syncing data to a file geodatabase or somewhere else on the ArcGIS Server machine, and that data is then published to Server.

Personally, I'd say that the arcpy module is best suited for that, as you can take advantage of GP tools to sync such as truncate and append, or using the Distributed Geodatabase toolset. I don't think the Python API allows you to do that, but I may be wrong.

View solution in original post

12 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Matthew,

What type of data are you working with?  If possible, you can simply update the feature class the service is created from.  As long as the database this feature class is stored in is registered with ArcGIS Server you won't have to do anything.  The service will update automatically.

MatthewSanders1
New Contributor III

Thanks for the reply! I have a question that may help clear up my confusion...

To add data to the ArcGIS Server, do I use an ArcGIS API, or do I add directly to the database it reads from? As I explained in another comment, my past experience is dealing with systems that have an API which accepts the data and then adds it to the database for you - you never directly touch the database yourself. Although now I'm starting to think with ArcGIS I need to add the data to the ArcGIS database itself and not go through ArcGIS Server's API.

To be more clear, let's say I have 3 servers, "MyDatabaseServer", "ArcGISDatabaseServer", and "ArcGISServer"

My original understanding is that I would pull data from MyDatabaseServer, give it to ArcGISServer, and ArcGISServer would push the data to ArcGISDatabaseServer.

But now I'm wondering if I was looking at it wrong, and that I actually need to pull data from MyDatabaseServer and manually add it to the database on ArcGISDatabaseServer, and that ArcGISServer will update itself using the data I added to the ArcGISDatabaseServer database. Is that correct?

0 Kudos
JonathanQuinn
Esri Frequent Contributor

Might be a terminology thing, but can you explain what you mean by syncing data to the ArcGIS Server?  I assume you mean you're interseted in syncing data to a file geodatabase or somewhere else on the ArcGIS Server machine, and that data is then published to Server.

Personally, I'd say that the arcpy module is best suited for that, as you can take advantage of GP tools to sync such as truncate and append, or using the Distributed Geodatabase toolset. I don't think the Python API allows you to do that, but I may be wrong.

MatthewSanders1
New Contributor III

Thank you for your reply! I was brought on near the end of a project that revolves around ArcGIS. Unfortunately, I have no experience with, or prior knowledge of, GIS, ArcGIS, or any of its components. Being new to the subject, I don't fully understand the terminology, so I apologize for the confusion.

I was given the task of taking information from our proprietary data collection system and 'exporting' it to a client's existing ArcGIS Server (their server is running ArcGIS v10.2). So basically, I am pulling data from our database and adding it to the client's ArcGIS database. It seems like a relatively simple goal, but learning my way around ArcGIS in a short period of time is a heck of a pill to swallow and I am left with many questions.

Let's say their server has a service called "roads" and it has a feature layer called "signs" which holds the geolocation and information about every road sign in the state. I need to write a python script which can accept new data and enter it into the client's ArcGIS server. I thought it would be simple, but I am out of my element and could use a point in the right direction. It seems like some people use arcpy, but the website makes ArcGIS API for Python look like the recommended option.

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

I second Jonathan Quinn  suggestions of sticking with arcpy for this and to use the database tools and append.  You may need to do some prep work from the collection table to get it to be in the right format to append.  

do you know what database is being used for the ArcGIS Server service? (Sorry if you mentioned it and I missed it)

i like to use file geodatabases (fgdb) v's an enterprise database (e.g. ArcSDE for SQL or Oracle).  Even if you are updating a "master" database using an enterprise, you can export to a fgdb and run the service using that.  I recommend stopping the service, updating the file and restarting the service, although there are other ways to do this.

i would first take a copy of the target file and get the appending of new data figured out.  If you have issues with the arcpy syntax, make sure to pull and <passwords> or other secure items out, and post the code using https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?s...‌ so others can help.

MatthewSanders1
New Contributor III

I'm not positive what database is being used for the ArcGIS Server service, but I will check.

I have a question which may clear up some of my confusion:

Do I add data to the server via the ArcGIS Server's API, or do I have to add data directly to the database?

In my experience with other systems, the server has an API which accepts the data, cleans/processes it, and then adds it to the database - you never directly touch the database yourself. Is this how ArcGIS works? Or do I need to access the database and add the data that way?

0 Kudos
JonathanQuinn
Esri Frequent Contributor

Generally, an organization will have a database that is hosted on a separate machine from their ArcGIS Server instance. That database will be registered to ArcGIS Server as a data store and you'll build map documents using the data.  Then, you'll publish the map document to ArcGIS Server and the Server will simply retrieve data from the database directly to respond to any requests for the service. If data is being used in a service and it's updated within the database, those changes will be honored within the service.

MatthewSanders1
New Contributor III

Ok, that's exactly what I needed to know, thank you. So I need to be connecting to the organization's database server and adding information directly to their database. That clears up a whole lot.

So in theory, if my database's data is already formatted correctly for the client's database, I wouldn't even need arcpy or ArcGIS API for Python, I'd just need to insert it into the database?

JonathanQuinn
Esri Frequent Contributor

Yes, keep things simple. If your clients database is accessible to ArcGIS Server, simply register the database as a data store and publish maps using data from the database.  If your clients database is not accessible to ArcGIS Server, (different network, etc), then you may have to think about replication techniques like replicas or truncating and appending data.