Showing results for 
Search instead for 
Do you mean 

Creating an (editable) 2D Shapefile Snippet (2016)

by Technical Evangelist on ‎08-23-2016 12:21 PM - edited on ‎02-24-2020 04:40 AM by Community Manager (1,601 Views)


Download model




Today's Model is actually a Snippet intended to work around an issue that was recently raised when producing Shapefiles from the Spatial Modeler in ERDAS IMAGINE 2016. People were reporting that the Shapefiles created could not be edited in ERDAS IMAGINE's 2D View. This is because 3D Shapefiles cannot be edited in the 2D View.

It appears that many Features-based operators (such as Buffer Zones and Convert to Features) are creating a 3D Coordinate Reference System (CRS) on the output Features (even though the vertex height information may not have been populated). Which in turn means you get a 3D Shapefile if your Features Output is to the Shapefile format.


The solution is to make sure you transform the Features into a 2D CRS before outputting to a Shapefile. The biggest problem is defining the 2D CRS to be used. I’ve done it in this model by rasterizing the original (2D) shapefile input. But that takes time, so a better solution would be to use an existing raster stream that might be present in your Model (and which has the desired output 2D CRS associated with it).





The approach taken in the Model shown above is to use the Raster Information operator to acquire the necessary output (2D) CRS information. To do this you need a Raster stream which contains only a 2D coordinate system, which is normal for ortho-imagery, but may not be for raster DEMs and some other types of imagery. You can verify by checking to see if the VerticalCRS port returns (null). Obviously you should only use a data source which uses the CRS you want your output data to be in.


The first output port of the Raster Information operator is the Boundary of the raster stream. As well as containing the bounding box coordinates, the Boundary also encodes the CRS used by those coordinates and stores all this information as a Dictionary data type. The Dictionary Item operator is therefore used to look up the CRS value from the Boundary dictionary. That CRS is then passed to the TargetCRS port of the Coordinate Transformation operator. The other input to the Coordinate Transformation operator is the FeaturesIn port, into which are fed the 3D Features. The Features are thus transformed from a 3D CRS to a 2D CRS and this Features stream can then be fed directly into Features Output to create a 2D Shapefile (which should be editable in a 2D View).


This approach is used to automate selection of the CRS based on the inputs to the Model. If instead you wish to manually define the CRS to be used you can substitute a Construct CRS ID operator as the input to the TargetCRS port of the Coordinate Transformation operator. 




on ‎04-12-2018 09:09 AM

Not working for me I'm afraid. Have shapefile in utm14 - checked in qgis to make sure it was 2d - but still unable to edit it in IMAGINE. This model fails with the error "Object reference to set to an instance of the object".

by Technical Evangelist
on ‎04-12-2018 09:24 AM

It may be for some other reason than it being a 3D Shapefile that its locked then.