Почему геопандаж.read_file возвращает разные результаты для Windows и Linux? - PullRequest
0 голосов
/ 14 февраля 2019

Я использую геопанды для чтения файла .shp.Мой код выглядит следующим образом:

import geopandas as gpd

blocks = gpd.read_file('shp/block_shp/block.shp', encoding = 'utf-8')
print(blocks.columns)

На моем компьютере с ОС Windows выходные данные (столбцы информационного кадра геопанды) таковы:

Index(['ID', 'AREA', 'ID1', 'AREA1', 'NAME', 'DISTRICT', 'BLOCK_ID','geometry'],
  dtype='object')

Я скопировал тот же код ипапку с файлом .shp на машине linux (centos 7) и запустите код.Нет ошибок или предупреждений, но результат печати отличается:

Index(['geometry'], dtype='object')

Он получает только последний столбец geometry и пропускает все остальные столбцы.Процесс чтения намного быстрее, чем в Windows, и мне интересно, пропустил ли он эти столбцы во время чтения.В зависимости от версии пакетов на машине Windows:

pip show show GDAL fiona rtree pyproj shapely geopandas

Name: GDAL
Version: 2.3.3
Summary: GDAL: Geospatial Data Abstraction Library
Home-page: http://www.gdal.org
Author: Frank Warmerdam
Author-email: warmerdam@pobox.com
License: MIT
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires:
Required-by:
---
Name: Fiona
Version: 1.8.4
Summary: Fiona reads and writes spatial data files
Home-page: http://github.com/Toblerity/Fiona
Author: Sean Gillies
Author-email: sean.gillies@gmail.com
License: BSD
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires: attrs, munch, click, click-plugins, cligj, six
Required-by:
---
Name: Rtree
Version: 0.8.3
Summary: R-Tree spatial index for Python GIS
Home-page: http://toblerity.github.com/rtree/
Author: Sean Gillies
Author-email: sean.gillies@gmail.com
License: LGPL
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires: setuptools
Required-by:
---
Name: pyproj
Version: 1.9.6
Summary: Python interface to PROJ.4 library
Home-page: https://github.com/jswhit/pyproj
Author: Jeff Whitaker
Author-email: jeffrey.s.whitaker@noaa.gov
License: OSI Approved
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires:
Required-by: geopandas
---
Name: Shapely
Version: 1.6.4.post1
Summary: Geometric objects, predicates, and operations
Home-page: https://github.com/Toblerity/Shapely
Author: Sean Gillies
Author-email: sean.gillies@gmail.com
License: BSD
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires:
Required-by:
---
Name: geopandas
Version: 0.4.0
Summary: Geographic pandas extensions
Home-page: http://geopandas.org
Author: GeoPandas contributors
Author-email: kjordahl@alum.mit.edu
License: BSD
Location: c:\users\lenovo\anaconda3\lib\site-packages
Requires: fiona, pyproj, shapely, pandas
Required-by:

И версия пакетов на Linux:

pip3 show GDAL fiona rtree pyproj shapely geopandas

Name: GDAL
Version: 2.3.3
Summary: GDAL: Geospatial Data Abstraction Library
Home-page: http://www.gdal.org
Author: Frank Warmerdam
Author-email: warmerdam@pobox.com
License: MIT
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by:
---
Name: Fiona
Version: 1.8.4
Summary: Fiona reads and writes spatial data files
Home-page: http://github.com/Toblerity/Fiona
Author: Sean Gillies
Author-email: sean.gillies@gmail.com
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires: six, munch, cligj, click-plugins, attrs, click
Required-by:
---
Name: Rtree
Version: 0.8.3
Summary: R-Tree spatial index for Python GIS
Home-page: http://toblerity.github.com/rtree/
Author: Howard Butler
Author-email: hobu@hobu.net
License: LGPL
Location: /usr/local/lib/python3.6/site-packages
Requires: setuptools
Required-by:
---
Name: pyproj
Version: 1.9.6
Summary: Python interface to PROJ.4 library
Home-page: https://github.com/jswhit/pyproj
Author: Jeff Whitaker
Author-email: jeffrey.s.whitaker@noaa.gov
License: OSI Approved
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by: geopandas
---
Name: Shapely
Version: 1.6.4
Summary: Geometric objects, predicates, and operations
Home-page: https://github.com/Toblerity/Shapely
Author: Sean Gillies
Author-email: sean.gillies@gmail.com
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by:
---
Name: geopandas
Version: 0.4.0
Summary: Geographic pandas extensions
Home-page: http://geopandas.org
Author: GeoPandas contributors
Author-email: kjordahl@alum.mit.edu
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires: pandas, shapely, fiona, pyproj
Required-by:

Я не знаю, почему это произошло.Может кто-нибудь сказать мне, как решить эту проблему?Спасибо за ваше внимание.

Результат выполнения fio info --indent 2 path_to_shp дает разные результаты:

windows:

{
  "driver": "ESRI Shapefile",
  "schema": {
    "properties": {
      "ID": "int:10",
      "AREA": "float:10.2",
      "ID1": "int:10",
      "AREA1": "float:10.6",
      "NAME": "str:16",
      "DISTRICT": "str:16",
      "BLOCK_ID": "int:8"
    },
    "geometry": "Polygon"
  },
  "crs": "EPSG:4326",
  "crs_wkt": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]",
  "bounds": [
    113.75219,
    22.447622,
    114.6233,
    22.86469
  ],
  "name": "block",
  "count": 74
}

linux:

{
  "driver": "ESRI Shapefile",
  "schema": {
    "properties": {},
    "geometry": "Polygon"
  },
  "crs": "EPSG:4326",
  "crs_wkt": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY,AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.HORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]",
  "bounds": [
    113.75219,
    22.447622,
    114.6233,
    22.86469
  ],
  "name": "block",
  "count": 74
}

И я уверен, что все остальные файлы (.DBF, .prj, .shx и .geojson) в папке с файлом .shp одинаковы.

...