Select to view content in your preferred language

Need to find cells at which the polygon lies and also the cells contained within the polygon

688
5
02-21-2019 01:41 AM
AarthiAdhikesavan
Emerging Contributor

I have divided the map into rows and columns at the backend using the extent height and width of map  (arcgis api for js) and i have a set of polygons on the map.  Now i want to know the cells(rows and columns and each cell size be 500mx500m) at which each polygon lies and also the cells contained within the polygon.  Note that the rows and columns are not visible on the map. I need the java code to find this.  Can anyone help with this ?  Thank you in advance

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Aarthi,

   So you have a GraphicsLayer or a FeatureLayer added to the map which is not visible for the cells?

0 Kudos
AarthiAdhikesavan
Emerging Contributor

Yes, I have polygons are visible on map but cells are not visible on the map, since i have divided the map at the backend. i have attached the image.  Dotted lines indicate that they are not visible on the map and i have described about the input and output. If there is need for clarifications regarding image, please let me know. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

OK. So if you add the polygons as graphics to a FeatureLayer, then you can query this FeatureLayer using the other polygon(s) as the queries geometry property and set the queries spatialRelationship to intersects to find which cells are intersected by the input polygon and then do the query again for "contains" to find out which ones are actually fully contained by the polygon. You can see this sample for how to create a FeatureLayer from graphics clientside.

0 Kudos
AarthiAdhikesavan
Emerging Contributor

Sorry.  I'm not getting your point.  If the cells are not visible then how can I find that they intersects are not ? And one more thing I'm new to GIS related projects.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

You will have to add the cells are actual graphics to a FeatureLayer in the map who's visibility is set to false. Look at the JS API help for info on creating graphics:

Add graphics to a map | ArcGIS API for JavaScript 3.27 

Then you need to use the Query and queryFeatures method on the FeatureLayer to do the spatial query of that feature layer.

Query | API Reference | ArcGIS API for JavaScript 3.27 

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#queryfeatures 

0 Kudos