Question

3D Solids in PostGIS

  • 29 April 2019
  • 6 replies
  • 28 views

Badge

Hi! I have been googling PostGIS-3D-solutions so hard that my finger tips are getting sore.

Basically I need to create 3D solids and store them in PostGIS from mainly Autocad data (preferably with FME). Then I want to be able to store 3D points in the same database and query if they are inside the body of the solid or not. As simple as that.

Any suggestions or links will be appreciated!


6 replies

Badge +2

@peteralstorp FME supports PostGIS solid geometry so you should be able to accomplish your data load. You may have to restructure your AutoCAD data - some ideas here. As an FYI, this is an interesting review on the use of 3D geometry in PostGIS: Towards a True 3D GIS (circa 2014 so a little dated).

In FME, you should be able to use the Clipper to identify the 3D points inside your solids.

Example workspace (2019.0): postgis3dsolid.zip

Userlevel 6
Badge +32

@peteralstorp FME supports PostGIS solid geometry so you should be able to accomplish your data load. You may have to restructure your AutoCAD data - some ideas here.  As an FYI, this is an interesting review on the use of 3D geometry in PostGIS: Towards a True 3D GIS  (circa 2014 so a little dated).

In FME, you should be able to use the Clipper to identify the 3D points inside your solids.

Example workspace (2019.0): postgis3dsolid.zip

Nice to see the Clipper works, but it puts a warning in the log:

Clipper_Raster (RasterClippingFactory): No valid clipper feature(s) received

When I checked this earlier I assumed something went wrong, but apparently not. What does the warning means in this case?

Badge +2

Nice to see the Clipper works, but it puts a warning in the log:

Clipper_Raster (RasterClippingFactory): No valid clipper feature(s) received

When I checked this earlier I assumed something went wrong, but apparently not. What does the warning means in this case?

Looks like that is a message that should be removed.  

The Clipper will also accept an Extruded Solid, so the GeometryCoercer is not actually needed in this case. The result in PostGIS will be a mesh

Userlevel 6
Badge +32

Looks like that is a message that should be removed.

The Clipper will also accept an Extruded Solid, so the GeometryCoercer is not actually needed in this case. The result in PostGIS will be a mesh

Great, happy to see it clips in 3D!

Badge

@peteralstorp FME supports PostGIS solid geometry so you should be able to accomplish your data load. You may have to restructure your AutoCAD data - some ideas here. As an FYI, this is an interesting review on the use of 3D geometry in PostGIS: Towards a True 3D GIS (circa 2014 so a little dated).

In FME, you should be able to use the Clipper to identify the 3D points inside your solids.

Example workspace (2019.0): postgis3dsolid.zip

My main objective here was to get info on writing data with FME that would enable me to run SQL PostGIS-queries that would answer my question if 3D-points are inside the body of the solid or not, I may have been somewhat unclear. Using the GeometryCoercer with the brep-setting as you suggested got me closer to the truth but I still can't manage to query the data with spatial SQL which irritates me. And I'm surprised to see PostGIS so poorly documented.

Userlevel 6
Badge +32

My main objective here was to get info on writing data with FME that would enable me to run SQL PostGIS-queries that would answer my question if 3D-points are inside the body of the solid or not, I may have been somewhat unclear. Using the GeometryCoercer with the brep-setting as you suggested got me closer to the truth but I still can't manage to query the data with spatial SQL which irritates me. And I'm surprised to see PostGIS so poorly documented.

If I interpret the documentation correctly I think it should be doable using ST_3DIntersection, as the solid gets written as POLYHEDRALSURFACE in PostGIS.

It needs sfcgal backend, which is standard from PostGIS 2.2.0. (But I have 2.1 installed, and ran out of time and motivation to upgrade my installation for testing this.)

Found one post on SE which pushed me in this direction, not sure if this is going to work tho...

Reply