You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

why esriGeometryPolygon generated a polylin...   Eric Lussier May 25, 2006
Re: why esriGeometryPolygon generated a pol...   Neil Clemmons May 25, 2006
Re: why esriGeometryPolygon generated a pol...   Eric Lussier May 26, 2006
Re: why esriGeometryPolygon generated a pol...   Neil Clemmons May 26, 2006
Re: why esriGeometryPolygon generated a pol...   Eric Lussier May 26, 2006
Re: why esriGeometryPolygon generated a pol...   Neil Clemmons May 26, 2006
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject why esriGeometryPolygon generated a polyline ? 
Author Eric Lussier 
Date May 25, 2006 
Message Good day,

To make a short story: I have a polyline shape file that i used to get the fields name in order to put them into a fields collection.

after that i create my new polygone shapefile and i give it the files names that i've got from the polyline.

It works find, but the resulting geometry of the new created file is polyline.

I would like to know if some one had allready had that kind of problem and what was the cause of it?

the code bellow may gives you some hits on what i did wrong.

Thanks.

 
 
set pGeomDef = New GeometryDef
Set pGeomDefEdit = pGeomDef
With pGeomDefEdit
    .GeometryType = esriGeometryPolygon ' sets geometry type (currently polygon)
    Set pSpatRef = pMap.SpatialReference
    If (pSpatRef Is Nothing) Then ' if current map has no spatial ref
        Set .SpatialReference = New UnknownCoordinateSystem ' assign null reff
    Else
        Set .SpatialReference = pMap.SpatialReference ' else use maps spatial ref
    End If
End With
Set pFieldEdit.GeometryDef = pGeomDef

pFieldsEdit.AddField pField2
Next intCountfield
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 'Create the shapefile
' (some parameters apply to geodatabase options and can be defaulted as Nothing)
Dim pFeatClass As IFeatureClass
Set pFeatClass = pFeatureWorkspace.CreateFeatureClass(strNameNewPolygone, pFields, Nothing, Nothing, esriFTSimple, strShapeFieldName, "")
' Add to current map
Set pFeatureLayer = New FeatureLayer
Set pFeatureLayer.FeatureClass = pFeatClass
pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName
pMap.AddLayer pFeatureLayer
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: why esriGeometryPolygon generated a polyline ? 
Author Neil Clemmons 
Date May 25, 2006 
Message When copying the fields from the polyline shapefile, make sure you aren't copying it's geometry field. 
  Neil Clemmons
Senior GIS Developer
Geographic Information Services, Inc.
Birmingham, AL
http://www.gis-services.com

Check out our blog:
http://blog.gis-services.com/ 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: why esriGeometryPolygon generated a polyline ? 
Author Eric Lussier 
Date May 26, 2006 
Message Hi Neil,

i used the iClone interface to do a copy of the fields. I guest that the cloned field generated is a conform copy of the original one, including the geometriy.

can you tell me what's wrong?

thanks




 
 
Dim pClone As IClone
Dim pSpatRef As ISpatialReference
For intCountfield = 0 To intField
Set pField = pFeatureLayer.FeatureClass.Fields.Field(intCountfield)
Set pClone = pField
Set pFields2 = New esriCore.Fields
Set pField2 = pClone.Clone
Set pFieldsEdit = pFields2

Set pField2 = New esriCore.Field
Set pFieldEdit = pField2

pFieldEdit.Name = strNameNewPolygone
pFieldEdit.Type = esriFieldTypeGeometry

Set pGeomDef = New GeometryDef
Set pGeomDefEdit = pGeomDef
With pGeomDefEdit
    .GeometryType = esriGeometryPolygon ' sets geometry type (currently polygon)
    Set pSpatRef = pMap.SpatialReference
    If (pSpatRef Is Nothing) Then ' if current map has no spatial ref
        Set .SpatialReference = New UnknownCoordinateSystem ' assign null reff
    Else
        Set .SpatialReference = pMap.SpatialReference ' else use maps spatial ref
    End If
End With
Set pFieldEdit.GeometryDef = pGeomDef

pFieldsEdit.AddField pField2
Next intCountfield
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: why esriGeometryPolygon generated a polyline ? 
Author Neil Clemmons 
Date May 26, 2006 
Message It looks like you're creating a new fields collection inside the For/Next loop. You should be creating the fields collection outside the loop. You will also need to skip the geometry field and create your own. It looks like you're creating a new geometry field with each iteration of your loop. You should only be doing this once. Its ok to clone the other fields (except the FID field, of course). 
  Neil Clemmons
Senior GIS Developer
Geographic Information Services, Inc.
Birmingham, AL
http://www.gis-services.com

Check out our blog:
http://blog.gis-services.com/ 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: why esriGeometryPolygon generated a polyline ? 
Author Eric Lussier 
Date May 26, 2006 
Message Neil,

Thanks for your help.

I did a clean-up of the script. I was performing task without reasons.

I must admit that i have i little difficulty to figure how to set the geometry to polygone.

i tried with igeometryedit, but i still have a polyline generated.







 
 
Dim pClone As IClone
Dim pSpatRef As ISpatialReference
Set pFields = pFeatureLayer.FeatureClass.Fields 
Set pClone = pFields
Set pFields2 = New esriCore.Fields
Set pFields2 = pClone.Clone

Set pFieldEdit = pField2
'
pFieldEdit.Name = strNameNewPolygone
pFieldEdit.Type = esriFieldTypeGeometry
'
Set pGeomDef = New GeometryDef
Set pGeomDefEdit = pGeomDef
pGeomDefEdit.GeometryType = esriGeometryPolygon
Set pSpatRef = pMap.SpatialReference
Set pGeomDefEdit.SpatialReference = pMap.SpatialReference
Set pFieldEdit.GeometryDef = pGeomDef


 'Create the shapefile
' (some parameters apply to geodatabase options and can be defaulted as Nothing)
Dim pFeatClass As IFeatureClass
Set pFeatClass = pFeatureWorkspace.CreateFeatureClass(strNameNewPolygone, pFields, Nothing, Nothing, esriFTSimple, strShapeFieldName, "")
' Add to current map
Set pFeatureLayer = New FeatureLayer
Set pFeatureLayer.FeatureClass = pFeatClass
pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName
pMap.AddLayer pFeatureLayer

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: why esriGeometryPolygon generated a polyline ? 
Author Neil Clemmons 
Date May 26, 2006 
Message You are cloning the entire field collection from the polyline shapefile. This will clone the geometry field. So, the geometry field you are creating is not being used. You need to loop through the polyline shapefile fields and clone the field objects individually, skipping the geometry and FID field. You then need to create the new geometry field and add it to the collection. 
  Neil Clemmons
Senior GIS Developer
Geographic Information Services, Inc.
Birmingham, AL
http://www.gis-services.com

Check out our blog:
http://blog.gis-services.com/