【问题标题】:How to clip a shapefile to a bounding box?如何将 shapefile 剪辑到边界框?
【发布时间】:2014-09-03 16:45:00
【问题描述】:

关于如何将this shapefile 剪辑到适当的边界框有什么建议吗?特别是,我只想查看这些界限:[(-105.53 , 39.9) (-104.93,40.27)]。 site for ogr2ogr 有一个使用 -clipdst 选项的示例,看起来很有希望。我使用Anaconda 来管理我的python 安装。我已经安装了 GDAL,这样conda update gdal 会产生:

Fetching package metadata: ..
# All requested packages already installed.
# packages in environment at /Users/<me>/anaconda:
#
gdal                      1.10.1               np18py27_2

运行which ogr2ogr

ogr2ogr is /Users/<me>/anaconda/bin/ogr2ogr

下载并解压缩 Natural Earth 子单元文件后,我运行以下命令:

ogr2ogr -f GeoJSON -clipdst -105.53 39.9 -104.93 40.27 places.json ne_10m_admin_0_map_subunits.shp

很遗憾,我收到了这个错误:

ERROR 6: GEOS support not enabled.

我查看了这个错误,建议here 是启用geos(我使用conda install geos 安装的一个包)。所以我有geos 3.3.3 版。但是,我不知道如何启用 ogr2ogr 访问 geos 库。

非常感谢任何帮助。我不打算使用ogr2ogr,但我没有看到很多替代方案。


更新:2015-02-26

重新安装 anaconda 后,我安装了 gdal 和 geos。这是目前的情况:

$ ogr2ogr -f GeoJSON -clipdst -105.53 39.9 -104.93 40.27 places.json ne_10m_admin_0_map_subunits.shp

FAILURE:
Unable to open datasource `ne_10m_admin_0_map_subunits.shp' with the following drivers.
  -> ESRI Shapefile
  -> MapInfo File
  -> UK .NTF
  -> SDTS
  -> TIGER
  -> S57
  -> DGN
  -> VRT
  -> REC
  -> Memory
  -> BNA
  -> CSV
  -> GML
  -> GPX
  -> KML
  -> GeoJSON
  -> GMT
  -> GPKG
  -> SQLite
  -> WAsP
  -> PostgreSQL
  -> PCIDSK
  -> OpenFileGDB
  -> XPlane
  -> AVCBin
  -> AVCE00
  -> DXF
  -> Geoconcept
  -> GeoRSS
  -> GPSTrackMaker
  -> VFK
  -> PGDump
  -> OSM
  -> GPSBabel
  -> SUA
  -> OpenAir
  -> PDS
  -> WFS
  -> HTF
  -> AeronavFAA
  -> EDIGEO
  -> GFT
  -> GME
  -> SVG
  -> CouchDB
  -> Idrisi
  -> ARCGEN
  -> SEGUKOOA
  -> SEGY
  -> ODS
  -> XLSX
  -> ElasticSearch
  -> PDF
  -> CartoDB
  -> SXF

【问题讨论】:

  • 您需要使用 GEOS 编译 GDAL。如果 Anaconda 没有这个,那么询问他们的用户列表为什么会这样,在别处寻找不同的预编译包,或者自己编译。
  • 你解决过这个问题吗?
  • @vitale232 - 还没有。请参阅上面的更新。
  • @simplyclimb 你在运行什么操作系统?我只是尝试创建一个带有 GEOS 对 linux-64 支持的 conda 包。我很好奇它是否会为您解决问题。
  • @vitale232 - OS X 10.9.5

标签: anaconda shapefile ogr geos


【解决方案1】:

我遇到了同样的问题并找到了解决方案。解决方案是您必须在系统上安装 qt 库。安装 qt rpm 包后,安装 geos 并使用 --with-geos 选项重新安装 gdal。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    • 2018-03-16
    相关资源
    最近更新 更多