Preview
Hi, Visitor  | 

View shapefile structure 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 template to view the structure of a shapefile and its attribute data. Shapefile features are present as empty types.

Supported HTTP Methods

GET

URL Template

View a shapefile's structure and its attribute data
http://api.shapeserver.com/REST/v1/shapefiles/structure?file=file&format=format&key=ShapeServerKey

Template Parameters

Note
Parameter names and values are not case-sensitive.
Parameter Description Values
file Required The name of the file. A string with the name of the shapefile.
Example: file=RiverSample
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

View a shapefile's structure and its attribute data
The following example retrieves the structure and attribute data of shapefile 'rivers'.
http://api.shapeserver.com/REST/v1/shapefiles/structure?file=rivers&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/acecd38f-ca54-45d1-b6f7-730f5618df0b/2067608809</TraceId>
	<Resource i:type="ShapefileResource">
		<ItemId>1</ItemId>
		<Name>rivers</Name>
		<Shapefile>
			<Name>rivers</Name>
			<SRID>4326</SRID>
			<ShapeType>PolyLine</ShapeType>
			<FeatureCount>98</FeatureCount>
			<CoordinateSystem>
				<Name>GCS_WGS_1984</Name>
				<Unit>UNIT["Degree", 0.0174532925199433]</Unit>
				<WKT>GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137, 298.257223563]], PRIMEM["Greenwich", 0], UNIT["Degree", 0.0174532925199433]]</WKT>
			</CoordinateSystem>
			<BoundingBox>
				<Value>Lower Left: (-164,62, -36,90) Upper Right: (161,07, 72,23)</Value>
				...
			</BoundingBox>
			<Features>
				<Feature i:type="PolyLine">
					<FeatureId>0</FeatureId>
					<IsEmpty>true</IsEmpty>
					<BoundingBox i:nil="true"/>
					<CoordinateSystem i:nil="true"/>
					<WKB i:nil="true"/>
					<WKT i:nil="true"/>
					<DBFData i:nil="true"/>
					<NumPoints>0</NumPoints>
					<Points i:nil="true"/>
					<Ordinal>0</Ordinal>
				</Feature>
				<Feature i:type="MultiPolyLine">
					<FeatureId>1</FeatureId>
					<IsEmpty>true</IsEmpty>
					<BoundingBox i:nil="true"/>
					<CoordinateSystem i:nil="true"/>
					<WKB i:nil="true"/>
					<WKT i:nil="true"/>
					<DBFData i:nil="true"/>
					<NumPolyLines>0</NumPolyLines>
					<PolyLines i:nil="true"/>
				</Feature>
				...				
			</Features>
			<DBFData>
				<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
					<xs:element name="DBFData">
						<xs:complexType>
							<xs:sequence>
								<xs:element name="FeatureId" type="xs:int" minOccurs="0"/>
								<xs:element name="OID" type="xs:unsignedInt" minOccurs="0"/>
								<xs:element name="NAME" type="xs:string" minOccurs="0"/>
								<xs:element name="SYSTEM" type="xs:string" minOccurs="0"/>
							</xs:sequence>
						</xs:complexType>
					</xs:element>
					<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="DBFData" msdata:UseCurrentLocale="true">
						<xs:complexType>
							<xs:choice minOccurs="0" maxOccurs="unbounded">
								<xs:element ref="DBFData"/>
							</xs:choice>
						</xs:complexType>
					</xs:element>
				</xs:schema>
				<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
					<DocumentElement xmlns="">
						<DBFData diffgr:id="DBFData1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
							<FeatureId>0</FeatureId>
							<OID>0</OID>
							<NAME>Aldan</NAME>
							<SYSTEM>Lena</SYSTEM>
						</DBFData>
						<DBFData diffgr:id="DBFData2" msdata:rowOrder="1" diffgr:hasChanges="inserted">
							<FeatureId>1</FeatureId>
							<OID>1</OID>
							<NAME>Amazon</NAME>
							<SYSTEM>Amazon</SYSTEM>
						</DBFData>	
						...					
					</DocumentElement>
				</diffgr:diffgram>
			</DBFData>
		</Shapefile>
		<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\/abdea131-0f1b-4ff1-a991-c56e8078d3e3\/-1616183636",
	"Resource":
	{
		"__type":"ShapefileResource:http:\/\/schemas.shapeserver.com\/rest\/v1",
		"ItemId":1,
		"Name":"rivers",
		"Shapefile":
		{
			"Name":"rivers",
			"SRID":4326,
			"ShapeType":"PolyLine",
			"FeatureCount":98,
			"CoordinateSystem":
			{
				"Name":"GCS_WGS_1984",
				"Unit":"UNIT[\"Degree\", 0.0174532925199433]",
				"WKT":"GEOGCS[\"GCS_WGS_1984\", DATUM[\"D_WGS_1984\", SPHEROID[\"WGS_1984\", 6378137, 298.257223563]], PRIMEM[\"Greenwich\", 0], UNIT[\"Degree\", 0.0174532925199433]]"
			},
			"BoundingBox":
			{
				"Value":"Lower Left: (-164,62, -36,90) Upper Right: (161,07, 72,23)",
				...
			},
			"Features":
			[
				{
					"__type":"PolyLine:http:\/\/schemas.shapeserver.com\/rest\/v1",
					"FeatureId":"0",
					"IsEmpty":true,
					"BoundingBox":null,
					"CoordinateSystem":null,
					"WKB":null,
					"WKT":null,
					"DBFData":null,
					"NumPoints":0,
					"Points":null,
					"Ordinal":0
				},
				{
					"__type":"MultiPolyLine:http:\/\/schemas.shapeserver.com\/rest\/v1",
					"FeatureId":"1",
					"IsEmpty":true,
					"BoundingBox":null,
					"CoordinateSystem":null,
					"WKB":null,
					"WKT":null,
					"DBFData":null,
					"NumPolyLines":0,
					"PolyLines":null
				},	
				...			
			],
			"DBFData":"<DataTable xmlns=\"http:\/\/schemas.datacontract.org\/2004\/07\/System.Data\">
			<xs:schema id=\"NewDataSet\" xmlns:xs=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns=\"\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">
				<xs:element name=\"DBFData\">
					<xs:complexType>
						<xs:sequence>
							<xs:element name=\"FeatureId\" type=\"xs:int\" minOccurs=\"0\"\/>
							<xs:element name=\"OID\" type=\"xs:unsignedInt\" minOccurs=\"0\"\/>
							<xs:element name=\"NAME\" type=\"xs:string\" minOccurs=\"0\"\/>
							<xs:element name=\"SYSTEM\" type=\"xs:string\" minOccurs=\"0\"\/>
						<\/xs:sequence>
					<\/xs:complexType>
				<\/xs:element>
				<xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:MainDataTable=\"DBFData\" msdata:UseCurrentLocale=\"true\">
					<xs:complexType>
						<xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">
							<xs:element ref=\"DBFData\"\/>
						<\/xs:choice>
					<\/xs:complexType>
				<\/xs:element>			
			<\/xs:schema>
			<diffgr:diffgram xmlns:diffgr=\"urn:schemas-microsoft-com:xml-diffgram-v1\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">
				<DocumentElement xmlns=\"\">
					<DBFData diffgr:id=\"DBFData1\" msdata:rowOrder=\"0\" diffgr:hasChanges=\"inserted\">
						<FeatureId>0<\/FeatureId><OID>0<\/OID><NAME>Aldan<\/NAME><SYSTEM>Lena<\/SYSTEM>
					<\/DBFData>
					<DBFData diffgr:id=\"DBFData2\" msdata:rowOrder=\"1\" diffgr:hasChanges=\"inserted\">
						<FeatureId>1<\/FeatureId><OID>1<\/OID><NAME>Amazon<\/NAME><SYSTEM>Amazon<\/SYSTEM>
					<\/DBFData>
					...
				<\/DocumentElement>
			<\/diffgr:diffgram><\/DataTable>"
		},
		"IsPublicShape":false
	}
}
                
Note
Not all features and their associated metadata are shown in the responses above. When data has been omitted three dots (...) mark the location of the omitted data.

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