Saturday, 28 September 2019

qgis - Error in merging two shapefiles of different geometry types


I am trying to merge two shapefiles...


Here are the links of two shapefiles


Australian State & Territory


State and Territory ASGC Ed 2011 Digital Boundaries in ESRI Shapefile Format (http://www.abs.gov.au/ausstats/subscriber.nsf/log?openagent&1259030001_ste11aaust_midmif.zip&1259.0.30.001&Data%20Cubes&6E45E3029A27FFEFCA2578CC0012083E&0&July%202011&14.07.2011&Latest)


Australian Suburbs


State Suburbs ASGS Non ABS Structures Ed 2011 Digital Boundaries in ESRI Shapefile Format (http://www.abs.gov.au/AUSSTATS/subscriber.nsf/log?openagent&1270055003_ssc_2011_aust_shape.zip&1270.0.55.003&Data%20Cubes&D68DFFC14D31F4E1CA2578D40013268D&0&July%202011&22.07.2011&Previous)


When I try to merge with QGIS extension MMQGIS.


But it is giving me following error. I try to Google it but can't find something that a newbee can understand.



Error!! Merged layers must all be same type of geometry (polygon != polygon 2.5D)


enter image description here


Can someone explain what exactly this error is and how to fix the problem and merge two files?



Answer



If you still want to work in QGIS then you can do it by importing the shapefiles to GRASS and then exporting them back out again to shapefile. This should convert them both to polygon geometry and the merge will work.


Make sure the two layers are loaded into QGIS before you start.


To import into GRASS:


1. Load the GRASS plugin and the toolbars.
Open the plugin manager (Plugins --> Manage and Install Plugins) and search GRASS in the search bar, ensure that the checkbox is ticked. This should add a new GRASS toolbar to your QGIS window. If it doesn't right click on an empty part of the toolbar; this will bring up a list of toolbars, make sure that GRASS is ticked.


Step 01 - loading the toolbars



2. Create a GRASS workspace.
GRASS doesn't work with data in traditional folders like you would using QGIS with shapefiles. Instead it stores files in a database structure that you have to create before you can start. To do this (adapted from HERE):


In the GRASS toolbar, click on the "New Mapset" icon to bring up the MAPSET wizard. It should automatically create a default save folder in your user folder. Then click Next.


Create new save location


Choose to "create a new location" and call it something - for example 'Australia'. Click Next.


Create new GRASS location


You then need to set the projection. Looking at your data some of it is in GDA94 EPSG: 4283 so I've used this. You can type "4283" into the search bar to filter the list. Click Next.


Setting the projection


Leave the Default GRASS region alone and click Next.


GRASS region



Specify a name for the "mapset" -> I've called it 'Demo'. Click Next. Click Finish.


New mapset name


This should create your location and mapset and set it as the working directory. It should also load the GRASS tools (if it doesn't there is a toolbar button to load the tools). Your now ready to import the files into GRASS.


3. Load the data into GRASS
Open the GRASS tools and look at the Modules Tree. Open File Management -> Import Vector into GRASS and double click on v.in.ogr.qgis - Import Loaded Vector.


GRASS tools


Select one of the files from the dropdown list. Give it a name in the box below - I've just copied the name of the shapefile to make it easier. Click Run. It might take a little while to do, particularly on your complex shapefile. When it's finished you can view it in QGIS by clicking View Output. Repeat this step for the other file.


Run tool


When they're both in QGIS right click on them in the table of contents and select Save As. Save them to a regular folder on your harddrive in shapefile format.


Save As



Redo the join using the two new shapefiles that you've created. I've just tested it with the MMQGIS merge tool and it seems to work fine.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...