A colleague once sent me a Shapefile of village names for a regional development project. I opened the attribute table, and found a column that read, from top to bottom, “München”, “Zürich”, “Córdoba” and a long procession of question marks where whole names should have been. The sender was baffled. “It looks fine on my computer,” he said, which was true, and was the whole problem. His computer and mine disagreed about how to interpret the same bytes in the same file. Three weeks later, the same project produced a second, more expensive discovery: a column called “Population” that held the 2020 census, and another called “Population” that was supposed to hold the 2021 projection. The two had started life as “Population_2020” and “Population_2021”, and the Shapefile format had cut both names to ten characters, leaving two columns with identical names, one of which the software quietly renamed and the other of which it silently confused.
Neither of these is a bug. Both are consequences of a format that was designed in the early 1990s, for the hardware, languages and expectations of that time, and that, more than thirty years later, remains the most widely exchanged vector format in the world. The Shapefile is everywhere, and its limitations are well known and entirely predictable. In this guide I’ll explain every important limit, show how text encoding works (and why it goes wrong), give you step-by-step diagnosis and repair for the most common symptoms, and set out the practices that let you use Shapefiles safely when you must, and avoid them when you can.
This article is a deep dive into the eighth item of Top 10 Most Common GIS Errors and How to Fix Them, and a companion to Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?

