¿Dividir o guardar un subconjunto de un archivo SHP de forma ESRI en un nuevo archivo?

StackOverflow https://stackoverflow.com/questions/3016682

  •  26-09-2019
  •  | 
  •  

Pregunta

Estoy trabajando con archivos de forma en Geodjango. En este momento estoy tratando de escribir una prueba para el código que se carga en un archivo de forma y lo guarda en una base de datos. El archivo de forma actualmente tiene un recuento de características de 64,118. Me gustaría reducir esto a un puñado para que la prueba pueda cargarlo rápidamente y confirmar que todo está bien.

Dado que los archivos de forma no están en formato de texto, ¿hay una aplicación o biblioteca gratuita que pueda usar para sacar un puñado de características y guardarlas en un archivo nuevo?

Debo mencionar que no tengo una licencia ni acceso a ninguna de la línea de productos ESRI.

¿Fue útil?

Solución

You have several options to export a subset of records from a shapefile.

  • Any Open Source desktop GIS will be able to perform this. Some of the more populars are Quantum GIS, gvSIG or openJUMP. The exact steps will vary in each of them, but basically you have to load the shape file, start editing, select the records you want and export them to a new shapefile.

  • The ogr2ogr tool, part of the GDAL package allows you to transform between different geographic vector formats (or within the same format), and you can specify an SQL-like expression to filter the original dataset.

    ogr2ogr -f "ESRI Shapefile" -where "id < 10" new_shapefile.shp huge_shapefile.shp

  • If you are using PostGIS and don't want to install any of the previous apps, you can use the pgsql2shp tool to export a subset of your PostGIS table to a shapefile.

    pgsql2shp -f "/path/to/shapefile" -h server -u user -P password postgisdb "SELECT * FROM table WHERE id < 10"

Edit: In any of the three options you can perform a spatial filter (ie features that fall within a bounding box) rather than a selection based on attributes.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top