zoukankan      html  css  js  c++  java
  • OGR – Merging Multiple SHP files

    So I have 25 shapefiles with data for 25 counties, and I want to merge them all into one shapefile.

    Using OGR, you can merge 2 files like this:

    ogr2ogr merge.shp file1.shp
    ogr2ogr -update -append merged.shp file2.shp -nln merge

    You create a new shapefile merged and copy the contents of file1 into the new shapefile. Then you append the contents of file2 to the newly created shapefile and name it merged.

    What do you do if you don’t want to do this 25 times ?

    On page 22 of this document (Using GDAL / OGR for Data Processing and Analysis) is a Python script for doing this. But I couldn’t get the Python bindings for GDAL to work. The errors were always with importing _gdal which I understand is the gdal dll and references to _gdal are created by SWIG. I don’t care about the script. I can write my own. But I would like to get GDAL(OGR) working from Python.

    So after giving up on this concept temporarily, I resorted to Windows scripting, as modified from this page:

    as above, use: ogr2ogr merge.shp file1.shp to create a shapefile mergecontaining the data of file1

    then:

    for %f in (*.shp) do (
    ogr2ogr -update -append merge.shp %f  -f “esri shapefile” -nln merge )
    That worked.

  • 相关阅读:
    day29 作业
    day 29 线程
    day28 进程
    day27 服务端 和客户端
    day26 作业
    day26 网络编程
    java基础 反射
    python 计时
    mongodb 批量插入唯一索引冲突
    js hook
  • 原文地址:https://www.cnblogs.com/mfryf/p/3556460.html
Copyright © 2011-2022 走看看