[gdal-dev] Reprojecting shapefile

Even Rouault even.rouault at mines-paris.org
Wed Nov 28 13:28:55 EST 2007


Le Wednesday 28 November 2007 19:41:03 Frank Warmerdam, vous avez écrit :
> Mullins, Steven wrote:
> > I am reading point data via a VRT file from a sql server and converting
> > to a shapefile.  This works great.  The X and Y coordinates are read from
> > the SQL data columns.  The shapefiles are reprojected but the X and Y
> > datafields are not updated.  I understand why they are not, since they
> > are not spatial data in the shapefile sense.  However, I would like them
> > to match the reprojected coordinates.  Any suggestions?
> >
> > Thanks,
> >
> > Steve
> >
> > VRT FILE (geology-all.ovf):
> >
> > <OGRVRTDataSource>
> >     <OGRVRTLayer name="geology-all">
> >       <SrcDataSource>ODBC:xxx/xxxxxxxxx at xxxx</SrcDataSource>
> > 	<GeometryType>wkbPoint</GeometryType>
> > 	<SrcSQL>
> > 	  SELECT dmlrpermits_geopoints.keyPeGeoPoints, PeNo, PeGeoLoc,
> > PeGeoElevation, PeGeoAnalysis, PeGeoShared
> > 	  from dmlrpermits_geopoints
> > 	</SrcSQL>
> >       <LayerSRS>PROJCS["NAD27 / Virginia South",
> >     	  GEOGCS["NAD27",
> >         DATUM["North_American_Datum_1927",
> >         SPHEROID["Clarke 1866",6378206.4,294.9786982139103,
> >         AUTHORITY["EPSG","7008"]],
> >         AUTHORITY["EPSG","6267"]],
> >         PRIMEM["Greenwich",0,
> >         AUTHORITY["EPSG","8901"]],
> >         UNIT["degree",0.01745329251994328,
> >         AUTHORITY["EPSG","9122"]],
> >         AUTHORITY["EPSG","4267"]],
> >     	  PROJECTION["Lambert_Conformal_Conic_2SP"],
> >     	  PARAMETER["standard_parallel_1",36.76666666666667],
> >         PARAMETER["standard_parallel_2",37.96666666666667],
> >         PARAMETER["latitude_of_origin",36.33333333333334],
> >         PARAMETER["central_meridian",-78.5],
> >         PARAMETER["false_easting",2000000],
> >         PARAMETER["false_northing",0],
> >         UNIT["US survey foot",0.3048006096012192,
> >         AUTHORITY["EPSG","9003"]],
> >         AUTHORITY["EPSG","32047"]]
> >       </LayerSRS>
> > 	<GeometryField encoding="PointFromColumns" x="PeGeoEasting"
> > y="PeGeoNorthing"/> </OGRVRTLayer>
> > </OGRVRTDataSource>
> >
> >
> > Command:
> >
> > ogr2ogr -f "ESRI Shapefile"  -t_srs 83.wkt geo geology-all.ovf
>
> Steven,
>
> The only solution I can see is to write a script to copy the values
> back into the attributes.
>
> Best regards,


Or, if you can use GDAL 1.5dev, use the BNA driver as output.
BNA is a very simple text format.
For points, you'll get something like :
"id1", "id2",1, Y, X
This can be opened as a CSV file afterwards.

Something like that should do the job :
ogr2ogr -f BNA -dsco "NB_IDS=2" -dsco "MULTILINE=NO" output.bna input.shp

See : http://www.gdal.org/ogr/drv_bna.html

Best regards.


More information about the gdal-dev mailing list