Hey, Peter!<br><br>Thank you for the hint.<br><br>Actually no much reason, i can remake my code to create a new shp file in ogr.<br><br>Thank you!<br>emmiolla.<br><br><div class="gmail_quote">On Thu, Jan 27, 2011 at 11:16 AM, Peter J Halls <span dir="ltr"><<a href="mailto:P.Halls@york.ac.uk">P.Halls@york.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Emmiolla,<br>
<br>
the problem is that OGR does not rewrite the extents when updating a dataset; it only calculates and writes the extents when creating a new dataset. This is documented behaviour. You are creating the dataset in ArcCatalog and then updating it with OGR, hence your problem.<br>
<br>
Is there any reason why you cannot create the dataset from OGR? I do this regularly and have never had problems with ArcGIS reading this output. It would require a few extra lines of code to define the attribute data, but these are very straightforward.<br>
<br>
Best wishes,<br>
<br>
Peter<br>
<br>
Emmiolla Emmiolla wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">
Hello, all!<br>
<br>
I need to copy features to the empty shp file.<br>
<br>
The code is really simple:<br>
<br>
const char *pszDriverName = "ESRI Shapefile";<br>
OGRSFDriver *poDriver;<br>
<br>
OGRRegisterAll();<br>
<br>
poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(<br>
pszDriverName );<br>
if( poDriver == NULL )<br>
{<br>
printf( "%s driver not available.\n", pszDriverName );<br>
exit( 1 );<br>
}<br>
<br>
OGRDataSource *poDS;<br>
poDS = OGRSFDriverRegistrar::Open(<br>
"C:\\ArcProjects\\Untamo\\Test\\test.shp", TRUE );<br>
if( poDS == NULL )<br>
{<br>
printf( "Open failed.\n" );<br>
exit( 1 );<br>
}<br>
<br>
OGRLayer *poLayer;<br>
poLayer = poDS->GetLayerByName( "test" );<br>
<br>
<br>
OGRDataSource *poDS1;<br>
poDS1 = OGRSFDriverRegistrar::Open(<br>
"C:\\ArcProjects\\Untamo\\Test\\arbukle0ot.shp", FALSE );<br>
if( poDS1 == NULL )<br>
{<br>
printf( "Open failed.\n" );<br>
exit( 1 );<br>
}<br>
<br>
OGRLayer *featuresLayer;<br>
featuresLayer = poDS1->GetLayerByName( "arbukle0ot" );<br>
<br>
OGRFeature *poFeature;<br>
featuresLayer->ResetReading();<br>
while( (poFeature = featuresLayer->GetNextFeature()) != NULL )<br>
{<br>
<br>
OGRFeature *newFeature;<br>
<br>
newFeature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() );<br>
newFeature->SetField( "ID", 1);<br>
newFeature->SetGeometry(poFeature->GetGeometryRef());<br>
<br>
if( poLayer->CreateFeature(newFeature ) != OGRERR_NONE )<br>
{<br>
printf( "Failed to create feature in shapefile.\n" );<br>
exit( 1 );<br>
}<br>
<br>
OGRFeature::DestroyFeature( newFeature );<br>
OGRFeature::DestroyFeature( poFeature );<br>
}<br>
<br>
OGRDataSource::DestroyDataSource( poDS );<br>
OGRDataSource::DestroyDataSource( poDS1 );<br>
}<br>
<br>
arbukle0ot.shp contains features,<br>
test is empty shp file, that is created with ArcCatalog.<br>
<br>
Now if you run this code, features will be copied, however the extent of the<br>
shp file will be strange, as the MinX and MinY will be 0 and 0. (however it<br>
should not be, the extent of each feature differs from zero)<br>
<br>
The most interesting thing, that if you will take this test.shp, draw some<br>
features in ArcMap, check extent (it will be the right one), than delete<br>
this features to make shp file again empty, and run the code, the extent of<br>
the output file be the correct!<br>
<br>
I wonder, what is a problem?<br>
<br>
emmiolla<br>
<br>
<br>
<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote>
<br>
-- <br>
--------------------------------------------------------------------------------<br>
Peter J Halls, GIS Advisor & Acting Team Leader Applications Support Group,<br>
Information Directorate, University of York<br>
Telephone: 01904 323806 Fax: 01904 323740<br>
Snail mail: C/O IT Services, University of York, Heslington, York YO10 5DD<br>
This message has the status of a private and personal communication<br>
--------------------------------------------------------------------------------<br>
</blockquote></div><br>