1

This may be very simple, but I'm new to GRASS GIS. I have a large shapefile containing global species ranges, which needs topological cleaning. I imported this into GRASS GIS 6.4.3 using v.in.ogr (a very slow process!). When using v.in.ogr errors were encountered:

> (Mon Feb 03 14:30:37 2014)                                            
> v.in.ogr dsn=C:\GIS_Phil\IUCN_all_ranges_raw.shp
> layer=IUCN_all_ranges_raw output=IUCN_all_ranges_raw -e Projection of
> input dataset and current location appear to match Layer:
> IUCN_all_ranges_raw Counting polygons for 726 features... Importing
> map 726 features...
> ----------------------------------------------------- Building topology for vector map <IUCN_all_ranges_raw_tmp>... Registering
> primitives... 35000 primitives registered 2128395 vertices registered
> Number of nodes: 29730 Number of primitives: 35000 Number of points: 0
> Number of lines: 0 Number of boundaries: 35000 Number of centroids: 0
> Number of areas: - Number of isles: -
> ----------------------------------------------------- WARNING: Cleaning polygons, result is not guaranteed!
> ----------------------------------------------------- Break polygons:
> ----------------------------------------------------- Remove duplicates:
> ----------------------------------------------------- Break boundaries:
> ----------------------------------------------------- Remove duplicates:
> ----------------------------------------------------- Clean boundaries at nodes:
> ----------------------------------------------------- Break boundaries:
> ----------------------------------------------------- Remove duplicates:
> ----------------------------------------------------- Clean boundaries at nodes:
> ----------------------------------------------------- Break boundaries:
> ----------------------------------------------------- Remove duplicates:
> ----------------------------------------------------- Clean boundaries at nodes:
> ----------------------------------------------------- Break boundaries:
> ----------------------------------------------------- Remove duplicates:
> ----------------------------------------------------- Clean boundaries at nodes:
> ----------------------------------------------------- Merge boundaries:
> ----------------------------------------------------- Change dangles to lines:
> ----------------------------------------------------- Remove bridges:
> ----------------------------------------------------- Building topology for vector map <IUCN_all_ranges_raw_tmp>... Building areas...
> 481585 areas built 12187 isles built Attaching islands... Number of
> nodes: 568734 Number of primitives: 2323622 Number of points: 0 Number
> of lines: 0 Number of boundaries: 2323622 Number of centroids: 0
> Number of areas: 481585 Number of isles: 12187 Number of areas without
> centroid: 481585
> ----------------------------------------------------- Find centroids for layer: IUCN_all_ranges_raw
> ----------------------------------------------------- Write centroids: WARNING: 432364 areas represent more (overlapping) features, because
> polygons overlap in input layer(s). Such areas are linked to more than
> 1 row in attribute table. The number of features for those areas is
> stored as category in layer 2
> ----------------------------------------------------- 14410 input polygons Total area: 2.55953E+014 (481585 areas) Overlapping area:
> 2.17134E+014 (432364 areas) Area without category: 2.10092E+012 (18832 areas)
> ----------------------------------------------------- Building topology for vector map <IUCN_all_ranges_raw>... Registering
> primitives... 1429509 primitives registered 3434995 vertices
> registered Building areas... 481585 areas built 12187 isles built
> Attaching islands... Attaching centroids... Number of nodes: 960111
> Number of primitives: 1429509 Number of points: 0 Number of lines: 0
> Number of boundaries: 966756 Number of centroids: 462753 Number of
> areas: 481585 Number of isles: 12187 Number of areas without centroid:
> 18832
> ----------------------------------------------------- WARNING: Errors were encountered during the import Try to import again, snapping with
> at least 1e-013: 'snap=1e-013' Default region for this location
> updated Region for the current mapset updated (Tue Feb 04 08:22:58
> 2014) Command finished (1072 min 21 sec)

The next step was to export the (hopefully) cleaned file using v.out.ogr. Many of the species range polygons overlap one another, or are islands within the ranges of other species. There are also likely to be holes in the ranges of some species that are topologically represented as islands.

Should I be using the -c flag when exporting this data? With the -c flag I got this message:

> (Tue Feb 04 14:36:00 2014)                                            
> v.out.ogr -c input=IUCN_all_ranges_raw@PERMANENT type=area
> dsn=C:\GIS_Phil\grassoutput\grassoutisl.shp Exporting 481585 areas
> (may take some time)... WARNING: 18832 features found without category
> were skipped v.out.ogr complete. 3723175 features written to
> <IUCN_all_ranges_raw> (ESRI_Shapefile). (Tue Feb 04 16:02:58 2014)
> Command finished (86 min 57 sec)

Without the -c flag I got this message:

> (Tue Feb 04 16:28:33 2014)                                            
> v.out.ogr input=IUCN_all_ranges_raw@PERMANENT type=area
> dsn=C:\GIS_Phil\grassoutput\grassoutni.shp WARNING: The map contains
> islands. To preserve them in the output map, use the -c flag Exporting
> 481585 areas (may take some time)... v.out.ogr complete. 3809331
> features written to <IUCN_all_ranges_raw> (ESRI_Shapefile). (Tue Feb
> 04 17:56:31 2014) Command finished (87 min 58 sec)

Are either of these actually exporting the species ranges correctly?

Are the features without category that are skipped when using the -c flag holes in species ranges, in which case they should be skipped, or are they useful data (eg portions of actual species ranges) that need to be retained?

  • The command suggested to use the "snap" parameter, perhaps that had been a good idea :-) – markusN Feb 19 '14 at 9:01
  • I've been through the cleaning process again after splitting the vector layer so that each species range is in a separate file. I've been using snap, and using v.build when errors are reported for a species. This has corrected most of the errors, but some still remain. I also need to clip the species ranges to the Philippines (which I did in QGIS), and when I do this there are a few species for which features within the Philippines are erroneously excluded from the clipped files. For these features QGIS reports 'invalid geometry.' I've tried the QGIS 'dissolve' tool but this hasn't helped. – user1407959 Feb 20 '14 at 10:12
  • Thanks for the suggestion about snap! Any further ideas on the clipping would be very welcome:) – user1407959 Feb 20 '14 at 10:14
  • Ok, I sorted out those problems with the clipping! – user1407959 Feb 20 '14 at 14:07
3

When you import a shapefile (without topology) with v.in.ogr in GRASS GIS (topological GIS), GRASS needs to build a GRASS topology

1) first, it try to clean the shapefile with v.clean:

WARNING: Cleaning polygons, result is not guaranteed!
> ---- Break polygons:
> ---- Remove duplicates:
...

2) after, it try to build a topology with v.build

 Building topology for vector map <IUCN_all_ranges_raw_tmp
 >----, with Building areas...
 ....

GRASS can use several runs (v.clean -> v.build) to get the best possible result, but it may remain errors: result is not guaranteed ! (provisionally disregarded -> Number of areas without centroid: 18832)

That has nothing to do with the islands which are topologically correct (Number of isles: 12187)

For polygons/areas, when you use v.out.ogr, the -c flag is used for exporting the GRASS vector map to shapefile format, preserving islands, and nothing else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.