A shapefile is an Esri vector data storage format for storing the location, shape, and attributes of geographic features. It is stored as a set of related files and contains one feature class. Shapefiles often contain large features with a lot of associated data and historically have been used in GIS desktop applications such as ArcMap. If you have a small amount of data in a shapefile—generally fewer than 1,000 features—you can make it available for others to view through a web browser by adding it as a .zip file containing the .shp, .shx, .dbf, and .prj files to a map you create with the map viewer.
When you add a shapefile, the map viewer converts it to a format that web clients can quickly read and display. To help further improve the performance of the display, you can choose to generalize the features in your shapefile. Generalizing reduces the size of the shapefile by simplifying the features and is often appropriate for data at small scales.
Generalize features for web display
Shapefiles often contain large features with a lot of associated data. Smaller features with less data are often necessary for the shapefile to display properly over the web. Generalizing the features is one way to reduce the size of the shapefile and therefore improve web display. You can generalize the features using a desktop application such as ArcMap or you can have the map viewer do the generalization when you add the file to your map. Generalizing reduces the precision of the shapefile layer to approximately 1 meter in Web Mercator and will remove vertices within 10 meters in Web Mercator. This should maintain an informative and accurate display of your features while reducing the overall size of your data and allowing your layer to quickly display in the map.
Generalizing doesn't work well on coincident polygon features intended for large-scale display because it will create some slivers in the polygons. For coincident polygons at large scales, you can choose to maintain the features if you have a relatively small amount of data, or if you have a large amount of data, you can publish a feature service to a GIS Server site. If you have publishing privileges in your organization, you can also create feature layers by publishing features.
Considerations for adding shapefiles
Shapefiles were originally created to perform geoprocessing on desktop apps. They are now supported in a number of web browser clients including the map viewer. There are some limits to what web browser clients can support.
Below are best practices for using shapefiles in the map viewer.
- Choose to generalize features for web display if you have a large amount of features intended to be displayed at small scales and you have not already generalized your vertices in ArcGIS Desktop.
- Create a .zip file that contains the .shp, .shx, .dbf, and .prj files that comprise the shapefile.
- Store your shapefile directly in the root (the central directory) of the .zip archive and not in directories within the archive. If your .zip file viewer shows path information, the path should be blank.
- The name of the new layer is the same as the name of the .zip file you added. You can rename the file before adding to the map, or rename the layer once it is part of the map.
- Add standard compressed archive .zip files.
- Include no more than 1,000 shapefile features in your file.
- In some cases, when you attempt to add a file with fewer than 1,000 features, you see an error message that the shapefile is too big to add to the map. This occurs when the extracted data is too big to display in a web browser or the file is larger than 10 MB. Often, generalizing the features will reduce the overall size and allow the shapefile to be added to the map. If that doesn't work, you may need to create a feature service with ArcGIS Server. If you have publishing privileges in your organization, you can create feature layers by publishing features. You can try breaking up your features into multiple shapefiles, but this may result in a map that takes a long time to display.
- The shapefile should contain valid geometries. If you have ArcMap, you can use the Repair Geometry geoprocessing tool to correct invalid geometries in shapefiles.
- Include in the shapefile the accompanying .prj file in which the coordinate system of the data is defined. If you have ArcMap, you can define the coordinate system of a shapefile, which creates an appropriate .prj file for the shapefile.
The following limitations apply to using shapefiles in the map viewer:
- Compression formats other than a .zip archive are not supported.
- Files containing more than 1,000 features cannot be added to a map.
- The shapefile must be less than 10 MB in size.
- The following features are not supported: multipatch or multipoint geometries, geometries that cross the dateline, or self-intersections in polygons. Shapefiles with these features cannot be added to a map.
- Shapefiles cannot be dragged directly onto the map viewer; you must use the Add button in the map viewer.