Select to view content in your preferred language

Extracting all XY coordinates from within a polygon?

1273
6
11-24-2017 06:50 AM
TheodoreF
Frequent Contributor

I have multiple polygon shapes covering the UK. How can I create an Excel spreadsheet of all 6 (sometimes 7) figure XY British National Grid coordiantes that fall within these polygons? I don't want just the XYs of the polygon verticies, but all coordinates intersecting the polygon.

Tags (1)
0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

As in Raster to Point if you had a raster representation... which I don't think you have.

Or a select by location, then export or an intersect.

In any event with vector data, you will have to add the coordinates of any resultant points using the standard methods such as the Add XY coordinates tool etc.

Perhaps a visual might help for the non-domestic people

XanderBakker
Esri Esteemed Contributor

You can achieve this with some Python code, but before I post anything, I really wonder why you would like to have something like that? Also if there may be more than a million points inside a polygon it might be more than the 1048576 records (including header) that Excel supports. Especially if you are going to want points every 1 unit (in X and Y). What are you planning to do with this list in Excel?

0 Kudos
TheodoreF
Frequent Contributor

My colleague wants to upload it to our online database to replace our current post code dataset. So when a client places an order (including post code and XY) we can match it to our list of XYs instead of our postcodes (which are less accurate spatially).

And good point about the issue of having millions of records re: Excel!

0 Kudos
DarrenWiens2
MVP Honored Contributor

Have you considered using (or spatially enabling) your database do a point-in-polygon comparison, rather than pre-populating every possible point? Alternatively, calling a geometry service to do the comparison for you? for example: Geoprocessing - Point in polygon search | ArcGIS API for JavaScript 3.22 

TheodoreF
Frequent Contributor

Hi Dan,

Raster to point was my original idea, clipping the raster to a graphics version of the polygon first. Each raster would need to have a cell size of 1 metre though (British XYs are metre units, measured from the extreme bottom left of the country at 0,0). However this would result in a 1TB+ raster (I don't have that space anywhere!).

Here is a sample visual:

I want to know every XY located within this single multi-part polygon.

(The background raster is lightweight, low res.)

0 Kudos
curtvprice
MVP Esteemed Contributor

However this would result in a 1TB+ raster (I don't have that space anywhere!).

Integer rasters are stored compressed, and in this case the values are repeated (polygon id repeated for each cell inside a polygon) so the raster will be much smaller than rows x columns x 4 bytes (32 bits).

If you are really planning to make a row for each grid-point in an Excel spreadsheet, you may want to consider every 100m (10,000x less rows) or 50m 2,500x less rows) and using a table lookup. If some of your polygons are too small to have one point in them, you you can use the MAXIMUM_AREA option in your polygon to raster operation to make sure small polys aren't "dropped" in your raster.