<div dir="ltr">Hi,<div><br></div><div>Looks like you have invalid latitude values in the shapefile. Try creating geometry type instead of geography.</div><div><br></div><div>Best regards,</div><div><br></div><div>Tamas</div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-15 17:06 GMT+02:00 Mike Colbert <span dir="ltr"><<a href="mailto:mcolbert@unicon-intl.com" target="_blank">mcolbert@unicon-intl.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here is the command and the error:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">String[] cmd = {<u></u><u></u></p>
<p class="MsoNormal"> "-overwrite",<u></u><u></u></p>
<p class="MsoNormal"> "-f", "MSSQLSpatial",<u></u><u></u></p>
<p class="MsoNormal"> "MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx",<u></u><u></u></p>
<p class="MsoNormal"> "C:\\Users\\mcolbert\\Downloads\\UGRB_Ozone_NAA\\UGRB_Ozone_NAA.shp", // error on this one<u></u><u></u></p>
<p class="MsoNormal">// "C:\\Users\\mcolbert\\Downloads\\tl_2010_06_zcta510\\tl_2010_06_zcta510.shp", // this one seems fine<u></u><u></u></p>
<p class="MsoNormal"> "-lco", "GEOM_TYPE=geography",<u></u><u></u></p>
<p class="MsoNormal"> "-lco", "GEOM_NAME=geog",<u></u><u></u></p>
<p class="MsoNormal"> "-nln", "CM_SHAPE",<u></u><u></u></p>
<p class="MsoNormal"> "--debug", "ON"<u></u><u></u></p>
<p class="MsoNormal">// ,"-a_srs", "ESPG:4269"<u></u><u></u></p>
<p class="MsoNormal"> };<u></u><u></u></p>
<p class="MsoNormal">ogr2ogr.main(cmd);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">OGR: OGROpen(C:\Users\mcolbert\Downloads\UGRB_Ozone_NAA\UGRB_Ozone_NAA.shp/00000000003FFE40) succeeded as ESRI Shapefile.<u></u><u></u></p>
<p class="MsoNormal">OGR_MSSQLSpatial: EstablishSession(Connection:"Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx")<u></u><u></u></p>
<p class="MsoNormal">ODBC: SQLDriverConnect(DRIVER=SQL Server;Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx)<u></u><u></u></p>
<p class="MsoNormal">OGR: OGROpen(MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx/000000000042C440) succeeded as MSSQLSpatial.<u></u><u></u></p>
<p class="MsoNormal">MSSQLSpatial: DeleteLayer(cm_shape)<u></u><u></u></p>
<p class="MsoNormal">OGR_MSSQLSpatial: Using column ogr_fid as FID for table cm_shape.<u></u><u></u></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":
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">System.FormatException: <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> at Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> at Microsoft.SqlServer.Types.Forw<u></u><u></u></p>
<p class="MsoNormal">Terminating translation prematurely after failed<u></u><u></u></p>
<p class="MsoNormal">translation of layer UGRB_Ozone_NAA (use -skipfailures to skip errors)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m assuming there is nothing unusual about the shapefile. The file is available here:<u></u><u></u></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" target="_blank"><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><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Any help is appreciated.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Mike<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div></div>