Repository: geopandas/geopandas

Issue:
Warn when writing to Shapefile will change column names
I used gpd.to_file to save my geo dataframe object into a shapefile. However some of my column names have changed. Does anyone know why that occurred and how to fix that? I can rename the columns back to their original names but it would be good to know why that happened.

`sample_target0_ff.to_file(out_path+'shp/sample_target0_ff.shp', driver='ESRI Shapefile')
`
and the name is changed from "ignition_id" to "ignition_i" and from "pbi_grid_id" to "pbi_grid_i" 

Discussion:

Patch:
diff --git a/doc/source/io.rst b/doc/source/io.rst
index 1316d6d2..b22b0dd6 100644
--- a/doc/source/io.rst
+++ b/doc/source/io.rst
@@ -1,24 +1,32 @@
 .. _io:
 
 Reading and Writing Files
-=========================================
-
-
+=========================
 
 Reading Spatial Data
 ---------------------
 
-*geopandas* can read almost any vector-based spatial data format including ESRI shapefile, GeoJSON files and more using the command::
+*geopandas* can read almost any vector-based spatial data format including ESRI
+shapefile, GeoJSON files and more using the command::
 
     geopandas.read_file()
 
-which returns a GeoDataFrame object. (This is possible because *geopandas* makes use of the great `fiona <http://fiona.readthedocs.io/en/latest/manual.html>`_ library, which in turn makes use of a massive open-source program called `GDAL/OGR <http://www.gdal.org/>`_ designed to facilitate spatial data transformations).
+which returns a GeoDataFrame object. This is possible because *geopandas* makes
+use of the great `fiona <http://fiona.readthedocs.io/en/latest/manual.html>`_
+library, which in turn makes use of a massive open-source program called
+`GDAL/OGR <http://www.gdal.org/>`_ designed to facilitate spatial data
+transformations.
 
-Any arguments passed to :func:`geopandas.read_file` after the file name will be passed directly to ``fiona.open``, which does the actual data importation. In general, :func:`geopandas.read_file` is pretty smart and should do what you want without extra arguments, but for more help, type::
+Any arguments passed to :func:`geopandas.read_file` after the file name will be
+passed directly to ``fiona.open``, which does the actual data importation. In
+general, :func:`geopandas.read_file` is pretty smart and should do what you want
+without extra arguments, but for more help, type::
 
     import fiona; help(fiona.open)
 
-Among other things, one can explicitly set the driver (shapefile, GeoJSON) with the ``driver`` keyword, or pick a single layer from a multi-layered file with the ``layer`` keyword::
+Among other things, one can explicitly set the driver (shapefile, GeoJSON) with
+the ``driver`` keyword, or pick a single layer from a multi-layered file with
+the ``layer`` keyword::
 
     countries_gdf = geopandas.read_file("package.gpkg", layer='countries')
 
@@ -37,11 +45,13 @@ If the dataset is in a folder in the ZIP file, you have to append its name::
 
     zipfile = "zip:///Users/name/Downloads/gadm36_AFG_shp.zip!data"
 
-If there are multiple datasets in a folder in the ZIP file, you also have to specify the filename::
+If there are multiple datasets in a folder in the ZIP file, you also have to
+specify the filename::
 
     zipfile = "zip:///Users/name/Downloads/gadm36_AFG_shp.zip!data/gadm36_AFG_1.shp"
 
-It is also possible to read any file-like objects with a ``read()`` method, such as a file handler (e.g. via built-in ``open`` function) or ``StringIO``::
+It is also possible to read any file-like objects with a ``read()`` method, such
+as a file handler (e.g. via built-in ``open`` function) or ``StringIO``::
 
     filename = "test.geojson"
     file = open(filename)
@@ -53,9 +63,6 @@ You can also read path objects::
     path_object = pathlib.path(filename)
     df = geopandas.read_file(path_object)
 
