Skip to content

Shapefile import

domlysz edited this page Jan 6, 2019 · 2 revisions

Remember BlenderGIS is building with the mind of a 2 step workflow :

  1. Explore and manage your data in your favourite GIS software
  2. Try to import them in Blender

Following this paradigm BlenderGIS always make the assumption you have a good knowledge on what you are trying to import, if it's not the case please go to step 1.

You must also read carefully how BlenderGIS handle georeferencing informations.


This tool can import in Blender most of shapefile feature type including geometry with z value. However multipatch feature are not supported.

Separate objects

By default all features will be merged into one unique mesh. However it's also possible to import each into separate objects. But keep in mind, Blender is not designed to handle thousands of objects. Importing into separate objects can be very slow with lot of features.

When importing into separate objects it's possible to define a field whose values will be used to name each features. Newly created objects are imported into a new Blender collection.

Importing into separate objects also offers the ability to handle attributes data into Blender. For each newly created object, feature's attributes data will be assigned as new custom properties. Then, when re-exporting this collection of objects into a new shapefile, theses custom properties are well taken into account.

Importing all features into one unique mesh does not allows to handle attributes data, but it's the best approach for importing large shapefile. There is an option in BlenderGIS's preferences that allows merging automatically duplicate vertices while importing. This option is usefull to reduce the mesh size in memory when the imported features share lot of vertices.

Elevation and extrusion

Features elevation can be setup from various sources

  • Geometry : for 3d shapefile only, this option will use the z coordinates of each vertices
  • Field : peek up feature's elevation an attribute data fields
  • Object : select a ground object that will be used as reference for vertices z coordinates
  • None : flat import

An extrusion value can also be setup from a specified attribute field

Coordinate Reference System (CRS)

When importing a shapefile it's necessary to specify the projection of the file.

Typical import workflow assumes 2 mains conditions:

  • all your data must be already in the same projection
  • this projection must be suitable for your area of interest.

Once again use a GIS software to explore and manage your data (reprojection, clip ...) before trying to import them in Blender. Each contry have a set of commonly used projections, if you really don't know if the projection of your data is suitable for your location you can consider transforming them into the right UTM zone. However, this topic is out of scope of BlenderGIS wiki.

Most of shapefile define the CRS in a .prj file witch contains the definition of the projection in Well-know text (wkt) format. However, BlenderGIS store map projection as SRID unique identifier and unfortunately discover the right SRID from WKT definition is not an easy task. Futhermore, the prj file is optional and may be missing. That's why for now the user must explicit the input/file SRS.

Fortunately, BlenderGIS handle a list of predefinate CRS witch help to quickly specify the projection of your input data.

If the CRS of your input file is not in the list, you can quickly add a new one with + operator.

You can find more information on how to manage this list of predefinate CRS in geoscene addon documentation.

Warning :

You must avoid as much as possible importing a shapefile stored as longitude/latitude in degrees otherwise you will lose data accuracy. One degree on the earth is equals to approx 111km so one meter is approx 0.00001 degrees but Blender works with coordinates as single precision (float32) and a single float value has actually about 7 significant digits of precision. You cannot expect an accuracy bellow 1 meter when working in decimal degrees because closest points will be rounded and merged into one. Futhermore, angulars units will be virtually unusable in Blender. In this case, you need to choose an appropriate map projection (in linear units) for your location and transform your data into this reference system.

Reprojection capabilities

Shapefile importer support minimal reprojection capabilities which can be usefull in some case. Please use this functionnaly with caution and full background knowledge, BlenderGIS can't do magic alignment for you...

Reprojection will be involved each time a shapefile must be transformed to match the scene CRS.

The scene CRS is the destination CRS so it leads all reprojection tasks. If the scene is not yet georeferenced, then it will be not possible to perform a reprojection task.

Georeferencing informations of the scene will be automatically initialized according to the first shapefile import. But, it's possible to define the scene CRS before importing any shapefile and thus ensure reprojection of each subsequent imports. To do this use the geoscene manager panel available in 3dview tool sheft.

Troubles

  • This tool depends on pyshp library that is in beta version, so sometimes it cannot process the shapefile. Typically, if you got "Unable to read shapefile", "Unable to extract geometry" or "Unable to read DBF table" error, these are pyShp issues. In this case:

    • Try to check if there is any update of pyshp lib.

    • If there is no update available or if update doesn't correct the problem, try to open and re-export the shapefile with any GIS software. You can also try to clean/repair geometry, delete unnecessary fields...

  • For polygons import, if you see faces which seem to be strangely filled try to remove duplicate vertex on the mesh (modify tolerance distance if necessary)

  • The script can handle multipart geometry but actually if the part defines a polygon hole, a face will still be created.

  • Because the scene can be very large, don’t forget to configure camera clipping distance according to the scene. If you still see black faces error on render image after setting clip end distance try to set the clip start distance closer to the scene, it will help Blender to improve vertex position according to the Z depth of the camera.

You can’t perform that action at this time.