Shapefile Converter
Operator: Abdulla Al Fahad. How tools are built and checked
A shapefile is never one file. The shapes sit in .shp, their positions in .shx, the attributes in .dbf, the coordinate system in .prj and the text encoding in .cpg, and a conversion that loses one of them gives wrong places or garbled names. This page takes the set, as a ZIP or as loose files, and keeps them together. Output is GeoJSON, CSV or KML in WGS 84, and the same page goes the other way: GeoJSON, or a CSV with latitude and longitude, becomes a shapefile ZIP.
Key features
- Reads every shape type, including Z and M variants, MultiPoint, PolyLine and Polygon with holes; MultiPatch is skipped with a notice
- Decodes DBF text with the code page from the .cpg, else from the file's language driver byte, else UTF-8 with a Windows-1252 fallback, or the one you choose
- Reprojects from the .prj with proj4, or from a choice of WGS 84, Web Mercator, British National Grid, a UTM zone or your own proj4 string
- Simplifies lines and polygon rings with Douglas-Peucker (metres) or Visvalingam-Whyatt (area)
- Draws a map preview from your own projection with no tiles, next to a filterable attribute table
- Writes GeoJSON with RFC 7946 winding, CSV with WKT or latitude and longitude, and KML
How the sidecar files, code pages and projections are used
The .shp holds records of one shape type. Polygon rings in a shapefile run clockwise for outer boundaries and counter-clockwise for holes; GeoJSON reverses that, so rings are reversed on the way out, and each hole is attached to the smallest outer ring that contains it. Polygons whose winding breaks the convention are repaired by treating them as separate polygons, and a notice counts how many.
Limits: a .shp up to 400 MB, 25 million vertices and 3 million records in total; a ZIP may unpack to 600 MB across at most 400 entries, and the unpacked bytes are counted as they are produced, not taken from the sizes the ZIP declares. Records the .dbf marks as deleted are skipped.
Without a .prj the page assumes WGS 84 only when every coordinate already fits inside longitude -180 to 180 and latitude -90 to 90. Otherwise it keeps the numbers, says it cannot reproject, and blocks the download until you pick a system, because GeoJSON and KML in the wrong coordinates are worse than none.
How it works
Reprojection sends each vertex through proj4. A vertex that falls outside the valid range of the projection makes that feature's geometry empty, and the page counts them. A .prj that names a datum other than WGS 84, ETRS89 or NAD83 and gives no datum shift triggers a warning, because the result can be off by metres to a few hundred metres.
Simplification works on local metres: longitude is scaled by the cosine of the feature's mean latitude. Rings keep at least four points and never collapse, lines keep at least two, and point layers are left alone.
Common use cases
- A city planner downloads a 38 MB parcel ZIP in State Plane feet. The .prj names the zone, so the GeoJSON lands in the right place without choosing anything.
- A volunteer receives a .dbf full of question marks. The .cpg says UTF-8 but the data is Windows-1250; choosing Windows-1250 in Settings restores the accented street names.
- A fieldworker has a CSV of 800 survey points with lat and lon columns. The shapefile ZIP opens in desktop GIS with PointZ geometry because a height column was chosen.
- A web developer needs a county boundary layer as a lightweight GeoJSON for a map. Visvalingam-Whyatt at a modest tolerance cuts the vertex count by most of its size while keeping the outline recognisable, and the before and after counts are shown.
- A data journalist gets a layer with no .prj from a colleague. The numbers are about 500,000 and 4,500,000, nowhere near degrees, so the page refuses to guess and asks for a coordinate system before it lets the GeoJSON download.
How to use this tool
- Drop the ZIP, or select the .shp, .dbf, .prj and .cpg files together; Load example builds a UTM park layer.
- Check the coordinate system and encoding in Settings, and turn on Simplify if you need a lighter file.
- Choose GeoJSON, CSV or KML and press Download.
- For the other direction, open the GeoJSON or CSV tab, drop the file and download the ZIP.
Example
A park layer in NAD 1983 UTM Zone 10N with three features
Alder Park polygon with a hole, first corner x 550000, y 5272000
Ring Road line, 4 vertices
Kiosk point at 551100, 5272750GeoJSON output, first corner of Alder Park
[-122.334849, 47.5994802] (WGS 84, longitude then latitude)Tips for best results
- Select the .shp, .dbf, .prj and .cpg together in one file dialog, or zip them first. Loose files are matched by their shared base name, so parcels.shp and parcels_old.dbf are not paired.
- Check the attribute table before downloading: if accented names look wrong there, change the encoding in Settings rather than fixing the exported file afterwards.
- Keep the original ZIP. Simplification and field-name shortening are not reversible in the files you download.
- One tolerance field serves both methods: Douglas-Peucker reads it as a distance in metres, Visvalingam-Whyatt as the side of a square, so a tolerance of 10 drops triangles smaller than 100 square metres.
Edge cases to watch
dBASE allows column names of 10 characters and text values of 254 bytes. Longer names are shortened and made unique, the page lists them, and longer text is cut at a character boundary.
A shapefile holds one geometry type, so a GeoJSON that mixes points, lines and polygons is written as one shapefile per type in the same ZIP.
Shapes that cross the antimeridian are not split, so a line that spans 180 degrees longitude will draw across the map in some viewers.
M values are not carried to GeoJSON, CSV or KML; heights (Z) are.
Common errors and how to fix them
- This is not a shapefile: the first four bytes are not the file code 9994
- The .shp is not an ESRI shapefile. A file with a .shp extension can also be a renamed download page or another GIS format; check how it was obtained.
- The header says the file is N bytes but fewer are present, so it may be cut off
- The .shp was truncated during a download or copy. Records before the cut are still read and converted, but the layer is incomplete, so fetch the file again.
- The coordinates look like metres but there is no .prj, so the download stays blocked
- Choose the coordinate system the data was produced in (the data's metadata or the supplier will say), or paste a proj4 string. The page does not guess, because shifted coordinates look plausible on a map.
- "No .shp file was found"
- Add the .shp itself. A .dbf alone has attributes but no shapes, and a ZIP of a folder must contain the .shp inside it.
- "The coordinate system could not be used"
- The .prj or proj4 text is not understood. Choose a listed system, or enter a proj4 string such as +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs.
Best practices
- Open the output in the desktop GIS you will use before sharing it, and compare one feature's coordinates with the source layer to confirm the reprojection.
- When you simplify for the web, keep a note of the tolerance so a later, more detailed export is comparable.
CSV and KML details
The CSV with WKT adds one wkt column after the attributes; the latitude and longitude option fills those columns only for single points and tells you how many features were left empty. A text attribute that looks like a formula, such as one starting with =, gets a leading single quote in the CSV so it arrives in a spreadsheet as text. KML escapes markup characters and removes control characters that XML cannot hold.
Frequently asked questions
Why does the converter need a .prj at all?
A shapefile stores bare numbers. The .prj says whether 550000 is metres in a UTM zone, feet in a state plane or degrees, and without it the numbers can only be guessed. Only coordinates that already fit inside longitude -180 to 180 and latitude -90 to 90 are accepted as WGS 84.
What happens to a hole that no outer ring contains?
A ring with the wrong winding or no containing outer ring is kept as its own polygon rather than dropped, and the page reports how many rings it repaired this way. Holes are matched to the smallest outer ring whose boundary box and outline contain their first point.
Does it keep the .shx index and the .sbn spatial index?
The converter reads the .shp sequentially and does not need the .shx or any spatial index. A shapefile ZIP it writes contains .shp, .shx, .dbf, .prj and .cpg.
When should I use GeoJSON to CSV or CSV to GeoJSON instead?
Use those pages when the data is already text in latitude and longitude. Come here when the source is the binary shapefile set, when the coordinates need reprojecting, or when you need a shapefile as the output.