-*geopandas* can also get data from a PostGIS database using the :func:`geopandas.read_postgis` command.
-
-
 Reading subsets of the data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -172,9 +179,47 @@ by using the :meth:`geopandas.GeoDataFrame.to_postgis` method.
     countries_gdf.to_file("package.gpkg", layer='countries', driver="GPKG")
     cities_gdf.to_file("package.gpkg", layer='cities', driver="GPKG")
 
-**Writing to PostGIS**::
+
+Spatial databases
+-----------------
+
+*geopandas* can also get data from a PostGIS database using the
+:func:`geopandas.read_postgis` command.
+
+Writing to PostGIS::
 
     from sqlalchemy import create_engine
     db_connection_url = "postgres://myusername:mypassword@myhost:5432/mydatabase";
     engine = create_engine(db_connection_url)
-    countries_gdf.to_postgis(name="countries_table", con=engine)
+    countries_gdf.to_postgis("countries_table", con=engine)
+
+
+Apache Parquet and Feather file formats
+---------------------------------------
+
+.. versionadded:: 0.8.0
+
+GeoPandas supports writing and reading the Apache Parquet and Feather file
+formats.
+
+`Apache Parquet <https://parquet.apache.org/>`__ is an efficient, columnar
+storage format (originating from the Hadoop ecosystem). It is a widely used
+binary file format for tabular data. The Feather file format is the on-disk
+representation of the `Apache Arrow <https://arrow.apache.org/>`__ memory
+format, an open standard for in-memory columnar data.
+
+The :func:`geopandas.read_parquet`, :func:`geopandas.read_feather`,
+:meth:`GeoDataFrame.to_parquet` and :meth:`GeoDataFrame.to_feather` methods
+enable fast roundtrip from GeoPandas to those binary file formats, preserving
+the spatial information.
+
+.. warning::
+
+    This is an initial implementation of Parquet file support and
+    associated metadata. This is tracking version 0.1.0 of the metadata
+    specification at:
+    https://github.com/geopandas/geo-arrow-spec
+
+    This metadata specification does not yet make stability promises. As such,
+    we do not yet recommend using this in a production setting unless you are
+    able to rewrite your Parquet or Feather files.
diff --git a/geopandas/io/file.py b/geopandas/io/file.py
index 04a1b680..47e938ba 100644
--- a/geopandas/io/file.py
+++ b/geopandas/io/file.py
@@ -1,6 +1,7 @@
 from distutils.version import LooseVersion
 
 import io
+import warnings
 import numpy as np
 import pandas as pd
 
@@ -241,6 +242,14 @@ def _to_file(
         crs = pyproj.CRS.from_user_input(crs)
     else:
         crs = df.crs
+
+    if driver == "ESRI Shapefile" and any([len(c) > 10 for c in df.columns.tolist()]):
+        warnings.warn(
+            "Column names longer than 10 characters will be truncated when saved to "
+            "ESRI Shapefile.",
+            stacklevel=3,
+        )
+
     with fiona_env():
         crs_wkt = None
         try:


Test patch:
diff --git a/geopandas/io/tests/test_file.py b/geopandas/io/tests/test_file.py
index 8207d32a..d7b1b5ea 100644
--- a/geopandas/io/tests/test_file.py
+++ b/geopandas/io/tests/test_file.py
@@ -243,6 +243,22 @@ def test_to_file_schema(tmpdir, df_nybb):
     assert result_schema == schema
 
 
+def test_to_file_column_len(tmpdir, df_points):
+    """
+    Ensure that a warning about truncation is given when a geodataframe with
+    column names longer than 10 characters is saved to shapefile
+    """
+    tempfilename = os.path.join(str(tmpdir), "test.shp")
+
+    df = df_points.iloc[:1].copy()
+    df["0123456789A"] = ["the column name is 11 characters"]
+
+    with pytest.warns(
+        UserWarning, match="Column names longer than 10 characters will be truncated"
+    ):
+        df.to_file(tempfilename, driver="ESRI Shapefile")
+
+
 @pytest.mark.parametrize("driver,ext", driver_ext_pairs)
 def test_append_file(tmpdir, df_nybb, df_null, driver, ext):
     """ Test to_file with append mode and from_file """