<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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: <i>code_for_UTM_12N</i>"<br>
This causes ogr2ogr to reproject you data to the correct projection<br>
<br>
Bo Victor Thomsen<br>
<br>
<div class="moz-cite-prefix">Den 15/04/16 kl. 17:06 skrev Mike
Colbert:<br>
</div>
<blockquote
cite="mid:07ABE3AF1207E047A24A3BA507A717A7BF42DD88@bear.unicon-intl.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here is the command and the error:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">String[] cmd = {<o:p></o:p></p>
<p class="MsoNormal">
"-overwrite",<o:p></o:p></p>
<p class="MsoNormal"> "-f",
"MSSQLSpatial",<o:p></o:p></p>
<p class="MsoNormal">
"MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx",<o:p></o:p></p>
<p class="MsoNormal">
"C:\\Users\\mcolbert\\Downloads\\UGRB_Ozone_NAA\\UGRB_Ozone_NAA.shp",
// error on this one<o:p></o:p></p>
<p class="MsoNormal">//
"C:\\Users\\mcolbert\\Downloads\\tl_2010_06_zcta510\\tl_2010_06_zcta510.shp",
// this one seems fine<o:p></o:p></p>
<p class="MsoNormal"> "-lco",
"GEOM_TYPE=geography",<o:p></o:p></p>
<p class="MsoNormal"> "-lco",
"GEOM_NAME=geog",<o:p></o:p></p>
<p class="MsoNormal"> "-nln",
"CM_SHAPE",<o:p></o:p></p>
<p class="MsoNormal"> "--debug",
"ON"<o:p></o:p></p>
<p class="MsoNormal">// ,"-a_srs",
"ESPG:4269"<o:p></o:p></p>
<p class="MsoNormal"> };<o:p></o:p></p>
<p class="MsoNormal">ogr2ogr.main(cmd);<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">OGR:
OGROpen(C:\Users\mcolbert\Downloads\UGRB_Ozone_NAA\UGRB_Ozone_NAA.shp/00000000003FFE40)
succeeded as ESRI Shapefile.<o:p></o:p></p>
<p class="MsoNormal">OGR_MSSQLSpatial:
EstablishSession(Connection:"Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx")<o:p></o:p></p>
<p class="MsoNormal">ODBC: SQLDriverConnect(DRIVER=SQL
Server;Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx)<o:p></o:p></p>
<p class="MsoNormal">OGR:
OGROpen(MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx/000000000042C440)
succeeded as MSSQLSpatial.<o:p></o:p></p>
<p class="MsoNormal">MSSQLSpatial: DeleteLayer(cm_shape)<o:p></o:p></p>
<p class="MsoNormal">OGR_MSSQLSpatial: Using column ogr_fid as
FID for table cm_shape.<o:p></o:p></p>
<p class="MsoNormal">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":
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">System.FormatException: 24201: Latitude
values must be between -90 and 90 degrees.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">System.FormatException: <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> at
Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double
x, Double y, Nullable`1 z, Nullable`1 m)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> at
Microsoft.SqlServer.Types.Validator.BeginFigure(Double x,
Double y, Nullable`1 z, Nullable`1 m)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> at Microsoft.SqlServer.Types.Forw<o:p></o:p></p>
<p class="MsoNormal">Terminating translation prematurely after
failed<o:p></o:p></p>
<p class="MsoNormal">translation of layer UGRB_Ozone_NAA (use
-skipfailures to skip errors)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m assuming there is nothing unusual about
the shapefile. The file is available here:<o:p></o:p></p>
<p class="MsoNormal"><a moz-do-not-send="true"
href="http://deq.wyoming.gov/media/attachments/Air%20Quality/Winter%20Ozone/Nonattainment%20Information/2012_AQD_UGRB-Ozone-Nonattainment-Area-GIS-Shape-File.zip"><span
style="color:windowtext">http://deq.wyoming.gov/media/attachments/Air%20Quality/Winter%20Ozone/Nonattainment%20Information/2012_AQD_UGRB-Ozone-Nonattainment-Area-GIS-Shape-File.zip</span></a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any help is appreciated.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Mike<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
<br>
</body>
</html>