Preview
Hi, Visitor  | 

Upload shapefiles with the ShapeServer REST API

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Use the following URL templates to upload shapefiles to ShapeServer.

Supported HTTP Methods

POST

URL Templates

Upload a shapefile
http://api.shapeserver.com/REST/v1/upload?file=filename&access=access&format=format&key=ShapeServerKey
Upload a shapefile and create preview image
http://api.shapeserver.com/REST/v1/upload?file=filename&access=access&preview=preview&previewsize=previewsize&previewtheme=previewtheme&previewreducetol=previewreducetol&format=format&key=ShapeServerKey

Template Parameters

Note
Parameter names and values are not case-sensitive.
Parameter Description Values
filename Required The name of the ZIP file to upload. A string with the name of the ZIP file that contains the set of files that comprise a specific shapefile. The ZIP file should at least contain the .shp, .shx and .dbf files. The projection (.prj) file is optional, if it is missing the WGS84 projection is assumed. Make sure that all files in the ZIP file have the same file name. The ZIP file should contain a single shapefile set.
Example: filename=RiverSample.zip
access Optional Specifies whether the file is publicly-accessible. One of the following values:
  • Public: make the file visible to anyone with a valid ShapeServer key.
  • Private: do not make the file public [default].
Example: access=private
preview Optional Indicates whether to create an image of the contained features. A string that contains an integer value of 0 or 1. The default value is 0.
Example: preview=0
previewSize Optional A comma-separated string containing the preview image height and width. A string with two integer values separated by a comma, indicating the height and width of the preview image. The default value is 480,640.
Example: previewSize=300,400
previewTheme Optional The name of the style theme to be applied to the preview image. One of the following values:
  • Movie
  • MovieGrid
  • Ocean
  • OceanGrid
  • ShapeServerBlue
  • Sky
  • SkyGrid
  • Steel
  • SteelGrid
  • Tech
  • TechGrid
Example: previewTheme=steel
previewReduceTol Optional The tolerance to input to the map layer coordinate reduction algorithm. This property is relevant only to layers of types Polygon and Polyline. A double value. The default value is 0 (do not reduce the layer coordinates).
Example: previewReduceTol=10000
format Optional The output format for the response. One of the following values:
  • xml [default]
  • json
Example: format=json
key Required Specifies the ShapeServer key to use for this request. A valid ShapeServer key.
Example: key=abc1234def56789

Input

When you create the HTTP request to upload data, you must post the input data in the body of the request. You must also set the content type in the request to the following value:
  • ZIP (application/x-zip-compressed)

Response

A Response resource is returned when you make a request. The response supports the following response formats:
  • XML (application/xml)
  • JSON (application/json)

Examples

Upload a shapefile
The following example uploads a ZIP file with the Rivers shapefile file set and does not make it publicly-accessible.
http://api.shapeserver.com/REST/v1/upload?file=rivers.zip&access=private&key=ShapeServerKey

XML Response

                    
<Response xmlns="http://schemas.shapeserver.com/rest/v1" 
		  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
	<Copyright>Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.</Copyright>
	<StatusCode>200</StatusCode>
	<StatusDescription>OK</StatusDescription>
	<ErrorDetails/>
	<TraceId>A194389081078C7D09BEBEABD04A01E877624938/ce556ffa-2f23-46e8-87d2-1c124b83257e/966204447</TraceId>
	<Resource i:type="ShapefileUpload">
		<ItemId>1</ItemId>
		<Name>rivers</Name>
		<Created>2012-12-05T11:11:19.5518436+01:00</Created>
		<Completed>2012-12-05T11:11:20.0468719+01:00</Completed>
		<SRID>4326</SRID>
		<ShapeType>PolyLine</ShapeType>
		<FeatureCount>98</FeatureCount>
		<Status>Completed</Status>
		<PreviewImage i:nil="true"/>
		<IsPublicShape>false</IsPublicShape>
	</Resource>
</Response>
                

JSON Response

                    
{
	"Copyright":"Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.",
	"StatusCode":200,
	"StatusDescription":"OK",
	"ErrorDetails":"",
	"TraceId":"A194389081078C7D09BEBEABD04A01E877624938\/4b72bd38-2175-482c-8ec1-c655643c712d\/586310508",
	"Resource":
	{
		"__type":"ShapefileUpload:http:\/\/schemas.shapeserver.com\/rest\/v1",
		"ItemId":1,
		"Name":"rivers",
		"Created":"\/Date(1354703135947+0100)\/",
		"Completed":"\/Date(1354703136207+0100)\/",
		"SRID":4326,
		"ShapeType":"PolyLine",
		"FeatureCount":98,
		"Status":"Completed",
		"PreviewImage":null,
		"IsPublicShape":false
	}
}
                
Upload a shapefile and create preview image
The following example uploads a ZIP file with the Rivers shapefile file set, creates a preview image with style theme 'Steel' and does not make it publicly-accessible.
http://api.shapeserver.com/REST/v1/upload?file=rivers.zip&preview=1&previewsize=300,400&previewtheme=Steel&access=private&key=ShapeServerKey

XML Response

                    
<Response xmlns="http://schemas.shapeserver.com/rest/v1" 
		  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
	<Copyright>Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.</Copyright>
	<StatusCode>200</StatusCode>
	<StatusDescription>OK</StatusDescription>
	<ErrorDetails/>
	<TraceId>A194389081078C7D09BEBEABD04A01E877624938/d30d16e3-3275-4f83-85bc-56522fb9f029/-221435869</TraceId>
	<Resource i:type="ShapefileUpload">
		<ItemId>1</ItemId>
		<Name>rivers</Name>
		<Created>2012-12-05T11:43:37.2096713+01:00</Created>
		<Completed>2012-12-05T11:43:38.4157403+01:00</Completed>
		<SRID>4326</SRID>
		<ShapeType>PolyLine</ShapeType>
		<FeatureCount>98</FeatureCount>
		<Status>Completed</Status>
		<PreviewImage>iVBORw0KGgoAAAANSUhEUgbFMer9RWyQX ...</PreviewImage>
		<IsPublicShape>false</IsPublicShape>
	</Resource>
</Response>
                

JSON Response

                    
{
	"Copyright":"Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.",
	"StatusCode":200,
	"StatusDescription":"OK",
	"ErrorDetails":"",
	"TraceId":"A194389081078C7D09BEBEABD04A01E877624938\/020cae2d-4b6a-4697-a776-685b6bc44218\/8288464",
	"Resource":
	{
		"__type":"ShapefileUpload:http:\/\/schemas.shapeserver.com\/rest\/v1",
		"ItemId":1,
		"Name":"rivers",
		"Created":"\/Date(1354705135962+0100)\/",
		"Completed":"\/Date(1354705136801+0100)\/",
		"SRID":4326,
		"ShapeType":"PolyLine",
		"FeatureCount":98,
		"Status":"Completed",
		"PreviewImage":[137,80,78,71,13,10,26,10,0,0,0,66,96,130, ...],
		"IsPublicShape":false
	}
}
                
Note
The PreviewImage nodes have been truncated for clarity.

HTTP Status Codes

When the request is successful, the following HTTP status code is returned.
  • 200
When the request is not successful, the response returns one of the following errors.
  • 400
  • 401
  • 404
  • 500
  • 503

See Also