4

I am developing a script which gets an JSON array with point coordinates. This array is encoded to a python dictionary. From this I filter all points (latitude and longitude) and an ID. This coordinates are converted into arcpy-points by using arcpy.Point(). Now in a next step I want to create a shapefile of these points by using Code:

arcpy.CopyFeatures_management(ptList, r"pointTemp.shp")

My question is how to store this shapefile into a folder which is located on ArcGIS Server side. Do I have to give the skript a special path or location?

One folder that is on ArcGIS Server side in my case is "C:\temp", I have full read and wright rights, but the script doesn´t create the shapefile in this folder. If I run the script local on my pc, all works fine and the shape is created and stored locally on "C:\temp".

Any suggestions or tips?

1
  • 1
    Not terribly important in this case, but the version (10.0, 10.1) may tailor a more exact answer in terms of arcpy commands
    – KHibma
    Nov 26, 2012 at 17:37

1 Answer 1

5

I assume you're talking about geoprocessing services because you're using tools? By default Server will write output to the local jobs directory for a particular service / execution. This directory is guaranteed to exist and is created at execution time. You just need to write your shapefile there. Server then handles sending it back to the client.

outputPoints = os.path.join(arcpy.env.scratchWorkspace, "pointTemp.shp")    
arcpy.CopyFeatures_management(ptList, outputPoints)

Alternatively you can do a copy to a known directory to persist the result somewhere on the Server. The only problem is making sure you dont overwrite existing files Server side (ie, you're now responsible for unique file names/locations)

#code to ensure name is unique
#newOutputName = os.path.join("c:\\temp", "newname.shp")
arcpy.Copy_management(outputPoints, newOutputName)
3
  • Thanks, that works! I have a follow-up question. When I want to use the function spatial join, I use as input my point.shp, but how do I have to call a second shape that lies somewhere else on the Server? Sorry, if these are stupid question, but I am new to this stuff. A Database with FeatureClasses is located here on the Server: C:\arcgisserver\directories\arcgissystem\arcgisinput\project\project.MapServer\extracted\v101\database.gdb But this path does not work. Do I have to change something? Thanks.
    – Sven
    Nov 26, 2012 at 18:19
  • That database was most likely put there through the publishing process. I personally wouldnt link against that. Its now become a static copy of your data (whether or not you intended that). If you setup and use a data store entry (telling server where you data lives) you can control what data each service uses. Just setup the spatial join tool with whatever data you need to use in your script. The publishing process (as-is right now without a datastore) will copy the data needed when publishing. Else, setup the datastore and re-publish and you map and gp services will reference the same data
    – KHibma
    Nov 26, 2012 at 19:50
  • No, the database is already there and was not published in combination with my script. Can you tell me more about the data store entry?
    – Sven
    Nov 27, 2012 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.