What a Shapefile Actually Is
A “Shapefile” is not one file but a set of files that share a base name. All of them must stay together.
| File | Role | Required? |
|---|---|---|
.shp | The geometry | Yes |
.shx | An index of the geometry | Yes |
.dbf | The attribute table, in the old dBase format | Yes |
.prj | The coordinate reference system, as text | Strongly recommended |
.cpg | The character encoding of the .dbf | Strongly recommended |
.sbn, .sbx | A spatial index used by some software | Optional |
.qix | A spatial index used by GDAL and some map servers | Optional |
.xml | Metadata | Optional |
The geometry and the attributes live in separate files, linked by the order of the records. The .dbf, which gives the format both its attribute handling and many of its limits, is a dBase file, a format from the 1980s. Most of the field limits of Shapefiles are really dBase limits.
The Limitations, One by One
1. Field names are limited to 10 characters
A dBase field name has at most ten characters. Longer names are truncated, which is the origin of cryptic column names across the world. The harm comes from collisions: when two long names share the same first ten characters, they truncate to the same name.
| Original name | Truncated to 10 characters |
|---|---|
| Population_2020 | Population |
| Population_2021 | Population |
| Population_density | Population |
| Land_use_class | Land_use_cl |
| Land_use_code | Land_use_co |
Software handles collisions differently. GDAL, for example, “launders” field names, shortening them and adding numbers to keep them unique, such as Populatio0 and Populatio1, and warns you. Others may silently drop or overwrite a column. The original meaning is lost. If you only have the truncated file, you can’t recover the full names, except from documentation.
Also, field names with spaces, accents or special characters can behave unpredictably, and are best avoided.
2. Text fields are limited to 254 characters
A text field holds a maximum of 254 characters. Longer strings are truncated without warning. Descriptions, notes, long names and addresses are often damaged this way.
3. Encoding is not stored reliably
The .dbf file does not reliably declare how its text is encoded. This is the source of most “strange characters” problems, and we’ll give it its own section below.
4. Limited and awkward data types
- No true date-time: there is a date type, but no time of day. Date-times are stored as text, or lose their time part.
- No true NULL for numbers: an empty numeric value may be stored as zero, a blank, a row of asterisks or a special value, depending on the software. Zero and “unknown” become indistinguishable.
- Integer limits: integers are limited in width (they are normally 32-bit in effect), and larger identifiers can overflow or be stored as decimal numbers.
- Floating point precision is limited by the declared field width and number of decimals, so values can be rounded.
- Boolean and other modern types are poorly supported.
- No lists, arrays, JSON or binary data.
5. A limit of about 255 fields
The dBase format supports roughly 255 fields, which wide tables can exceed.
6. A 2 GB limit
The .shp and .dbf files can each be about 2 GB at most, a limit set by the 32-bit file offsets of the format. Software that writes beyond it produces files that many programs can’t read. Very large datasets, such as national building footprints, hit this limit.
7. One geometry type per file
A Shapefile holds points, lines or polygons (or multipoints), but not a mixture. A dataset with several geometry types must be split into several Shapefiles. Z and M variants exist, but not every tool supports them well. True curves aren’t supported and are converted to straight segments.
8. No multiple layers, no relationships, no topology, no rules
One dataset is one set of files. A project with fifty layers becomes a folder of hundreds of files. There are no domains, relationship classes, subtypes, topology rules or attribute constraints, which is why Shapefiles are easy to corrupt with bad data. See Fixing Topology Errors and Overlaps.
9. A fragile bundle
Rename, lose or replace any of the files, and the dataset breaks, or worse, appears to work but is wrong. A .dbf that has the wrong number of records for the .shp is a common silent disaster.
10. Weak coordinate system handling
The CRS is stored as a .prj text file in a particular flavor of WKT. It may lack an authority code, and some software cannot match it exactly to a standard EPSG definition. If the .prj is missing, the CRS is unknown. See Missing or Unknown Projection: How to Fix It.
11. Limited metadata and no spatial index guarantee
Rich metadata and indexes aren’t part of the core format. Performance on big files depends on optional extra files and the software’s behavior.
12. File naming limits in practice
Long file names with spaces, accents and special characters are legal in modern systems, but can be troublesome for old software, web uploads and scripts. Case sensitivity on some systems (.SHP versus .shp) can stop tools from finding components.
The alternative
Most of these limits vanish with a modern format. GeoPackage supports long field names, UTF-8, many data types including dates and times, true NULLs, multiple layers in one file, very large sizes and built-in spatial indexes. See Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?
Understanding Text Encoding
To fix encoding problems, you need to understand them. It isn’t hard.
Computers store bytes, not letters
A text file is a sequence of bytes. An encoding is the table that says which byte (or bytes) stands for which character. If you read bytes with a different table from the one used to write them, you see the wrong characters.
The main encodings you will meet
- ASCII: the original encoding, with 128 characters (English letters, digits, punctuation). It can’t represent accents.
- Legacy code pages (single-byte): extensions of ASCII for particular languages, using 256 values. For example ISO-8859-1 (Latin-1) and Windows-1252 for Western European languages, ISO-8859-15 (adds the euro sign), Windows-1251 for Cyrillic, Windows-1256 for Arabic, and many others. In each, the same byte means a different letter. The byte for “é” in Latin-1 is the same as in Windows-1252, but the byte used for an Arabic letter in one table means a Cyrillic or Greek letter in another.
- Multi-byte legacy encodings for East Asian languages, such as Shift_JIS, GBK and Big5.
- UTF-8: the universal encoding, which can represent every character in every language, using one to four bytes per character. It is the modern standard, the default of the web, and the recommended encoding for all new data.
How a Shapefile declares its encoding
A .dbf can declare its encoding in two ways, both unreliable:
- A “language driver ID” byte in the file header, which indicates a code page. Old and limited, and not universally honored.
- A
.cpgfile, a tiny text file whose content is the encoding name, such asUTF-8orISO-8859-1(some software writes numbers such as1252).
If neither is present, software guesses, usually using the computer’s default code page, or UTF-8, depending on the program. Two programs may guess differently, which is why “it looks fine on my computer.”
What goes wrong
- The data is in encoding A, but read as encoding B. The text is wrongly displayed, but the bytes are intact. This is recoverable: choose the right encoding.
- The data was converted to an encoding that can’t represent some characters. Those characters were replaced by
?when written. This is permanent loss. The original characters are gone from the file. - Double conversion: text converted twice, or interpreted at one stage and saved again, producing a mess that sometimes can be reversed.
Recognizing the Symptoms
| What you see | Example | What it usually means |
|---|---|---|
| Pairs of odd characters in place of accented letters | “Café” for “Café” | UTF-8 text read as Latin-1 or Windows-1252. Recoverable: set the encoding to UTF-8 |
| Accented letters turn into a different, wrong letter, but consistently | “Ú” instead of “é” | A text file in one legacy code page read in another. Recoverable: try other code pages |
| Black diamonds with question marks | “Caf�” | A byte that is invalid in the encoding used to read. The source encoding is probably a legacy one, read as UTF-8 |
| Literal question marks in the text | “Caf?” or “???” | Characters that couldn’t be represented were replaced when the file was written. Probably unrecoverable from this file |
| Entire words of question marks in non-Latin scripts | Arabic, Cyrillic, Chinese or Greek names shown as “???????” | The file was written in a code page that does not contain these letters. Permanent loss |
| Squares, boxes or missing glyphs | Small rectangles | A font that lacks the characters. The data may be fine. Change the font |
| Names fine in one program, garbled in another | The programs guess the encoding differently. Declare it explicitly with a .cpg | |
| Column names garbled | Encoding of field names, or unsupported characters in the names | |
| Text cut at a fixed length | The 254-character limit, not encoding |
Diagnosing an Encoding Problem
Step 1: Look for a .cpg file
If there is a .cpg, open it with a text editor. It names the encoding the file claims. It may be wrong, but it is the first clue. If it is missing, that is probably why.
Step 2: Try the encoding setting in your software
- QGIS: open the layer’s properties, go to the Source tab, and change the Data source encoding. Try UTF-8 first. Then ISO-8859-1 or Windows-1252 for Western European languages. Watch how the attribute table changes. The correct encoding makes all the text look right.
- ArcGIS Pro: the behavior depends on the version and settings. Recent versions generally write and read Shapefiles with UTF-8 when a
.cpgsays so, and fall back on a system code page otherwise. If text is wrong, check the.cpgand, if needed, convert the data to a geodatabase or GeoPackage after setting the right encoding on import. - GeoPandas:
import geopandas as gpd
for enc in ["utf-8", "cp1252", "latin-1", "cp1256", "cp1251"]:
try:
gdf = gpd.read_file("places.shp", encoding=enc)
print(enc, "->", gdf["name"].head(3).tolist())
except Exception as e:
print(enc, "failed:", e)- GDAL: the
SHAPE_ENCODINGconfiguration option tells GDAL how to interpret the.dbf:
ogr2ogr -f GPKG places.gpkg places.shp --config SHAPE_ENCODING CP1252Setting it to an empty value disables recoding, which reads the raw bytes as-is.
Step 3: See the raw bytes, to tell “wrong table” from “information lost”
A neat trick is to read the file with Latin-1, an encoding that can decode any byte without error, so you can see the raw bytes as characters:
import geopandas as gpd
gdf = gpd.read_file("places.shp", encoding="latin-1")
print(gdf["name"].head(5).map(repr))What you see tells you what is in the file.
- Pairs like “é” or “ü”: the file contains UTF-8 bytes. Read it as UTF-8.
- Plausible letters in a single-byte code page, such as “é” for a Western European file: it is a legacy code page, probably Windows-1252 or Latin-1.
- Literal
?characters: the characters were already replaced in the file. The original text is gone. - Letters of an unexpected alphabet: a code page for another language, such as Windows-1251 (Cyrillic), Windows-1256 (Arabic) or a multi-byte one. Try the plausible candidates for the data’s origin.
Step 4: Think about where the data came from
The origin points to the likely encoding. Data from a Western European office using older software: Windows-1252 or ISO-8859-1. Data from a Russian or Eastern European source: Windows-1251 or a related one. Data exported by QGIS or modern software: probably UTF-8 with a .cpg. Ask the provider.
Fixing Encoding Problems
Case 1: The text is intact, and was read with the wrong encoding
This is the happy case. Tell the software the correct encoding, and save the data properly.
- QGIS: set the Data source encoding to the right one, verify the text, and then export the layer (Export > Save Features As) to a GeoPackage, or to a new Shapefile with the encoding set to UTF-8, so that QGIS writes a
.cpg. - GDAL:
# Read the DBF as Windows-1252, and write a UTF-8 GeoPackage
ogr2ogr -f GPKG fixed.gpkg places.shp --config SHAPE_ENCODING CP1252
# Or, write a new Shapefile with UTF-8 (and a .cpg file)
ogr2ogr -f "ESRI Shapefile" fixed.shp places.shp --config SHAPE_ENCODING CP1252 -lco ENCODING=UTF-8- GeoPandas:
gdf = gpd.read_file("places.shp", encoding="cp1252")
gdf.to_file("places_utf8.gpkg", driver="GPKG")- Add a
.cpgfile by hand when you are sure that the data is UTF-8: create a plain text file with the same base name as the Shapefile and the extension.cpg, and writeUTF-8in it. This tells software how to read it. (This only declares the encoding. It doesn’t convert anything, so it is right only if the data really is UTF-8.)
Case 2: Strings are “double-encoded”
If the text has been decoded wrongly and saved, you may see “Café” stored as real characters (not just a display problem). You can often reverse it in Python:
broken = "Café Münster"
fixed = broken.encode("latin-1").decode("utf-8")
print(fixed) # Café Münster
# Apply to a whole column
gdf["name"] = gdf["name"].apply(lambda s: s.encode("latin-1").decode("utf-8") if isinstance(s, str) else s)Test on a few values first. If a string can’t be encoded back (an exception occurs), it wasn’t broken in this way, and you should leave it alone, so wrap the conversion in try and except.
Case 3: Question marks: the information is gone
If the file contains literal ? where letters should be, the file itself has lost the information. No setting will bring it back. Your options:
- Find the original source: the database, the spreadsheet, the previous version, the provider, a backup.
- Re-join the text from another source using a stable key, such as an ID, a code or a coordinate. For example, an official gazetteer, an open data table or the original CSV.
- Reconstruct manually for a small number of values.
- Ask the provider to re-export with UTF-8, or in GeoPackage, and explain the problem.
- Document the loss in the metadata, so nobody builds on corrupted names.
The lesson: a single conversion to a limited code page destroys the characters it can’t represent. Never save multilingual data in a legacy encoding.
Case 4: Garbled field names
Field names are even more limited than values. Non-ASCII characters in names may not survive. Rename fields to plain ASCII, such as nom, name_ar_latin, or pop_2020, and keep the descriptive version in a data dictionary or as an alias (QGIS and ArcGIS both support field aliases).
Fixing Field-Name Problems
Prevent truncation by planning the names
When you must deliver a Shapefile, design the field names before export so that they are unique within the first ten characters and meaningful:
| Descriptive name | Short name for the Shapefile |
|---|---|
| Population_2020 | pop_2020 |
| Population_2021 | pop_2021 |
| Population_density | pop_dens |
| Land_use_classification | lu_class |
| Land_use_code | lu_code |
| Date_of_last_inspection | insp_date |
Then provide a data dictionary that maps every short name to its full name, meaning, type and units. See Metadata in GIS: Why It Matters and How to Create It and Understanding Spatial Data Types and Attributes.
Rename in QGIS
Use Refactor fields (Processing) to rename, retype and reorder fields in one step, writing a clean output. Or rename in the layer’s Fields tab. You can also use field aliases for display.
Rename with GDAL’s SQL
ogr2ogr -f "ESRI Shapefile" out.shp in.gpkg -dialect SQLite \
-sql "SELECT Population_2020 AS pop_2020, Population_2021 AS pop_2021, geom FROM places"(The geometry column’s name depends on the format and driver. Adjust it, or check with ogrinfo.)
Rename in Python
import json
import geopandas as gpd
gdf = gpd.read_file("places.gpkg")
mapping = {
"Population_2020": "pop_2020",
"Population_2021": "pop_2021",
"Population_density": "pop_dens",
}
assert all(len(v) <= 10 for v in mapping.values()), "A name exceeds 10 characters"
assert len(set(mapping.values())) == len(mapping), "Short names are not unique"
gdf = gdf.rename(columns=mapping)
gdf.to_file("places.shp", encoding="utf-8")
# Keep the mapping as documentation next to the data
with open("places_fields.json", "w", encoding="utf-8") as f:
json.dump(mapping, f, ensure_ascii=False, indent=2)Recovering from already truncated names
If a Shapefile arrives with truncated or collided names, look for:
- The original data from before the export.
- Documentation or metadata that lists the full names.
- An accompanying
.xmlfile with a field description. - The provider.
Without these, the best you can do is deduce the meaning from the values, and record your conclusions as uncertain.
Fixing Other Limitation Problems
Text longer than 254 characters (truncated)
- Prevention: don’t use Shapefile for long text. Use GeoPackage.
- If you must deliver a Shapefile, split the text across several fields, or deliver the long text in a separate table, linked by an ID.
- For data already truncated, go back to the original source.
Dates and times
- Dates are supported. Times are not. Store the date in a date field, and the time in a separate text field, or deliver a table. In ISO 8601 text (
2025-03-04T14:30:00Z), a text field keeps the full precision and sorts correctly. - Check how your software exports date-time columns, since it may drop the time, or fail.
NULL values
- Numeric NULLs are unreliable. Decide on a documented convention, and tell the recipient. For example, a NoData value such as
-9999for numbers, and an empty string for text, and write it in the metadata. A cleaner solution is to deliver a GeoPackage, which supports real NULLs. - Never let NULL silently become 0 in statistics. A pipe whose diameter is unknown is not a pipe of zero millimeters.
Big integers and identifiers
- Long identifiers (such as national IDs with many digits) should be stored as text, which also preserves leading zeros.
- 64-bit integers may be stored as decimals, or fail. Use text for identifiers.
Too many fields
Split the table, or move to a format without the limit.
Files over 2 GB
- Symptoms: write errors, truncated files, or outputs that other software can’t open.
- Fixes: convert to GeoPackage or a geodatabase, or split the dataset (by region or by attribute) into several smaller Shapefiles. GDAL has a layer creation option to control the 2 GB behavior, but files beyond the limit are not portable, so avoid them.
# Convert a huge Shapefile to a GeoPackage
ogr2ogr -f GPKG big.gpkg big.shp -nln buildingsMixed geometry types
Split by geometry type, for example with an attribute filter or a tool that separates points, lines and polygons. Or store the data in a format that allows mixed types, or in separate layers of a GeoPackage.
Missing, mismatched or partly copied components
- Missing
.shx: GDAL can rebuild it withSHAPE_RESTORE_SHX=YES. See Lock Files and Corrupted Geodatabases: Recovery Guide. - Missing
.dbf: the attributes are lost, unless a backup exists. - Missing
.prj: see Missing or Unknown Projection: How to Fix It. - Mismatched record counts: re-obtain a consistent set from the source.
- Always send all components, zipped into a single archive.
Case sensitivity and naming
Make file names consistent in case (preferably lowercase), and avoid spaces and special characters, especially for files that will be served by web servers, used in scripts or opened on different operating systems.
A Worked Example: Village Names Full of Question Marks
Problem: a Shapefile of village names, supplied by a regional office, shows Latin names with weird pairs of characters, and Greek names as rows of question marks.
- Look for the
.cpg: there is none. The.dbfheader declares no clear encoding. - Read with Latin-1 and print the raw values with
repr. The Latin names show “é” sequences, which is the signature of UTF-8 bytes read as a single-byte code page. But in the Greek name column, the values are literal question marks:'?????? ????'. - Diagnosis: two different things are going on.
- The Latin names are intact UTF-8, read in the wrong encoding. Recoverable.
- The Greek names contain literal
?, so they were damaged before or during an earlier export, when the data was converted to a code page without Greek letters. Not recoverable from this file.
- Fix the recoverable part: read the file as UTF-8, verify that the Latin names look right, and export the layer to a GeoPackage.
- Handle the unrecoverable part: ask the regional office for the original source. They have the original Greek names in a database, with village codes. Export a table (CSV in UTF-8) with the code and the Greek name.
- Re-join the Greek names to the GeoPackage using the village code as the key. Check a sample against a trusted gazetteer.
- Document: in the metadata, record that the Greek names were restored from the original database on a given date, and the encoding of all text is UTF-8.
- Prevent: send the regional office the guidance below, so that future exports are in UTF-8 or GeoPackage.
Without understanding the difference between “wrong table” and “information lost”, you could spend days trying encodings that can never work.
Best Practices
When you receive a Shapefile
- Check that all components are there (
.shp,.shx,.dbf,.prj, ideally.cpg). - Check the CRS and the extent.
- Check the text: look at the attribute table for strange characters, and test the encoding.
- Check field names for truncation, and read any documentation.
- Check the number of features against the delivery note.
- Convert to GeoPackage straight away for your own work, with the encoding set properly, and keep the original untouched.
- Report problems to the provider.
When you deliver a Shapefile
- Prefer GeoPackage where the recipient can use it. Offer a Shapefile only if they ask.
- Use UTF-8 encoding, with a
.cpgfile that says so. - Use short, unique, plain-ASCII field names (10 characters or fewer), and no spaces.
- Provide a data dictionary mapping every field to its full name, meaning, type and units.
- Include the
.prj, and state the EPSG code in the documentation. - Keep text under 254 characters, and handle long text separately.
- State the NULL convention for numbers.
- Don’t exceed 2 GB. Split if necessary.
- One geometry type per file.
- Zip all the components into one archive with a clear name, using only simple characters.
- Validate geometry before export. See How to Fix Invalid Geometry Errors.
- Test the delivery: open it in a different program, and on a different computer.
- Add metadata: source, date, CRS, encoding, field list and license. See Metadata in GIS: Why It Matters and How to Create It.
In your own workflow
- Use GeoPackage as your working and archive format. See Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?
- Convert to Shapefile only at the end, for delivery, never as the master.
- Never use a Shapefile as the only copy of important multilingual data.
- Standardize encoding on UTF-8 across your organization, in databases, spreadsheets and exports.
- When working with spreadsheets, save CSV files as UTF-8, and be careful with software that opens them in a legacy code page. See Python for GIS: Getting Started for reading CSVs with an explicit encoding.
- Automate checks for missing components, encoding problems, truncated names and size limits. See Geospatial Development & Automation: The Ultimate Guide.
Quick Reference: Symptom, Cause, Fix
| Symptom | Cause | Fix |
|---|---|---|
| “é” instead of “é” | UTF-8 read as Latin-1 | Set the encoding to UTF-8, or add a .cpg with UTF-8 |
| Wrong but consistent letters | Wrong legacy code page | Try other code pages, then export as UTF-8 |
Literal ? where letters should be | Characters lost in an earlier conversion | Retrieve the original, re-join from another source |
| Black diamonds “�” | Invalid bytes for the encoding used to read | Try a legacy encoding such as Windows-1252 |
Two columns with the same name, or Populatio0 | 10-character truncation | Rename before export, and use a data dictionary |
| Text ends abruptly at 254 characters | dBase text length limit | Use GeoPackage, or split the text |
| Date shows no time | No date-time type | Store time separately, or in text, or use GeoPackage |
| Numbers show 0 for unknown values | No real NULL | Define a NoData convention, or use GeoPackage |
| Cannot write or open a large file | 2 GB limit | Convert to GeoPackage, or split |
| Error mixing points and polygons | One geometry type per file | Split by type |
| “Cannot open”, missing files | Components missing or renamed | Obtain all components, rebuild .shx if needed |
| Layer has unknown CRS | Missing .prj | See Missing or Unknown Projection: How to Fix It |
Common Mistakes
- Treating a question mark as an encoding problem, when the information is already gone.
- Assuming that “it looks fine on my computer” means that the file is correct.
- Saving multilingual data in a legacy encoding.
- Creating a
.cpgfile that declares an encoding the data isn’t in. - Letting software truncate field names without checking for collisions.
- Using Shapefile as the master format.
- Emailing only the
.shp. - Ignoring warnings about launder or truncated names.
- Exceeding 254 characters and not noticing the truncation.
- Treating NULL and zero as the same.
- Using accents, spaces and special characters in field names and file names.
- Not providing a data dictionary.
- Overwriting the original with a “converted” version.
- Not testing the delivered file in another program.
Final Thoughts
I have a soft spot for the Shapefile. It carried a generation of GIS through the era when exchanging data meant exchanging floppy disks, and it is still a polite lingua franca between systems that otherwise can’t talk. But it is a format with a past, and the cheapest way to avoid its problems is to treat it as a delivery format and not a home. Work in GeoPackage, store your text in UTF-8, keep names short and documented when you must export, and never trust a file that you haven’t opened somewhere else.
And when you meet a column of question marks, remember the distinction that matters most in this whole guide: garbled characters can usually be rescued, and question marks can’t. Knowing which one you have saves days.
Pick one Shapefile that you rely on. Check its .cpg, its field names, its text lengths and its size. If anything surprises you, convert it to a GeoPackage today, set the encoding properly, and write its data dictionary. You will have taken the most important step this guide can offer.
Where to go next: review the whole series in Top 10 Most Common GIS Errors and How to Fix Them, and the format comparison in Shapefile vs. GeoJSON vs. GeoPackage: Which Format to Use?



