The shape file in the zip is not in projection espg:4269. It's in utm
zone 12N. Replace the "-a_srs", "ESPG:4269" with "-t_srs", "ESPG:4269"
and "-s_srs", "ESPG: /code_for_UTM_12N/"
This causes ogr2ogr to reproject you data to the correct projection
Bo Victor Thomsen
Den 15/04/16 kl. 17:06 skrev Mike Colbert:
Hi,
I have a Java web app with a SQL Server database and I would like to
add support for importing shapefiles. The shapes will then be used to
determine if geographic locations we have defined in our system are
within the areas defined by the shapes.
I’ve gone down the path of using ogr2ogr from Java to connect to SQL
Server and load the shapefile. However, I’m getting an error on a
particular file I will need to load. I’m wondering if I’m missing an
option on the command? Using a different shapefile, it seems to work.
Here is the command and the error:
String[] cmd = {
"-overwrite",
"-f", "MSSQLSpatial",
"MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx",
"C:\\Users\\mcolbert\\Downloads\\UGRB_Ozone_NAA\\UGRB_Ozone_NAA.shp",
// error on this one
//
"C:\\Users\\mcolbert\\Downloads\\tl_2010_06_zcta510\\tl_2010_06_zcta510.shp",
// this one seems fine
"-lco", "GEOM_TYPE=geography",
"-lco", "GEOM_NAME=geog",
"-nln", "CM_SHAPE",
"--debug", "ON"
// ,"-a_srs", "ESPG:4269"
};
ogr2ogr.main(cmd);
OGR:
OGROpen(C:\Users\mcolbert\Downloads\UGRB_Ozone_NAA\UGRB_Ozone_NAA.shp/00000000003FFE40)
succeeded as ESRI Shapefile.
OGR_MSSQLSpatial:
EstablishSession(Connection:"Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx")
ODBC: SQLDriverConnect(DRIVER=SQL
Server;Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx)
OGR:
OGROpen(MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx/000000000042C440) succeeded
as MSSQLSpatial.
MSSQLSpatial: DeleteLayer(cm_shape)
OGR_MSSQLSpatial: Using column ogr_fid as FID for table cm_shape.
ERROR 1: INSERT command for new feature failed. [Microsoft][ODBC SQL
Server Driver][SQL Server]A .NET Framework error occurred during
execution of user-defined routine or aggregate "geography":
System.FormatException: 24201: Latitude values must be between -90 and
90 degrees.
System.FormatException:
at
Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x,
Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double
y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types.Forw
Terminating translation prematurely after failed
translation of layer UGRB_Ozone_NAA (use -skipfailures to skip errors)
I’m assuming there is nothing unusual about the shapefile. The file
is available here:
http://deq.wyoming.gov/media/attachments/Air%20Quality/Winter%20Ozone/Nonattainment%20Information/2012_AQD_UGRB-Ozone-Nonattainment-Area-GIS-Shape-File.zip
Any help is appreciated.
Thanks,
Mike
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev