<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<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 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>
</body>
</html>