hii,
i'm working on arcgis runtime java maven application , I just want to know that how to export an sketch(point , line ,polygon) in shapefile format.
please share sample code if available...
@MarkBaird
I'm not completely sure of your workflow here, but how are you planning on drawing your sketches? Are you planning on using graphics and maybe the sketch editor like in this sample?
If this is your plan, then you could write some code to move these geometries into an existing shapefile. There is API which allows you to display and potentially edit shapefiles. The sample here shows how to open a shapefile. The ShapefileFeatureTable class has methods for adding new features.
Remember that a shapefile can only contain one type of geometry. For example if a shapefile schema is for points, then you can't write lines or polygons into the same file.
I would however consider if you really need to use the shapefile format here. There are potentially better workflows for editing and sharing data, but I'd need to know a little more about the bigger picture of what you are trying to achieve.
and for browsing geopackage , what should i do. as i tried the given sample but not working.
From your picture it looks like you have a number of point based graphics which you have added. Assuming you have a shapefile (potentially an empty one which is set up for point geometries) you can do something like this:
- Loop through the graphics in your graphics overlay and for each graphic obtain the geometry (a point in your example).
- For each geometry you will need to create a feature which matches the schema of your shape file. A feature will contain the geometry and optionally attributes too.
- Using the ShapefileFeatureTable class use the addFeature method https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/data/FeatureTable.html#addFeatureAsync(com.esri.arcgisruntime.data.Feature).
(Note that ShapefileFeatureTable inherits from FeatureTable)
There isn't a specific sample showing how to add features to a shapefile, but essentially its the same for any data source so these references will help:
- https://developers.arcgis.com/java/query-and-edit/edit/
- https://developers.arcgis.com/java/sample-code/add-features/
As for browsing shapefiles, just use the JavaFX file chooser and look for .shp files.
exactly, you got the plan what i am asking for ,but want to know that how can i save these geometries into shapefile format as by clicking simple save button. and another , how can i browse any shapefile into my project by using add data button on UI ,i have created.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.