7

I have a shapefile that contains all counties of Poland in one shapefile. The shapefile is provided by central cartography agency. The file with counties they provide is around 30MB.

The same shapefile from GADM is ~2MB large and contains the same level of detail (counties) with almost the same attributes. The only information I'm missing from GADM is the actual county identifier attribute that I want to use to match the counties with my data.

I'm running QGIS and I tried to simplify geometries to reduce the size. I've also tried SimpliPy, Generalizer but I can't get more than 0.5% - 1% size reduction. I Googled and searched Stackexchange but didn't find an answer to my question. I also couldn't find help understanding why the size of shapefiles of the same area can vary so much.

  • 1
    try mapshaper.org it will rebuild the shapefile, index and dbf – Mapperz Apr 1 '15 at 14:42
  • @Mapperz Hi there, I've been trying to reduce the size for few months now. I forgot to mention it in my question but I tried to use mapshaper with Douglas-Peucker method or any other method with poor results also.. I will try it again and let you know what the results were. – Radek Kukuczka Apr 1 '15 at 14:45
  • 2
    Can you identify the FILE that is unexpectingly large? does it come from the geometry (.shp), from the attribute table (.dbf) or from another file – radouxju Apr 1 '15 at 15:20
  • 3
    Radek : Mapshaper only gives you the .shp file, and after reducing this one, you just have to rename the old .dbf file, so that your geometry will be simplified and your attributes kept as they were. Anyway, @radouxju question makes sense : most of the time, the real heavy part of a shapefile is the dbf file. If this is the case, it could be due to a bad typing of your attributes, for example if the strings fields are too long (ie. only 10-15 characters used of a 250 characters field). – RobinC Apr 1 '15 at 16:45
  • 1
    The large one "powiaty" has 2240845 vertices and the small one "POL_adm2" has only 68201 vertices. That is the only reason for the difference in size. – user30184 Apr 2 '15 at 8:39
5

Note that 'level of detail' is a relative term. They may show the same information, ie counties, but level of detail also applies to the lines that make up the boundaries. One might use a hundred points to outline a county, and the other might use a couple thousand. Simplify/Generalize are what you use on the larger to bring them more in line, but depending on settings might not have that much impact - or might over do it. Or it could be a bloated/corrupted file that needs repair.

radouxju notes there are typically two component files of a shapefile that are largest - the .shp or geometry information, and the .dbf or attribute information. Depending on which one is the source of apparent bloat will dictate possible solutions.

Mapperz suggested http://www.mapshaper.org/ which is a site you can upload your file to for repair and simplification. Note that site doesn't appear to offer an option to not simplify, so it will be modifying data. For a straight repair you would need something like Repair Geometry in ArcGIS or GRASS' v.clean through QGIS. A repair may not reduce the file size any, but it also won't alter the data. I'm unsure whether Mapshaper can preserve topology and not introduce slivers in adjacent polygon boundaries during simplification, though if they're coincident before I would expect the same modifications would probably be made to both lines.

RobinC further clarified that "Mapshaper only gives you the .shp file, and after reducing this one, you just have to rename the old .dbf file, so that your geometry will be simplified and your attributes kept as they were."

user30184 took a look at the original files you provided and noted that the larger one did indeed have significantly more vertices than the smaller one (2.25 million vs 68 thousand in round numbers), which readily explains the size difference in the .shp file.

1

Generally speaking, you can reduce the content of either the .shp (geometry) or the .dbf (attribute) by trying generalization tools from other GIS packages as @GISdirtsniffer pointed out, or by deleting unused attribute columns.

In your case in particular, if as you said

The same shapefile from GADM is ~2MB large and contains the same level of detail (counties) with almost the same attributes. The only information I'm missing from GADM is the actual county identifier attribute ...

Then, you can use the smaller GADM geometry instead of the original central cartography agency. Specifically, you can use spatial join to join the original shapefile to the GADM file, and append attributes like the county identifier to GADM shapefile so that you have both the needed attributes and a smaller shapefile.

-1

I would use the Simplify tool to reduce the numbers of Vertices. I have come across this too many times.

  • 1
    Asker already states they have used the Simplify tool with insufficient results. Can you expand you answer with specific settings or additional information that might help get the desired level of size reduction? – Chris W Apr 4 '15 at 19:10

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.