Invalid argument - unknown wkt,this is the exception which i got

3130
15
02-19-2017 09:50 PM
竹丰刘
New Contributor II

I use the shapefileTable to open the shapefiles on my machine,write with the absolute path.I download the local shapefiles(include .dbf .prj .shp .shx) from google.and all the code are from https://developers.arcgis.com/java/10-2/sample-code/shapefile-feature-layer/  .I only change the shapefileTable line of code.

try {
shapefileTable = new ShapefileFeatureTable("E:\\antarctica-icesheet-polygons-3857\\icesheet_polygons.shp");
featureLayer = new FeatureLayer(shapefileTable);

// create a renderer
UniqueValueRenderer uvRenderer = new UniqueValueRenderer(
new SimpleFillSymbol(new Color(100, 0, 0, 255), null), "icesheet_polygons");

// set renderer
featureLayer.setRenderer(uvRenderer);
jMap.getLayers().add(featureLayer);

the shapefiels(include .dbf .prj ..sbn .sbx shp .shp.xml .shx) that the sample code use are more.Is that the problem?

I HOPE THERE IS SOMEBODY TO HELP ME OUT!   THANK YOU!

Tags (1)
15 Replies
竹丰刘
New Contributor II

this problem is kill me out,,,,I am a chinese guy(and a student),but I can barely found any solution about this,even sample.from chinese website 0.0

0 Kudos
nita14
by
Occasional Contributor III

Hi, 

First of all, the attached shapefile does not have correctly spatial reference specified (wrong .prj file). As the shapefile's name states, it is WKID 3857 - that is Web Mercator Auxilliary Sphere. You need to Define Projection (as WKID 3857)  and Project data to Basemap spatial reference which is WGS-1984 (WKID 4326) using ArcGIS Desktop or any other GIS tool. Check out this blog: When to use the Define Projection tool and the Project tool? | Support Services Blog for further guidance

Next,  you have two options:

1) Use ShapefileFeatureTable, then both Basemap and Shapefile spatial refences need to be the same. If not, shapefile is not displayer or misaligned.

2) Use LocalService's Dynamic Workspace (not recommended)

LocalServer can project the data on-the-fly. Check out ArcGIS Runtime Sample App for 10.2.4 - Dynamic workspaces: shapefile for assistance. 

Hope this helps,

Adam

竹丰刘
New Contributor II

sorry for so late to answer you,and really thank you for the answer.I have been use your method that i change the basemap url become a WKID 3857 one.and the same exception is reported .the following line is the same exception:

java.lang.RuntimeException: Invalid argument - unknown wkt
at com.esri.core.geodatabase.Geodatabase.nativeOpenShapefile(Native Method)
at com.esri.core.geodatabase.Geodatabase.a(Unknown Source)
at com.esri.core.geodatabase.ShapefileFeatureTable.<init>(Unknown Source)
at ShapefileApp.createMap(ShapefileApp.java:66)
at ShapefileApp.createUI(ShapefileApp.java:126)
at ShapefileApp$1.run(ShapefileApp.java:104)

it's first six line of exception.

 perhaps there is some problem with the shapefiles that I dowoload.and i have been required to use the California street map in the java project in the end.

0 Kudos
nita14
by
Occasional Contributor III

HI,

Have you used Define Projection tool to re-create valid .prj file? If not, you have to do so. Apparently, there is still issue with your shapefile. Also, you should add the same shapefile to ArcMap and see if the warning about unknown spatial reference pops up.

Regards,

Adam

0 Kudos
竹丰刘
New Contributor II

hello ,Adam.thank you for your answer,how nice of you.these days I have try to solve my problem,but it's still some problem in my project.

First,the project can be runing ,and the window can show out,but there is nothing be drawed in the window which is all blank.

I FEEL better because it's not be throw out the exception i encounter before.

Second,the shapefiles i downdoad can be draw in the Arcmap(desktop vision 10.1),there is a lot of line which represents the road in the Arcmap.I USE the analysisMap function,then it tells me that the map don't have the Spatial Reference or index(in chinese both are same meaning,my Arcmap are chinese vision),which  it's a serious warning,and I double-click it ,and then the map was added the Spatial Reference.And the file was added more three new files which is sbn. sbx. and shp.xml.but the window are still all blank.

the render code are followed: UniqueValueRenderer uvRenderer = new UniqueValueRenderer(
                                                   new SimpleLineSymbol(Color.RED, 1), "name");

                                                   featureLayer.setRenderer(uvRenderer);
                                                   jMap.getLayers().add(featureLayer);

any error in my code?

I KNOW the UniqueValueRenderer class' second parameter is column Header from the dbf.file which you can open it to see it .the sample code is also use the column Header to be the second parameter,and the sample can be drawed.BUT in my projet use it the same way,but it just can't be drawed,

Third,you tell me to re-creat the prj,file by Arcmap.I wish i can handle it ,but the function to define the projection have some problems.

when I choose my shapefile,it tell that my date set is not exist or not supported.

I AM JUST CONFUSED.IF you know something that can help,please let me know.

0 Kudos
nita14
by
Occasional Contributor III

HI,

The only way I can help you is that you post your project code and input data. I will see what is wrong there.

Regards,

Adam

0 Kudos
竹丰刘
New Contributor II

california-latest-free-roads.shp.rar - Google Drive 

this is the shapefiles in clonddisk lisk.

code .txt - Google Drive 

this is the code text

and this is my project.ArcGIS_runtime_java's vision is 10.2.4.I BUILD the project by the steps by the  official guide tell me.

0 Kudos
nita14
by
Occasional Contributor III

Hi,

The shapefile is not corrupted (Please remove the first dot (.) in the file name, there should be gisosm_roads_free_1 instead of gis.osm_roads_free_1) and the code is almost perfect - you should not use unique value renderer  in this case, since there are too many values, which you do not actually add. Also, the rendering time of the whole shapefile on my machine is about 2 minutes - far too long.

When I created a subset of shapefile the rendering is almost instantaneous. I suggest you do not display the whole shapefile, you can use Local Tiled Layer for display purposes.

Here is the valid code of the createMap() function:

private JMap createMap() {
// map
JMap jMap = new JMap();

ArcGISTiledMapServiceLayer basemap = new ArcGISTiledMapServiceLayer(BASEMAP_URL);
basemap.setOpacity(0.5f);
jMap.getLayers().add(basemap);

// Add shapefile
try {
shapefileTable = new ShapefileFeatureTable("C:\\tmp\\gisosm_roads_free_1.shp");
featureLayer = new FeatureLayer(shapefileTable);

// create a renderer
SimpleRenderer simpleRend = new SimpleRenderer(new SimpleLineSymbol(Color.RED, 2.0f, SimpleLineSymbol.Style.SOLID));

// set renderer
featureLayer.setRenderer(simpleRend);
jMap.getLayers().add(featureLayer);

} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(jMap,
wrap(e.getLocalizedMessage()), "",JOptionPane.ERROR_MESSAGE);
}

return jMap;
}

Hope this helps,

Adam

0 Kudos
竹丰刘
New Contributor II

thank you so much!!! 

NOW I can show the map .but it's takes too long to render it.

the shapefile that is too big is the reason why? IS  there any to solve this problem

and if the shapefiles' result is so not good enough,maybe  i should to only use the basemap(which its url is World_Street_Map (MapServer) )and not to use the shapefiles.┑( ̄Д  ̄)┍

0 Kudos