Preview
Hi, Visitor  | 

Visualize feature data 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 create an image with feature data.

Supported HTTP Methods

GET

URL Templates

Create an image with a style theme
http://api.shapeserver.com/REST/v1/shapefiles/images?file=file&fid=fid&size=size&buffer=buffer&singleimage=singleimage&includehotspots=includehotspots&theme=theme&format=format&nocache=nocache&reducetol=reducetol&key=ShapeServerKey
Create an image without a style theme
http://api.shapeserver.com/REST/v1/shapefiles/images?file=file&fid=fid&size=size&linecolor=linecolor&linewidth=linewidth&fillColor=fillColor&bgColor1=bgColor1&bgColor2=bgColor2&bgAngle=bgAngle&buffer=buffer&grid=grid&gridcolor=gridcolor&gridspace=gridspace&singleimage=singleimage&includehotspots=includehotspots&format=format&nocache=nocache&reducetol=reducetol&key=ShapeServerKey

Template Parameters

Note
Parameter names and values are not case-sensitive.
Parameter Description Values
file Required The name of the shapefile that contains the feature(s) you wish to visualize. A string with the shapefile name.
Example: file=RiverSample
fid Required Specifies the ids of the feature(s) to visualize.
Note
To retrieve a child feature from a multi-part feature (MultiPoint, MultiPolyLine and MultiPolygon shapes), use the parent.child format notation.
Example: fid=5.2 refers to child feature 2 of multi-part parent feature 5.
A comma-separated string with feature ids.
Example: fid=1,2,5.2,11
size Optional A comma-separated string containing the image height and width. A string with two integer values separated by a comma, indicating the height and width of the image. The default value is 480,640.
Example: size=300,400
lineColor Optional Specifies the color of a line string or polygon border. Overruled when parameter 'theme' is specified. A string with a hexadecimal color code. The default value is #FF0000 (red).
Example: lineColor=#AF4400
lineWidth Optional Specifies the width of a line string or polygon border in pixels. Overruled when parameter 'theme' is specified. A string that contains an integer value. The default value is 2.
Example: lineWidth=4
fillColor Optional Specifies the fill color of a polygon. Overruled when parameter 'theme' is specified. A string with a hexadecimal color code. The default value is #D3D3D3 (light gray).
Example: fillColor=#0000FF
bgColor1 Optional Specifies the primary background color of the resulting image. Overruled when parameter 'theme' is specified. A string with a hexadecimal color code. The default value is Transparent.
Example: bgColor1=#FFFFFF
bgColor2 Optional Specifies the secondary background color of the resulting image. When specified, a background gradient will be created that uses the values of parameters 'bgColor1' and 'bgColor2' as start and end colors, respectively. Overruled when parameter 'theme' is specified. A string with a hexadecimal color code. The default value is Transparent.
Example: bgColor2=#000000
bgAngle Optional The angle of the background gradient. Valid only if parameters 'bgColor1' and 'bgColor2' are specified. Overruled when parameter 'theme' is specified. A string that contains an integer value between 0 and 360.
Example: bgAngle=45
buffer OptionalThe amount of pixels to use to create a buffer around the resulting image. A string that contains an integer value. The default value is 12.
Example: buffer=20
grid Optional Indicates whether to show a background grid. Overruled when parameter 'theme' is specified. A string that contains an integer value of 0 or 1. The default value is 0 (no grid).
Example: grid=1
gridColor Optional Specifies the color of the background grid lines in hexadecimal notation. Valid only if parameter 'grid' is '1' (use grid). Overruled when parameter 'theme' is specified. A string with a hexadecimal color code. The default value is #D3D3D3 (light gray).
Example: gridColor=#FFFFFF
gridSpace Optional Sets the background grid line spacing in pixels. Valid only if parameter 'grid' is '1' (use grid). Overruled when parameter 'theme' is specified. A string that contains an integer value. The default value is 20.
Example: gridSpace=25
singleImage Optional Indicates whether to generate a single image that contains all features specified in parameter 'fid' or to generate one image per specified feature. A string that contains an integer value of 0 or 1. The default value is 0 (false).
Example: singleImage=1
includeHotSpots Optional Indicates whether to generate a FeatureImage that contains a HotSpot collection for use in an image map control. A string that contains an integer value of 0 or 1. The default value is 0 (false).
Example: includeHotSpots=1
theme Optional The name of the style theme to be applied to the image. One of the following values:
  • Movie
  • MovieGrid
  • Ocean
  • OceanGrid
  • ShapeServerBlue
  • Sky
  • SkyGrid
  • Steel
  • SteelGrid
  • Tech
  • TechGrid
Example: theme=steel
reduceTol 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: reduceTol=10000
noCache Optional Indicates whether to cache the specified features. Use this option to improve performance when selecting the same set of features multiple times from a large shapefile. A string that contains an integer value of 0 or 1. The default value is 0 (use cache).
Example: noCache=1
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, you must set the content type in the request to the following value:
  • XML (application/xml)

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

Create an image with a style theme
The following example creates a single image of features 0...5 in shapefile 'rivers' and uses theme 'Sky'.
http://api.shapeserver.com/REST/v1/shapefiles/images?file=rivers&fid=0,1,2,3,4,5&singleImage=1&theme=Sky&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/9c222cbe-d5a7-4523-98d8-b64b4b6236d6/-914234351</TraceId>
	<Resource i:type="ShapefileFeatureImageCollection">
		<ItemId>1</ItemId>
		<Shapefile>rivers</Shapefile>
		<ShapefileFeatureImages>
			<ShapefileFeatureImage>
				<ItemId>1</ItemId>
				<FeatureId>-1</FeatureId>
				<FeatureImage>iVBORw0KGGgoAAAAgoFTkSuQmCC ...</FeatureImage>
				<FeatureHotSpots i:nil="true"/>
			</ShapefileFeatureImage>
		</ShapefileFeatureImages>
	</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\/6cce30a4-e974-41e5-9b10-424c35475166\/2073774302",
	"Resource":
	{
		"__type":"ShapefileFeatureImageCollection:http:\/\/schemas.shapeserver.com\/rest\/v1",
		"ItemId":1,
		"Shapefile":"rivers",
		"ShapefileFeatureImages":
		[
			{
				"ItemId":1,
				"FeatureId":-1,
				"FeatureImage":[137,80,78,71,13,10,26,10,0,12,22,1,56 ...],
				"FeatureHotSpots":null
			}
		]
	}
}
                
Note
The binary data in the FeatureImage nodes has been truncated to improve readability.

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