Asset Publisher

Importing Shapefile (.shp) files to CartoDruid projects with QGIS


Importing Shapefile (.shp) files to CartoDruid projects with QGIS

CartoDruid can't handle Shapefile files (.shp) natively, so the way to work with them is to import them into SpatiaLite (SQlite) to directly use them in your project.

Previosly, we made a post about how to import Shapefiles using Spatialite_Gui: Importing Shapefile (.shp) files to CartoDruid projects, however now we consider another simpler possibility using the QGIS application.

QGIS is a GIS editor with full support to handle SQLite-Spatialite databases, this is extreamely useful when it comes to transform information between different formats. With this tool, you can convert your Shapefiles into SQlite databases ready to be used in you CartoDruid projects.

For this, follow these simple steps in QGIS (version 2.18 Las Palmas or higher)

  1. The first thing you have to do is load the SHP layer in the QGIS map, and clicking with the right button of the mouse on the layer will select the option "Save as ..."

  2. A window will appear where you must select some precise options to make source the resulting SQlite file is fully compatible with CartoDruid. Set the parameters as shown in this image, and pay special attention to the options highlighted in red:

  • Format: choose SpatiaLite and not SQLite.
  • File name: name and location where the database will be created with extension .sqlite.

  • Layer Name: the name that the table would have with the shape data inside the SQlite type base.

    In this example you would create a SQlite file called PLAGAS.sqlite, inside which you'd have a PLAGAS table with the same fields and data that you have selected from the shape file loaded in QGIS.

  • SRC: Cartographic Reference System for the output of the graphic layer. By default you can choose the original system of the shape layer (SRC of the Layer or SRC selected), or  the one that better fits your area of work. For example, in Castilla y León we usually use projected coordinates in the ETRS89 zone 30N system whose SRID denomination using EPSG (European Petroleum Survey Group) codes is 25830:

    The list of EPSG codes (SRID) most used in Spain can be consulted here.

    This topic is covered more fully in another article called "Coding of Reference Systems: EPSG (or SRID)".

  • Select Fields..: deselect the fields of the shape that you don't want to be included in the resulting SQLite database.

  • Geometry: choose the type of geometry (do not leave it in Automatic) that contains the shape, polygonal (Polygon) or point (Point). Check "Force Multi-Type" and uncheck "Include z-dimension" options

  • Layer Options: mark all "yes" as it appears in the image and in the part of the SRID write the code of the SRC chosen previously, for example, if it was "EPSG: 25830 - ETRS89 / UTM zone 30N " you have to put 25830 in the SRID.

  • Custom Options - Layer: it is very important to write the following expression in this part: FID = PK_UID, otherwise the database created will not be compatible with CartoDruid, and therefore cannot be viewed or edited.