Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

Uploading Item with British National Grid Spatial Reference #236

Closed SergStol closed 8 years ago

SergStol commented 8 years ago

I need to upload an item which is a zipped FGDB with multiple shapefiles within that are in British National Grid. Basemap is OS mastermap so its in BNG. When I do a normal upload there is a 1 meter mismatch between layer and basemap. Feature layer is showing with Spatial Reference of Web Mercator.

I defined spatialReference in addItem() method through parameters and also as targetSR in publishFGDBParameters. Still once uploaded the Feature Service is mismatched and in Web Mercator not in BNG (27700).

I cannot get the spatialReference parameter to post property here is my code:

user = content.users.user() ip = arcrest.manageorg.ItemParameter()

ip.title = name ip.filename = name + '.zip' ip.type = "File Geodatabase" ip.tags = name ip.spatialReference = arcrest.geometry.SpatialReference(wkid = 27700, wkt = None) ip.overwrite = True item = user.addItem(itemParameters=ip, filePath = zipped_FGDB, multipart = multipart)

description = 'Description of Service' publishParameters = arcrest.manageorg.PublishFGDBParameter(name, description, overwrite = True, targetSR = 27700)

item = user.publishItem(fileType="fileGeodatabase", publishParameters=publishParameters, itemId = item_id, overwrite = True, wait = True)

achapkowski commented 8 years ago

@SergStol can you please send me a small zip file of your data to achapkowski@esri.com

SergStol commented 8 years ago

I have managed to publish the data and preserve the BNG spatial reference. The issue was within PublishFGDBParameter() objects parameter formats for spatial reference. Currently its just an integer e.g. targetSR = 27700. This is incorrect JSON format, should be { "wkid" : 27700}, plus I added in another parameter into the source code on my local machine, "sourceSR".

publishParameters = arcrest.manageorg.PublishFGDBParameter(name, description, sourceSR = { "wkid" : 27700 }, targetSR = { "wkid" : 27700 })

item = user.publishItem( fileType="fileGeodatabase", publishParameters=publishParameters, itemId = item_id, overwrite = True, wait = True)

I did not need to define spatial reference while addItem() process either.