<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic GeometryEngine.geometryFromEsriShape. How to load from a file.shp? in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/geometryengine-geometryfromesrishape-how-to-load/m-p/460843#M1427</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to use the GeometryEngine.getNearestCoordinate() method but one of its arguments is a Geometry which I suppose it'd be the multi-point or polyline shape file which contains a trajectory I want to evaluate.&lt;/P&gt;&lt;P&gt;So that I'm trying to load this shapefile as a geometry using GeometryEngine.geometryFromEsriShape(). First I load the shape file as follows:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;byte[] esriShapeBuffer = null;
&amp;nbsp; try {
&amp;nbsp; esriShapeBuffer = Files.readAllBytes(shapeFile.toPath());
&amp;nbsp; } catch (IOException e) {
&amp;nbsp; // TODO Auto-generated catch block
&amp;nbsp; e.printStackTrace();
&amp;nbsp; }
&amp;nbsp; Geometry g = GeometryEngine.geometryFromEsriShape(esriShapeBuffer, Geometry.Type.UNKNOWN);
&amp;nbsp; Point p = GeometryEngine.getNearestCoordinate(g, mapPoint, false).getCoordinate();&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in line 8 Geometry g results to be null, even though I tried all Geometry Types (although I know my shape file is multi point).&lt;/P&gt;&lt;P&gt;When I reviewed the documentation of &lt;EM&gt;geometryFromEsriShape&lt;/EM&gt; it says: &lt;STRONG style="color: #353833; font-size: 12.16px; font-family: Arial, Helvetica, sans-serif;"&gt;Note: this is not from a shape-file on disk.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #353833; font-family: Arial, Helvetica, sans-serif; font-size: 12.16px;"&gt;So, please, how can I generate a geometry from a shapefile?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #353833; font-family: Arial, Helvetica, sans-serif; font-size: 12.16px;"&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:30:35 GMT</pubDate>
    <dc:creator>EdgarCanul</dc:creator>
    <dc:date>2021-12-11T20:30:35Z</dc:date>
    <item>
      <title>GeometryEngine.geometryFromEsriShape. How to load from a file.shp?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometryengine-geometryfromesrishape-how-to-load/m-p/460843#M1427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to use the GeometryEngine.getNearestCoordinate() method but one of its arguments is a Geometry which I suppose it'd be the multi-point or polyline shape file which contains a trajectory I want to evaluate.&lt;/P&gt;&lt;P&gt;So that I'm trying to load this shapefile as a geometry using GeometryEngine.geometryFromEsriShape(). First I load the shape file as follows:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;byte[] esriShapeBuffer = null;
&amp;nbsp; try {
&amp;nbsp; esriShapeBuffer = Files.readAllBytes(shapeFile.toPath());
&amp;nbsp; } catch (IOException e) {
&amp;nbsp; // TODO Auto-generated catch block
&amp;nbsp; e.printStackTrace();
&amp;nbsp; }
&amp;nbsp; Geometry g = GeometryEngine.geometryFromEsriShape(esriShapeBuffer, Geometry.Type.UNKNOWN);
&amp;nbsp; Point p = GeometryEngine.getNearestCoordinate(g, mapPoint, false).getCoordinate();&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in line 8 Geometry g results to be null, even though I tried all Geometry Types (although I know my shape file is multi point).&lt;/P&gt;&lt;P&gt;When I reviewed the documentation of &lt;EM&gt;geometryFromEsriShape&lt;/EM&gt; it says: &lt;STRONG style="color: #353833; font-size: 12.16px; font-family: Arial, Helvetica, sans-serif;"&gt;Note: this is not from a shape-file on disk.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #353833; font-family: Arial, Helvetica, sans-serif; font-size: 12.16px;"&gt;So, please, how can I generate a geometry from a shapefile?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #353833; font-family: Arial, Helvetica, sans-serif; font-size: 12.16px;"&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:30:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometryengine-geometryfromesrishape-how-to-load/m-p/460843#M1427</guid>
      <dc:creator>EdgarCanul</dc:creator>
      <dc:date>2021-12-11T20:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryEngine.geometryFromEsriShape. How to load from a file.shp?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometryengine-geometryfromesrishape-how-to-load/m-p/460844#M1428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Edgar,&lt;/P&gt;&lt;P&gt;In ArcGIS Runtime, you can dynamically add geometries from a shapefile to you map by following the code example here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/java/sample-code/dynamic-workspaces-shapefile/" title="https://developers.arcgis.com/java/sample-code/dynamic-workspaces-shapefile/"&gt;Dynamic workspaces shapefile | ArcGIS for Developers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2016 20:59:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometryengine-geometryfromesrishape-how-to-load/m-p/460844#M1428</guid>
      <dc:creator>EricBader</dc:creator>
      <dc:date>2016-07-29T20:59:23Z</dc:date>
    </item>
  </channel>
</rss>

